Neal Matthews
13th December 2010, 18:53
Hello,
Has anyone sucessfully written a function server for tfacr4220m000 - Post Sales Invoices. After the continue statement below I am receiving an error "Report name not filled". I have seen the error in similar threads but i'm not entirely sure if they are relevant.
Cheers Neal
spool.device = "ASCIF"
|* Post using AFS
stpapi.put.field( "tfacr4220m000", "ttyp.f", m_ttyp )
stpapi.put.field( "tfacr4220m000", "ttyp.t", m_ttyp )
stpapi.put.field( "tfacr4220m000", "ninv.f",str$(m_ninv))
stpapi.put.field( "tfacr4220m000", "ninv.t",str$(m_ninv))
stpapi.set.report( "tfacr4220m000", "rtfacr422021000",spool.device, error )
if error <> "" then
message("Set " & error)
endif
stpapi.continue.process( "tfacr4220m000", error )
if error <> "" then
message("Continue " & error)
endif
stpapi.end.session( "tfacr4220m000" , error )
if error <> "" then
message("End " & error)
endif
mark_h
14th December 2010, 03:23
When run manually does it create two reports?
Neal Matthews
14th December 2010, 10:43
Hello Mark,
When run manually there is only one report, however there is another report attached to the session for posting errors. Do I need to specify this in my code just in case it does run for whatever reason ?
Cheers Neal
mark_h
14th December 2010, 15:25
It could be - is there a way to turn off one or both of the reports? As far as I know there is still a bug with running sessions with multiple reports.
Neal Matthews
14th December 2010, 16:10
Hello Mark,
Copied session to current VRC and tried to remove the other report but the session will only run correctly with both reports attached. Tried specifying the first report in my code as well and the first report didn't give me a continue error but the second report is key to the posting process so has to be included.
Am i right in thinking that some sessions are not API friendly. Is it worth talking to support?
Cheers Neal
mark_h
14th December 2010, 17:47
You can try taking it to support - last time I did this they gave me a list of supported sessions. I am not sure if this one is on there and they might assist.
As it stands if you have source code you might be able to add "if api.mode then" and try to get everything setup for both reports. Not sure what all would be required to make this work.
kmcinc
4th January 2011, 21:27
Neal,
My AFS for tfacr4220m000 is working fine in our environment. Here is the code; compare it to yours:
stpapi.put.field( "tfacr4220m000", "ttyp.f", min.ttyp )
stpapi.put.field( "tfacr4220m000", "ttyp.t", max.ttyp )
stpapi.get.field( "tfacr4220m000", "btno.fin", str.btno )
stpapi.put.field( "tfacr4220m000", "bref.fin", SPRINTF$( bref, curr.date10 ))
stpapi.set.report("tfacr4220m000", "rtfacr422011000", ar.dev, error.msg)
stpapi.put.field( "tfacr4220m000", "spool.fileout", ar.rep )
stpapi.print.report( "tfacr4220m000", error.msg )
stpapi.end.session( "tfacr4220m000", error.msg )
Neal Matthews
12th January 2011, 17:17
Hello thanks for that unfortunately I can't get that version of the code to post either.
Cheers Neal
kmcinc
12th January 2011, 20:27
The code worked on IVc4 SP22.
Neal Matthews
13th January 2011, 10:51
Cheers I'm on 4c4 SP18. i'll try and get some more SP's loaded and see if that makes a difference.
Thanks Neal
Neal Matthews
19th April 2011, 11:26
Just to close this one off. My original code was OK and worked on SP18.
The problem was down to me calling the API code as each line of the invoice was being created. In the end I added the sales order numbers into an array as the invoice was being created and then set up a loop at the end of the program which went through the array and printed and posted for each Sales Invoice.
My last two issues with API's have been caused by the position of my API in the program as opposed to the API itself so I guess the lesson learned here is always check your API inputs very carefully. Hope this helps anyone looking at this thread in the future.
Cheers Neal
Babu N
22nd January 2016, 12:46
Hi Neal,
I am getting the same error in my AFS when I try to post the invoice.
Could you please help me with the actual logic to be followed?
I have posted below the script I have used.
|Post Invoice
stpapi.put.field("tfacr4220m000","cuno.f",str$(tfgld500.cuno))
stpapi.put.field("tfacr4220m000","cuno.t",str$(tfgld500.cuno))
stpapi.put.field("tfacr4220m000","ttyp.f",str$(ttyp))
stpapi.put.field("tfacr4220m000","ttyp.t",str$(ttyp))
stpapi.put.field("tfacr4220m000","ninv.f",str$(ninv))
stpapi.put.field("tfacr4220m000","ninv.t",str$(ninv))
stpapi.put.field("tfacr4220m000","invd.f",str$(curd))
stpapi.put.field("tfacr4220m000","invd.t",str$(curd))
stpapi.put.field("tfacr4220m000","tedt.fin",str$(curd))
stpapi.put.field("tfacr4220m000","year.fin",str$(fiscal.year))
stpapi.put.field("tfacr4220m000","prod.fin",str$(fiscal.period))
stpapi.put.field("tfacr4220m000","year.tax",str$(tax.year))
stpapi.put.field("tfacr4220m000","vprd.fin",str$(tax.period))
stpapi.put.field("tfacr4220m000","bref.fin",str$("Sales Invoice"))
stpapi.set.report("tfacr4220m000","rtfacr4422011000",pdevice,errm1)
if isspace(errm1) then
stpapi.continue.process("tfacr4220m000",errm)
if not isspace(errm) then
message("%s, Could Not Post The Invoice",errm)
else
stpapi.recover("tfacr4220m000",errm)
endif
endif
stpapi.end.session("tfacr4220m000")
mark_h
22nd January 2016, 14:40
Check your report name - your code has 4422 - but should just be 422. The original code posted by neal has rtfacr422011000, you code has rtfacr4422011000 - 1 character too long.