rahul ingale
4th April 2016, 16:02
In baan IV,How to Approve the Purchase Invoice when the batch is finalized ?
suppose i have created 1 purchase order with 100 rs as amount for quantity 2.then i take receipt for 1 qunatity and created batch with tfgld1101m000 and created purchase invoice for invoice amont 35.then i finalized this batch using tfgld1110m000.
i want to apporve this batch using afs on tfgld1101m000.also it should take care of partial matching.
mark_h
4th April 2016, 17:13
Well it does work with AFS on 4c4. I assume it would also work on other versions. Basically what someone did was document all the steps the user went thru to create the batch, do the matching, etc. So basically the code I wrote, creates the batch, then does all the matching steps. Actually now that I type this the only thing it does not do yet - is actually finalize the batch. But that would probably work also. It was not easy to do but it is possible. If you want to finalize the batch document the steps. You can also search the AFS Forum for the session name to see if there is already some code out there that works.
avpatil
26th October 2020, 05:06
Hi MArk,
tfgld101m000 has session tfgld1101m100 where one enters the transaction type Then upon double clicking it launches a session tfacp2600m000. In that session also there is session tfacp1102m000 for entering additional cost. How does one handle all theses sessons? I have the code, but it hangs when I try to execute stapi.put.field in tfacp2600m000.
Here is my code. I think I am misisng some thing here in terms of handling of these sessions. Before launching AFS, I already created record in tfgld100 and tfgld101. So all I now need is to create invoice thriugh tfacp2600m000.
stpapi.put.field("tfgld1101m000", "tfgld101.year", str$(year))
stpapi.put.field("tfgld1101m000", "tfgld101.btno", str$(i.btno))
stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", l.ttyp)
stpapi.find("tfgld1101m000", l.emsg)
if not isspace(l.emsg) then
l.emsg = "Transaction Type not defined for AP User: " & logname$
l.errf = 1
stpapi.end.session("tfgld1101m000", l.emsg)
endif
if l.errf=1 then
|continue
endif
| stpapi.mark("tfgld1101m000")
stpapi.handle.subproc("tfgld1101m000", "tfgld1101m100", "add")
stpapi.put.field("tfgld1101m100", "tfgld101.year", str$(year))
stpapi.put.field("tfgld1101m100", "tfgld101.btno", str$(i.btno))
stpapi.put.field("tfgld1101m100", "tfgld101.ttyp", l.ttyp)
stpapi.find("tfgld1101m100", l.emsg)
stpapi.handle.subproc("tfgld1101m100", "tfacp2600m000", "add")
stpapi.put.field("tfacp2600m000", "tfacp200.ninv", "0") |Document
stpapi.put.field("tfacp2600m000", "tfacp200.appr", str$(etol(tfacp.inv.purchase)))|Match with Orders
stpapi.put.field("tfacp2600m000", "tfacp200.orno", str$(i.orno)) |Receipt Number
if not isspace(l.dino) then
stpapi.put.field("tfacp2600m000", "tfacp200.shpm", l.dino) |Packing Slip
endif
stpapi.put.field("tfacp2600m000", "tfacp200.load", "") |Load
stpapi.put.field("tfacp2600m000", "tfacp200.shpi", "") |Shipment
stpapi.put.field("tfacp2600m000", "tfacp200.clus", "") |Freight Cluster
stpapi.put.field("tfacp2600m000", "tfacp200.lfbp", l.ifbp) |Invocie from BP
stpapi.put.field("tfacp2600m000", "tfacp200.isup", i.sinv) |Supplier Invoice
stpapi.put.field("tfacp2600m000", "tfacp200.refr", i.refr) |Reference
stpapi.put.field("tfacp2600m000", "tfacp200.docf", str$(i.invd)) |Document Date-
stpapi.put.field("tfacp2600m000", "reference.line", "") |Reference Line
stpapi.put.field("tfacp2600m000", "screen.amnt", str$(i.amnt)) |Screem Amount
stpapi.put.field("tfacp2600m000", "tfacp200.rade", str$(l.mcfr)) |Rate Determiner
stpapi.put.field("tfacp2600m000", "tfacp200.rtyp", l.ratt) |Exchange Rate Type
stpapi.put.field("tfacp2600m000", "tfacp200.rate(1)", str$(l.ratp)) |Rate Factor
stpapi.put.field("tfacp2600m000", "tfacp200.lavl", str$(etol(tfacp.vatc.header))) |Level of Tax calculation
stpapi.put.field("tfacp2600m000", "tfacp200.vatc", l.vatc) |Tax country
stpapi.put.field("tfacp2600m000", "tfacp200.cvat", l.cvat) |Tax code
stpapi.put.field("tfacp2600m000", "screen.vata", str$(i.vata)) |Tax Amount
stpapi.put.field("tfacp2600m000", "tfacp200.vaty", str$(i.vaty)) |Tax yesr
stpapi.put.field("tfacp2600m000", "tfacp200.vatp", str$(i.vatp)) |Tax period
stpapi.put.field("tfacp2600m000", "tfacp200.pryp", l.cotp) |Purchase Order Type
stpapi.put.field("tfacp2600m000", "tfacp200.otyp", "") |Original Invoce Type
stpapi.put.field("tfacp2600m000", "tfacp200.oinv", "0") |Priginal Invouce
stpapi.put.field("tfacp2600m000", "tfacp200.osch", "0") |Orginal Schedule Line
stpapi.put.field("tfacp2600m000", "taxnr", "") |Supplier Tax number
stpapi.put.field("tfacp2600m000", "tfgld200.bloc", "") |Hold Reason
stpapi.put.field("tfacp2600m000", "tfgld200.bank", l.cban) |Bank
stpapi.put.field("tfacp2600m000", "tfgld200.cpay", l.cpay) |Payment Term
stpapi.put.field("tfacp2600m000", "tfgld200.paym", l.paym) |Payment Method
stpapi.put.field("tfacp2600m000", "tfgld200.reas", "") |Reason for payment
stpapi.put.field("tfacp2600m000", "tfgld200.ccrs", l.ccrs) |Late Payment Surcharge
stpapi.put.field("tfacp2600m000", "tfgld200.paya", l.paya) |Payment Agreement
stpapi.put.field("tfacp2600m000", "tfgld200.optb", l.ptbp) |Orginal Pay to BP
stpapi.put.field("tfacp2600m000", "tfgld200.otbb", l.otbp) |Orginal Buy From BP
stpapi.insert("tfacp2600m000",1,l.emsg)
stpapi.end.session("tfacp2600m000",l.emsg)
stpapi.end.session("tfgld1101m100",l.emsg)
stpapi.end.session("tfgld1101m000",l.emsg)
Regards
Arvind Patil
mark_h
26th October 2020, 15:51
See my response in the api forum. To control the sessions you would typically execute an action on the main session. So to launch the subsession - typically after the add command, you would do continue on the controlling session. This would launch the next session and the control would be the session you are in. You can see this by looking at process ids and parent ids. It is not always continue, but most times it is.
So the first process is tfgld1101m000, then when you continue on this session it would launch tfgld1101m100 (and its parent PID should be the PID for tfgld1101m000), then when you continue on tfgld1101m100 and tfacp2600m000 launches it parent should be the PID for tfgld1101m100. That is typically how I know I got the launching correct.
I say typically because sometimes you can run this independent of the main session, but this is the exception and not the rule. I avoid it if I can. I always try to do this in the same order as if I was doing it manually. I usually documented my steps at a high level to get the starting point. Kind of like this:
(1) Run tfgld1101
(2) insert batch
(3) transaction button (really continue in background)
(4) tfgld1101s00 comes up
(5) insert transaction
(6) Continue
etc, etc,.
So basically at steps 3 and 5 I know I have to do a add session and a step to launch it. That is just me.