alibaba
26th July 2020, 00:30
Hi Experts:
I found a strange problem when the stpapi.* functions was running,I made a call from tfgld1101m000 to tfacp1110s000 to tfacp1130s000 and tfacp1131s000 using the stpapi function. The code like this:


stpapi.put.field("tfgld1101m000","tedt.df",str$(date.num()))
|... put other fields---
q = stpapi.change.view("tfgld1101m000",msg)
stpapi.put.field("tfgld1101m000","tfgld101.ttyp","XXX")
q = stpapi.insert("tfgld1101m000", true, msg)
if q = 0 then
t = stpapi.recover("tfgld1101m000", msg)
stpapi.end.session("tfgld1101m000",msg)
else
stpapi.handle.subproc("tfgld1101m000", "tfacp1110s000", "add")
stpapi.continue.process("tfgld1101m000", ttte)
stpapi.put.field("tfacp1110s000","tfacp200.suno", "xxxxxx")
stpapi.put.field("tfacp1110s000","screen.amnt", "0.18")
stpapi.put.field("tfacp1110s000","tfacp200.orno", "xxxxxx")
stpapi.handle.subproc("tfacp1110s000", "tfacp1230s000", "add")
stpapi.handle.subproc("tfacp1110s000", "tfacp1130s000", "add")
stpapi.handle.subproc("tfacp1130s000", "tfacp1131s000", "add")
q = stpapi.insert("tfacp1110s000", true, msg)
if q = 0 then
t = stpapi.recover("tfacp1110s000", msg)
stpapi.end.session("tfacp1110s000",msg)
else
stpapi.put.field("tfacp1131s000","tdpur045.orno", "xxxxxx")
stpapi.put.field("tfacp1131s000","tdpur045.pono", "1")
| stpapi.put.field("tfacp1131s000","tdpur045.srnb", "1")
q = stpapi.find("tfacp1131s000",msg)
if q = 1 then
q = stpapi.mark("tfacp1131s000",msg)
if q = 1 then
stpapi.put.field("tfacp1131s000","tdpur045.matc", "2")
q = stpapi.update("tfacp1131s000",true,msg)
q = stpapi.save("tfacp1131s000",msg)
if q = 0 then
t = stpapi.recover("tfacp1131s000", msg)
endif
stpapi.end.session("tfacp1131s000",msg)
stpapi.end.session("tfacp1130s000",msg)
endif
endif

When the script runs, stpapi.insert("tfacp1110s000", true, msg) is successful. But when I looked at the background running session, I found that session tfacp1130s000 had started, but session tfacp1131s000 did not start, so part stpapi.find("tfacp1131s000",msg) of the script failed to execute.
I debugged the program and found that tfacp1131s000 was started by tfacp1130s000. However, in tfacp1130s000, you need to determine whether you are running in background mode( background = 0 or 1 ). If it is no, tfacp1131s000 is not started. In the above script, after entering the debug mode of tfacp1130s000, the pre-defined variable background = 0.
I looked at tfacp1130s000 in the shell windows and found that its PPID(parent process) was not tfacp1110s000, but ottstpapiserv.
I tried to modify the script to like this

stpapi.put.field("tfgld1101m000","tedt.df",str$(date.num()))
|... put other fields---
q = stpapi.change.view("tfgld1101m000",msg)
stpapi.put.field("tfgld1101m000","tfgld101.ttyp","XXX")
q = stpapi.insert("tfgld1101m000", true, msg)
if q = 0 then
t = stpapi.recover("tfgld1101m000", msg)
stpapi.end.session("tfgld1101m000",msg)
else
stpapi.handle.subproc("tfgld1101m000", "tfacp1110s000", "add")
stpapi.continue.process("tfgld1101m000", ttte)
stpapi.put.field("tfacp1110s000","tfacp200.suno", "xxxxxx")
stpapi.put.field("tfacp1110s000","screen.amnt", "0.18")
stpapi.put.field("tfacp1110s000","tfacp200.orno", "xxxxxx")
stpapi.handle.subproc("tfacp1110s000", "tfacp1230s000", "add")
stpapi.handle.subproc("tfacp1110s000", "tfacp1130s000", "add")
stpapi.handle.subproc("tfacp1130s000", "tfacp1131s000", "add")
q = stpapi.insert("tfacp1110s000", true, msg)
if q = 0 then
t = stpapi.recover("tfacp1110s000", msg)
stpapi.end.session("tfacp1110s000",msg)
else

stpapi.end.session("tfacp1230s000",msg)
stpapi.end.session("tfacp1130s000",msg)
stpapi.continue.process("tfacp1110s000", msg)

stpapi.put.field("tfacp1131s000","tdpur045.orno", "xxxxxx")
stpapi.put.field("tfacp1131s000","tdpur045.pono", "1")
| stpapi.put.field("tfacp1131s000","tdpur045.srnb", "1")
q = stpapi.find("tfacp1131s000",msg)
if q = 1 then
q = stpapi.mark("tfacp1131s000",msg)
if q = 1 then
stpapi.put.field("tfacp1131s000","tdpur045.matc", "2")
q = stpapi.update("tfacp1131s000",true,msg)
q = stpapi.save("tfacp1131s000",msg)
if q = 0 then
t = stpapi.recover("tfacp1131s000", msg)
endif
stpapi.end.session("tfacp1131s000",msg)
stpapi.end.session("tfacp1130s000",msg)
endif
endif

when process tfacp1130s000 starts again by stpapi.continue.process("tfacp1110s000", msg), the value of the predefined variable background = 1, and tfacp1131s000 starts normally. The function stpapi.find("tfacp1131s000",msg) executed successfully. at this time,I looked at tfacp1130s000/tfacp1131s000 in the shell windows and found that its PPID(parent process) is tfgld1101m000 !
But I don't know why? Why the previous use of the function stpapi.handle.subproc("tfacp1110s000", "tfacp1130s000", "add"), the variable background of tfacp1130s000 is 0. But after executing the stpapi.continue.process("tfacp1110s000", msg) command again on tfacp1110s000, the variable background for tfacp1130s000 is 1.
Thanks!

bhushanchanda
26th July 2020, 09:25
By my personal experience, I can say, there are issues with using AFS for booking Purchase Invoices in LN(I assume that is what you are looking for). I would recommend to identify the tables involved and either go with db.* or dal.* functions to avoid any issues. You might need to look for DLL's wherever necessary. Using AFS, we found several similar issues. If you resolve one, you might get trapped in another and it becomes a never ending journey of troubleshooting.

alibaba
26th July 2020, 19:58
Thanks for your reply bhushanchanda.I think I found my problem: I entered the wrong STPAPI function order. Make the session start prematurely...

avpatil
26th October 2020, 05:18
Hi,
I am also trying to do similar.
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 missing 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 through 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 Pati

mark_h
26th October 2020, 15:35
Typically in 4c4. I would expect to see a continue or action on the main session to launch a subsession. This comes after the add. Like below from one of our:

| Start Session tfgld1101s000 ... Insert CTR transaction holder
stpapi.handle.subproc(sess.gld1100, sess.gld1101, "add")
| 1.2 Select Continue button
stpapi.continue.process(sess.gld1100, e.msg

So in yours I would had this:

stpapi.handle.subproc("tfgld1101m000", "tfgld1101m100", "add")
stpapi.continue.process("tfgld1101m000", l.emsg) |<<<== Launch tfgld1101m000
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)

The same would be true for tfacp2600m000. Below is a subroutines for creating a batch and adding purchase invoices for some contractors. Just remember we are on 4c4.


function api.create.batch()
{
long io.date
string str.date(10)

p.info = "Creating Batch ..."
display("p.info")
refresh()

num.to.date(date.num(), c.yyyy, c.mm, c.dd)

c.btno = get.next.btno(c.yyyy)
c.fprd = get.cur.fiscal.period()
c.rprd = get.cur.report.period()
c.vprd = get.cur.tax.period()

sess.gld1100 = "tfgld1100m000"
sess.gld1101 = "tfgld1101s000"

| 1. tfgld1100m000 (Maintain Transactions)
| 1.0 Input Batch data
stpapi.put.field(sess.gld1100, "tfgld100.tedt", str$(date.num()))
stpapi.put.field(sess.gld1100, "tfgld100.year", str$(c.yyyy))
stpapi.put.field(sess.gld1100, "tfgld100.btno", str$(c.btno))
stpapi.put.field(sess.gld1100, "tfgld100.bref", sprintf$("Contractor Labor (%02d/%02d/%02d)", mm,dd,yyyy\100))
stpapi.put.field(sess.gld1100, "tfgld100.fprd", str$(c.fprd))
stpapi.put.field(sess.gld1100, "tfgld100.rprd", str$(c.rprd))
stpapi.put.field(sess.gld1100, "tfgld100.vyer", str$(c.yyyy))
stpapi.put.field(sess.gld1100, "tfgld100.vprd", str$(c.vprd))
| 1.1 Insert a batch record
rc = stpapi.insert(sess.gld1100, 1, e.msg)
if not isspace(e.msg) then
stpapi.end.session(sess.gld1100)
return
endif

save.year = c.yyyy | used to update the contractor pro forma header
save.btno = c.btno

stpapi.get.field(sess.gld1100, "tfgld100.tedt", io.fld)
io.date = lval(io.fld)
str.date = num.to.date$(io.date, 2)

| Start Session tfgld1101s000 ... Insert CTR transaction holder
stpapi.handle.subproc(sess.gld1100, sess.gld1101, "add")
| 1.2 Select Continue button
stpapi.continue.process(sess.gld1100, e.msg)

| stpapi.get.field(sess.gld1101,"tedt.f",io.fld)
| stpapi.get.field(sess.gld1101,"tfgld101.year",io.fld)
| stpapi.get.field(sess.gld1101,"tfgld101.btno",io.fld)
| stpapi.get.field(sess.gld1101,"fyer.f",io.fld)
| stpapi.get.field(sess.gld1101,"fprd.f",io.fld)
| stpapi.get.field(sess.gld1101,"ryer.t",io.fld)
| stpapi.get.field(sess.gld1101,"rprd.t",io.fld)
| stpapi.get.field(sess.gld1101,"vyer.f",io.fld)
| stpapi.get.field(sess.gld1101,"vprd.f",io.fld)
|
stpapi.save(sess.gld1101,e.msg)

| 2. tfgld1101s000 (Maintain Transactions)
| 2.0 Input Batch transaction type
stpapi.put.field(sess.gld1101, "tfgld101.ttyp", "CTR")
| 2.1 Insert a CTR transaction into that batch
rc = stpapi.insert(sess.gld1101, 1, e.msg)
if not isspace(e.msg) then
stpapi.end.session(sess.gld1101)
stpapi.end.session(sess.gld1100)
return
endif

}
function api.create.approve.pur.inv()
{
domain tfgld.refr t.refr
domain tfacp.stap t.stap

string lasthalf(30)
string firsthalf(30),firstname(20)
string lastname(12), firstinit(1), middileinit(1)

i.ctr = i.ctr + 1
p.info = "Creating Invoice for employee: " &
str$(tccom001.emno) &
"(" & str$(i.ctr) & ")"
display("p.info")
refresh()


sess.acp1110 = "tfacp1110s000"
sess.acp1230 = "tfacp1230s000"
sess.acp1130 = "tfacp1130s000"
sess.acp1131 = "tfacp1131s000"
sess.acp1140 = "tfacp1140s000"
sess.acp1141 = "tfacp1141s000"
sess.acp1133 = "tfacp1133s000"

|------------------------------------------------------------
| I'm using the free$ (baan system variable) to let some
| sessions (tfacp1131s000, tfacp1133s000) know they were
| called from this contractor api process. Each of these
| sessions were compiled with Qkey overriding event calls.
|------------------------------------------------------------
free$ = "contractor.api"

| 2.2 Select CTR transaction (last.set)
rc = stpapi.browse.set(sess.gld1101, "last.set", e.msg)

| 2.3 Select Transaction button (continue option)
stpapi.handle.subproc(sess.gld1101, sess.acp1110, "add")
stpapi.continue.process(sess.gld1101, e.msg)

stpapi.save(sess.acp1110,e.msg)

| 3. tfacp1110s000 (Maintain Pur Inv)
| 3.0 Input pur inv data
stpapi.put.field(sess.acp1110, "tfacp200.ttyp", "CTR")
| 20060131.start Use default series
| stpapi.put.field(sess.acp1110, "tfacp200.ninv", "22")
stpapi.put.field(sess.acp1110, "tfacp200.ninv", str$(tfgld011.dsrn))
stpapi.put.field(sess.acp1110, "ref.po", strip$(tccom020.refa))
| 20070518.st Use tcudi005
| stpapi.put.field(sess.acp1110, "tfacp200.suno", strip$(tccom001.namb))
stpapi.put.field(sess.acp1110, "tfacp200.suno", strip$(tcudi005.suno)) | 20070518.end
| 20060116.st Change isup format and the refr fields
|t.refr = sprintf$("%02d%02d%02d%02d%s", mm, dd, yyyy\100, tfgld911.serc, strip$(tccom001.nama))
|t.refr = sprintf$("%02d%02d%02d%02d%-06d", mm, dd, yyyy\100, tfgld911.serc, tccom001.emno)
rc = string.scan(tccom001.nama,"%s,%s",firsthalf,lasthalf)
lastname = shiftl$(firsthalf(1;8))
rc = string.scan(shiftl$(lasthalf),"%s %s",firstname,middileinit)
firstinit = firstname(1;1)

t.refr = sprintf$("%02d%02d%02d%04d%s%s%s", mm, dd, tfgld911.serc,inv.count, firstinit, middileinit,lastname)
stpapi.put.field(sess.acp1110, "tfacp200.isup", t.refr)

|20060127.start - Change date again.
|stpapi.put.field(sess.acp1110, "tfacp200.docd", sprintf$("%02d%02d%04d", mm, dd, yyyy))
stpapi.put.field(sess.acp1110, "tfacp200.docd", str$(date.t))

| 20060116.st Change isup format and the refr fields
|t.refr = sprintf$("C%-06d %02d%02d%02d%02d", tccom001.emno, mm, dd, yyyy\100, tfgld911.serc)
| 20160413 Modify t.refr to include year
t.refr = sprintf$("C%02d%02d%02d%04d%-06d%s", mm, dd, tfgld911.serc, yyyy, tccom001.emno, strip$(tccom001.nama))
stpapi.put.field(sess.acp1110, "tfacp200.refr", t.refr)
stpapi.put.field(sess.acp1110, "screen.amnt", str$(round(tfgld911.amnt, 2, 0)))
stpapi.put.field(sess.acp1110, "tfacp200.reas", "5")
stpapi.put.field(sess.acp1110, "tfacp200.orno", strip$(tccom020.refa))

stpapi.get.field(sess.acp1110, "tfacp200.orno", io.fld)
stpapi.put.field(sess.acp1110, "tfacp200.orno", strip$(tccom020.refa))

| 3.1 Insert a purchase invoice
stpapi.handle.subproc(sess.acp1110, sess.acp1230, "add")
rc = stpapi.insert(sess.acp1110, 1, e.msg)
if not isspace(e.msg) then
stpapi.end.session(sess.acp1110)
return
endif

| 4. tfacp1230s000 (Maint Matched Pur Inv)
| 4.1 Select Variance Option (USER.0)
stpapi.handle.subproc(sess.acp1230, sess.acp1133, "add")
stpapi.application.option( sess.acp1230, 1, 0, e.msg ) | Variance button

| 5. tfacp1133s000 (Maint Match Pur Inv)
| 5.1 Insert T192 with Regular Hours
| Get the new Invoice Number ...
stpapi.get.field(sess.acp1133, "tfacp101.ninv", io.fld)
save.docn = lval(io.fld)

stpapi.put.field(sess.acp1133, "tfacp101.ttyp", "CTR")
stpapi.put.field(sess.acp1133, "tfacp101.ninv", str$(save.docn))
stpapi.put.field(sess.acp1133, "tfacp101.orno", "0")
stpapi.put.field(sess.acp1133, "tfacp101.pono", "0")
stpapi.put.field(sess.acp1133, "tfacp101.seri", "1")
rc = stpapi.change.view(sess.acp1133, e.msg)
stpapi.put.field(sess.acp1133, "tfacp101.leac", "T192")
stpapi.put.field(sess.acp1133, "tfacp101.dim1", tfgld911.ctrg)
| 20060918 Calculate the amount.
| stpapi.put.field(sess.acp1133, "tfacp101.amnt", str$(round((tfgld911.hour + tfgld911.othr) * tfgld911.rate, 2, 0)))
acp101.amnt = round((tfgld911.hour + tfgld911.othr) * tfgld911.rate, 2, 1)
stpapi.put.field(sess.acp1133, "tfacp101.amnt", str$(acp101.amnt))
stpapi.put.field(sess.acp1133, "tfacp101.dbcr", "1")
stpapi.put.field(sess.acp1133, "tfacp101.qty1", str$(tfgld911.hour + tfgld911.othr))
stpapi.put.field(sess.acp1133, "tfacp101.refr", "W/E " & t.refr)
rc = stpapi.insert(sess.acp1133, 1, e.msg)
if not isspace(e.msg) then
stpapi.end.session(sess.acp1133)
stpapi.end.session(sess.acp1230)
stpapi.end.session(sess.acp1110)
return
endif

| 5.2 Insert T192 with OT Hours
stpapi.put.field(sess.acp1133, "tfacp101.ttyp", "CTR")
stpapi.put.field(sess.acp1133, "tfacp101.ninv", str$(save.docn))
stpapi.put.field(sess.acp1133, "tfacp101.orno", "0")
stpapi.put.field(sess.acp1133, "tfacp101.pono", "0")
stpapi.put.field(sess.acp1133, "tfacp101.seri", "2")
rc = stpapi.change.view(sess.acp1133, e.msg)
stpapi.put.field(sess.acp1133, "tfacp101.leac", "T192")
stpapi.put.field(sess.acp1133, "tfacp101.dim1", tfgld911.ctrg)

|20060918.start Change calculation to make sure it balances with the tfgld911.amnt
| stpapi.put.field(sess.acp1133, "tfacp101.amnt", str$(round(tfgld911.othr * 0.5 * tfgld911.rate, 2, 0)))
stpapi.put.field(sess.acp1133, "tfacp101.amnt", str$(round(tfgld911.amnt - acp101.amnt, 2, 1)))
stpapi.put.field(sess.acp1133, "tfacp101.dbcr", "1")
stpapi.put.field(sess.acp1133, "tfacp101.qty1", str$(tfgld911.othr))
stpapi.put.field(sess.acp1133, "tfacp101.refr", "OT " & t.refr)
rc = stpapi.insert(sess.acp1133, 1, e.msg)
if not isspace(e.msg) then
stpapi.end.session(sess.acp1133)
stpapi.end.session(sess.acp1230)
stpapi.end.session(sess.acp1110)
return
endif

| 5.3 Insert 661110 with Booked Hours Debit
stpapi.put.field(sess.acp1133, "tfacp101.ttyp", "CTR")
stpapi.put.field(sess.acp1133, "tfacp101.ninv", str$(save.docn))
stpapi.put.field(sess.acp1133, "tfacp101.orno", "0")
stpapi.put.field(sess.acp1133, "tfacp101.pono", "0")
stpapi.put.field(sess.acp1133, "tfacp101.seri", "3")
rc = stpapi.change.view(sess.acp1133, e.msg)
stpapi.put.field(sess.acp1133, "tfacp101.leac", "661110")
stpapi.put.field(sess.acp1133, "tfacp101.dim1", tfgld911.ctrg)
stpapi.put.field(sess.acp1133, "tfacp101.amnt", str$(round(tfgld911.amnt.a, 2, 0)))
stpapi.put.field(sess.acp1133, "tfacp101.dbcr", "1")
stpapi.put.field(sess.acp1133, "tfacp101.qty1", str$(tfgld911.hour + tfgld911.othr))
stpapi.put.field(sess.acp1133, "tfacp101.refr", t.refr)
rc = stpapi.insert(sess.acp1133, 1, e.msg)
if not isspace(e.msg) then
stpapi.end.session(sess.acp1133)
stpapi.end.session(sess.acp1230)
stpapi.end.session(sess.acp1110)
return
endif

| 5.4 Insert T193 with Booked Hours Credit
stpapi.put.field(sess.acp1133, "tfacp101.ttyp", "CTR")
stpapi.put.field(sess.acp1133, "tfacp101.ninv", str$(save.docn))
stpapi.put.field(sess.acp1133, "tfacp101.orno", "0")
stpapi.put.field(sess.acp1133, "tfacp101.pono", "0")
stpapi.put.field(sess.acp1133, "tfacp101.seri", "1")
rc = stpapi.change.view(sess.acp1133, e.msg)
| 20050829.st Change credit account
| stpapi.put.field(sess.acp1133, "tfacp101.leac", "T193")
stpapi.put.field(sess.acp1133, "tfacp101.leac", "T192") | 20050829.end
stpapi.put.field(sess.acp1133, "tfacp101.dim1", tfgld911.ctrg)
stpapi.put.field(sess.acp1133, "tfacp101.amnt", str$(round(tfgld911.amnt.a, 2, 0)))
stpapi.put.field(sess.acp1133, "tfacp101.dbcr", "2")
stpapi.put.field(sess.acp1133, "tfacp101.qty1", str$(tfgld911.hour + tfgld911.othr))
stpapi.put.field(sess.acp1133, "tfacp101.refr", t.refr)
rc = stpapi.insert(sess.acp1133, 1, e.msg)
if not isspace(e.msg) then
stpapi.end.session(sess.acp1133)
stpapi.end.session(sess.acp1230)
stpapi.end.session(sess.acp1110)
return
endif

| 5.5 tfacp1133s000 End
stpapi.end.session(sess.acp1133)

| 4.2 tfacp1230s000 End
stpapi.end.session(sess.acp1230)

stpapi.handle.subproc(sess.acp1110, sess.acp1130, "add")
stpapi.continue.process(sess.acp1110, e.msg)
e.msg = ""

stpapi.handle.subproc(sess.acp1130, sess.acp1131, "add")
stpapi.end.session(sess.acp1131)

stpapi.handle.subproc(sess.acp1130, sess.acp1140, "add")
stpapi.application.option( sess.acp1130, 1, 0, e.msg ) | Approve button
e.msg = "" | "Process gone" mesage OK!

stpapi.handle.subproc(sess.acp1140, sess.acp1133, "add")
stpapi.end.session(sess.acp1133)

stpapi.end.session(sess.acp1140)
stpapi.end.session(sess.acp1130)
stpapi.end.session(sess.acp1110)

free$ = ""
}

avpatil
26th October 2020, 16:04
Thank you Mark. I think even in IVc4, One needs to double click on Transaction type to launch the session to enter the session to enter Purchase Invoice. in Baan V and ERP, there are options in form itself to launch function that will in this case would launch tfacp2600m000 from tfgld1101m100. I was looking for AFS command to execute a form command

Thanks

mark_h
26th October 2020, 23:44
Man did I miss the question. :) Try looking at stpapi.form.command for LN. You can refer to the sticky thread for some older documentation. Can probably search this forum also for examples.

void stpapi.form.command(string session, long command.type, string command.prog, ref string err.mesg)
ARGUMENTS
session Name of the session this command is executed on.
command.type The type of form command to be executed. The following values apply:
2 - session
5 - function
command.prog The code of the session or the name of the function to be executed.
err.mesg This parameter will contain the text of the error message if the function cannot complete normally.
DESCRIPTION
This function causes the specified form command to be executed in the specified session.
RETURN VALUES
None

EXAMPLE
stpapi.put.field("dtfsa1501m000", "dtfsa101.seno", str$(i.seno))
ret = stpapi.find("dtfsa1501m000", error.msg)
if ret = 1 then
ret = stpapi.mark("dtfsa1501m000", error.msg)
if ret = 1 then
stpapi.form.command("dtfsa1501m000", 5, "calculate.vat",
error.msg)
endif
endif