newbie007
24th August 2010, 21:51
Hi,

I have created a session with stpapi functions for tfacr2240m000 and tfacp2230m000. When I fill in all the field values and execute the stpapi.cont.process, it looks like it is running but nothing happens. I get an error message " <Ctrl>[A]: Simulate Write Off Payment Differences" while execute the stpapi.cont.process. I don't have the source code to look debug.


Here is the code

stpapi.put.field("tfacr2240m000","cuno.f",tfacr900.scuno)
stpapi.put.field("tfacr2240m000","cuno.t",tfacr900.scuno)
stpapi.put.field("tfacr2240m000","ttyp.f",tfacr900.ttyp)
stpapi.put.field("tfacr2240m000","ttyp.t",tfacr900.ttyp)
stpapi.put.field("tfacr2240m000","ninv.f",str$(tfacr900.ninv))
stpapi.put.field("tfacr2240m000","ninv.t",str$(tfacr900.ninv))
stpapi.put.field("tfacr2240m000","iyer.f",str$(1999))
stpapi.put.field("tfacr2240m000","iprd.f",str$(1))
stpapi.put.field("tfacr2240m000","iyer.t",year.s)
stpapi.put.field("tfacr2240m000","iprd.t",month.s)
stpapi.put.field("tfacr2240m000","ccur.f","USD")
stpapi.put.field("tfacr2240m000","ccur.t","USD")
stpapi.put.field("tfacr2240m000","user.ccur","USD")
stpapi.put.field("tfacr2240m000","max.amount",str$(999999999.00))
stpapi.put.field("tfacr2240m000","max.perc",str$(100.00))
stpapi.put.field("tfacr2240m000","doc.date",str$(date.num()))
stpapi.put.field("tfacr2240m000","fin.year",year.s)
stpapi.put.field("tfacr2240m000","fin.prod",month.s)
stpapi.put.field("tfacr2240m000","vat.year",year.s)
stpapi.put.field("tfacr2240m000","vat.prod",month.s)
stpapi.put.field("tfacr2240m000","rep.year",str$(0))
stpapi.put.field("tfacr2240m000","rep.prod",str$(0))
stpapi.put.field("tfacr2240m000","tfacr000.pdif",tfacr000.pdif)
stpapi.put.field("tfacr2240m000","tfgld003.psep","/")
stpapi.put.field("tfacr2240m000","tfacr200.cuno",tfacr900.scuno)
stpapi.put.field("tfacr2240m000","documnet",str$(document))
stpapi.put.field("tfacr2240m000","print.details",str$(etol(tcyesno.no)))
stpapi.put.field("tfacr2240m000","sim.pay.difference",str$(0))
|stpapi.set.report(tfacr2240m000","rtfacr2240110002",device.f,error.msg)
stpapi.continue.process("tfacr2240m000",error.msg)
stpapi.get.mess.code("tfacr2240m000", error.msg)

if (strip$(error.msg) <> "" and strip$(error.msg) <> "Process is gone") then
message("Write of ACR Payment Process = %s",error.msg) endif
stpapi.end.session("tfacr2240m000")


here is the AFS log;

LOGGING STARTED
08-24-2010
8->get.fields
8<-get.fields 0 cuno.f 1 user.ccur 0 cuno.t 1 ttyp.f 1 ttyp.t 1 ninv.f 1 ninv.t 1 iyer.f 1 tfgld003.psep 0 iprd.f 1 iyer.t 1 tfgld003.psep 0 iprd.t 1 ccur.f 1 ccur.t 1 max.amount 1 max.perc 1 doc.date 1 fin.year 1 tfgld003.psep 0 fin.prod 1 rep.year 1 tfgld003.psep 0 rep.prod 1 vat.year 1 tfgld003.psep 0 vat.prod 1 document 1 print.details 1 tfacr000.pdif 0 batch 0 tfacr200.cuno 0
>tfacr2240m000 put.field:cuno.f LBS101
>tfacr2240m000 put.field:cuno.t LBS101
>tfacr2240m000 put.field:ttyp.f SIV
>tfacr2240m000 put.field:ttyp.t SIV
>tfacr2240m000 put.field:ninv.f 20027683
>tfacr2240m000 put.field:ninv.t 20027683
>tfacr2240m000 put.field:iyer.f 1999
>tfacr2240m000 put.field:iprd.f 1
>tfacr2240m000 put.field:iyer.t 2010
>tfacr2240m000 put.field:iprd.t 08
>tfacr2240m000 put.field:ccur.f USD
>tfacr2240m000 put.field:ccur.t USD
>tfacr2240m000 put.field:user.ccur USD
>tfacr2240m000 put.field:max.amount 999999999
>tfacr2240m000 put.field:max.perc 100
>tfacr2240m000 put.field:doc.date 734008
>tfacr2240m000 put.field:fin.year 2010
>tfacr2240m000 put.field:fin.prod 08
>tfacr2240m000 put.field:vat.year 2010
>tfacr2240m000 put.field:vat.prod 08
>tfacr2240m000 put.field:rep.year 0
>tfacr2240m000 put.field:rep.prod 0
>tfacr2240m000 put.field:tfacr000.pdif ARP
>tfacr2240m000 put.field:documnet 20
>tfacr2240m000 put.field:print.details 2
>tfacr2240m000 put.field:sim.pay.difference 0
>tfacr2240m000 continue.process
8->cont.process
8<-cont.process 1
<tfacr2240m000 <Ctrl>[A]: Simulate Write Off Payment Differences
>tfacr2240m000 get.mess.code
<tfacr2240m000 tfacrs0176
>tfacr2240m000 end.session
8->end.program
9<-exit.child 0
8<-end.program 1
8<-exit.child
>tfacr2240m000 end.session
12->end.program
13<-exit.child 0
12<-end.program 1
12<-exit.child


Can anyone suggest what might be the issue ?. Any suggestion are appreciated.

Thanks
Newbie07

mark_h
25th August 2010, 15:52
What version of Baan are you on? We don't use this session or at least I have never used it. My question is what is in the stpapi.continue error.msg field? As a matter of fact I would remove the stpapi.get.mess.code. Very seldom do I use that. Also check the form - on my system there are three buttons. The simulate button would be choice.user.0 I believe on my system. Just want to double check that they did not do something different on your session.

I also added some code tags and turned smiles off on the post to make it easier to read. You can edit the post to see what all I did.

newbie007
27th August 2010, 06:47
Thanks Mark.
We are on BaanIVc4 SP16. I have asked baan to the latest debug object for otfacr2240 but since I don't have ptfacr2240. I cannot see what is happening in the code. I checked the form to make sure that continue.process is not executing user.0. On executing stpapi.cont.process on tfacr2240m000, the error.msg variable has "Ctrl>[A]: Simulate Write Off Payment Differences" not sure why I am getting this. I have all the stpapi.put.fields entered correctly, I am able to process the invoice manually without any issue. But thru AFS, I get this error message.

Also, I have removed the command, stpapi.get.mess.code from the code and still have the same issue.

thanks
Newbie

mark_h
27th August 2010, 16:53
Several things I noticed after looking some more - and I would look at them in this order.

(1) Is that code your actual code? The field document is mis-spelled in the stpapi.put.
(2) Do you get the same error if print the details and set the report
(3) Can you add a screen shot of the form for your system? Several fields you are putting are not on my system. The main one is stpapi.put.field("tfacr2240m000","sim.pay.difference",str$(0)). Not on our system - is this a yes/no field or what?
(4) I don't think you need to put tfgld003.psep field. Just a side item.
(5) And last but not least - I have to ask just to confirm. Have you double checked to see if it is actually working? I just noticed the message tfacrs0176 is just a warning on our system.

Now - the misspelled document field might just be the solution, but it could be several other things. The object or the stpapi libraries them selves - but I would save that for last.

newbie007
27th August 2010, 19:11
Hi Mark,

Please see my replies in bold


(1) Is that code your actual code? The field document is mis-spelled in the stpapi.put.

---> I have corrected the my code to have the "document" spelled correct and still get the same error message.


(2) Do you get the same error if print the details and set the report

----> Strangely, when I have the report set as "print.details = tcyesno.yes", the program worked and processed(wrote off) the invoice.

----> if print.details = tcyesno.no, then nothing happens...

(3) Can you add a screen shot of the form for your system? Several fields you are putting are not on my system. The main one is stpapi.put.field("tfacr2240m000","sim.pay.difference",str$(0)). Not on our system - is this a yes/no field or what?

----> sim.pay.difference is one of the fields in the script which is set if you want to simulate. I just wanted to make sure it is set to No" . It's domain is tcbool.

(4) I don't think you need to put tfgld003.psep field. Just a side item.

-----> since the program is looking at the tfgld003.psep on the afs.log, i just wanted to be sure, I am passing the correct value, to be sure that this is not the reason why I am getting the error.


(5) And last but not least - I have to ask just to confirm. Have you double checked to see if it is actually working? I just noticed the message tfacrs0176 is just a warning on our system.

---> Yeah, I checked to make sure if the invoice got processed. As it creates the batch and the tfacr200 will have a the write-off document and the balance of the original invoice will be "zero".

The process didn't create any batch or process the ACR invoice.


Now - the misspelled document field might just be the solution, but it could be several other things. The object or the stpapi libraries them selves - but I would save that for last.

----> I have the lastest SPI libraries, so I don't think that is an issue.


thanks
Newbie

mark_h
27th August 2010, 20:08
Okay - form looks like our system. The stpapi.put for the sim.pay.difference and for tflgd003.psep really do not do anything - I would remove them(that is just me). At least with #2 you have a work around - you can always sent the report to a dummy file I do that a lot. Something you can try - define the report(issue the stpapi.report command) but set the print details field back to NO. Run it again. I think on all of the AFS code I have written if the session called for a report I always did the stpapi.set.report(not 100% sure on that, but might very well be true).

It probably is something in the script for the session, but I am not sure what. If printing the report works then you at least have a work around. Just the basic code you included should work and I was really hoping it was the misspelled field called document.

newbie007
31st August 2010, 19:25
Thanks Mark..

I have one more question?.

Example of Data:

Say I have invoices SIV 10000001, SIV 10000010 which needs to be written off. I also have invoices SIV 10000002 which I don't want to write off

Issue:

I am calling tfacr2240m000 from a custom program and passing the transaction type and invoice numbers to be written off one at a time as the invoice number are not is a continuous range. Each time the program runs it creates a batch number and a write off document number. So if you have 1000 odd invoices not in a range, then you would end up with 1000 batch numbers and write off document numbers. I am wondering, if there is a way to have only one batch number and one document number for the batch of 1000 odd non continuous invoices numbers to be written off. Any ideas?.

thanks

mark_h
31st August 2010, 20:28
That turns out to be a functional question I can not really answer. I have never written one for these sessions. The few I have written usually first create a batch and then go into the subsessions to create the transactions. The few I have written in the tfgld area usually start with tfgld1101m000(I think).