tan.wang
26th August 2016, 11:08
Could any one help me to solve my question?
we want open the session tfacp2600m000 by afs and set value in it
but It can not be direct open,
If we want to open "tfacp2600m000" we only can use form command
stpapi.form.command("tfgld1140m000", 5, "exec.cont.process",error.msg)
in session tfgld1140m000 first,it will open "tfacp2600m000" session

we try to
|==================AFS tfgld1140m000=========================
stpapi.put.field("tfgld1140m000", "tfgld140.user", logged.user)
ret = stpapi.find("tfgld1140m000", error.msg)
if ret = 1 then

stpapi.get.field("tfgld1140m000", "tfgld140.ttyp", l.afs.ttyp)
stpapi.get.field("tfgld1140m000", "tfgld140.btno", l.afs.btno)

ret = stpapi.mark("tfgld1140m000", error.msg)
if ret = 1 then
stpapi.handle.subproc("tfgld1140m000", "tfacp2600m000","add")
stpapi.form.command("tfgld1140m000", 5, "exec.cont.process", error.msg)

|==================AFS tfacp2600m000=========================
stpapi.put.field("tfacp2600m000", "tfacp200.ttyp", l.afs.ttyp)
stpapi.put.field("tfacp2600m000", "tfacp200.ninv", default)

stpapi.put.field("tfacp2600m000", "tfacp200.appr", str$(etol(tfacp.inv.purchase)))
stpapi.put.field("tfacp2600m000", "tfacp200.orno", tdddc002.orno)
stpapi.put.field("tfacp2600m000", "tfacp200.ifbp", tdddc002.ifbp)

l.docd = num.to.date$(tdddc002.usdt, 2)
stpapi.put.field("tfacp2600m000", "tfacp200.docd", l.docd)

stpapi.put.field("tfacp2600m000", "screen.amnt", str$(tdddc002.iamt))
stpapi.put.field("tfacp2600m000", "tfacp200.lvat", str$(etol(tfacp.vatc.header)))


stpapi.form.command("tfacp2600m000", 5, "exec.user.0", error.msg)

but it's not work,we can't set value on "tfacp2600m000" session and stpapi.form.command("tfacp2600m000", 5, "exec.user.0", error.msg)is not work, althoughwe set tfacp200.appr = tfacp.inv.purchase but there was a error return,the massage is tfacp200.appr<> tfacp.inv.purchase.

Does any body have an Idea about this issue?
thank you

tan.wang
26th August 2016, 11:13
we found if we open session by manual"tfgld1140m000"→ "tfacp2600m000"
session "tfacp2600m000" will execute add.set() and before.new.object() in script

but when we use AFS ,add.set() and before.new.object()will not execute.

bhushanchanda
26th August 2016, 12:26
Hi,

There seems to be a few things missing in your logic - >

1. Handle suproc should be after executing form command
2. There is no stpapi.insert. You don't need choice.user.0
3. There might be a problem with AFS if you put VAT Calculation level as Header. Try lines instead.

Though we have handled tfacp2600m000 through tfgld1101m100, you might try to give the following code a try ->

|==================AFS tfgld1140m000=========================
stpapi.put.field("tfgld1140m000", "tfgld140.user", logged.user)
ret = stpapi.find("tfgld1140m000", error.msg)
if ret = 1 then

stpapi.get.field("tfgld1140m000", "tfgld140.ttyp", l.afs.ttyp)
stpapi.get.field("tfgld1140m000", "tfgld140.btno", l.afs.btno)

ret = stpapi.mark("tfgld1140m000", error.msg)
if ret = 1 then

stpapi.form.command("tfgld1140m000", 5, "exec.cont.process", error.msg)
stpapi.handle.subproc("tfgld1140m000", "tfacp2600m000","add")

|==================AFS tfacp2600m000=========================
stpapi.put.field("tfacp2600m000", "tfacp200.ttyp", l.afs.ttyp)
stpapi.put.field("tfacp2600m000", "tfacp200.ninv", default)

stpapi.put.field("tfacp2600m000", "tfacp200.appr", str$(etol(tfacp.inv.purchase)))
stpapi.put.field("tfacp2600m000", "tfacp200.orno", tdddc002.orno)
stpapi.put.field("tfacp2600m000", "tfacp200.ifbp", tdddc002.ifbp)
stpapi.put.field( "tfacp2600m000", "tfacp200.isup", "XYZ" ) |#If required


l.docd = num.to.date$(tdddc002.usdt, 2)
stpapi.put.field("tfacp2600m000", "tfacp200.docd", l.docd)

stpapi.put.field("tfacp2600m000", "screen.amnt", str$(tdddc002.iamt))
| stpapi.put.field("tfacp2600m000", "tfacp200.lvat", str$(etol(tfacp.vatc.transaction))) |#Commented
stpapi.put.field("tfacp2600m000", "tfacp200.lvat", str$(etol(tfacp.vatc.transaction))) |#New
ret = stpapi.insert("tfacp2600m000",true,error.msg)

if isspace(error.msg) then
message("Done")
stpapi.end.session("tfacp2600m000", error)
else
message("Error")
stpapi.end.session("tfacp2600m000", error)
endif