blanchap
14th March 2016, 15:03
Hi,
are AFS working on subsession in Baan?
I'm trying to do an AFS and sesson hangs on the first stpapi.put.field
here is my code
stpapi.clear("tfcmg2100s000")
stpapi.put.field("tfcmg2100s000","tfcmg204.ttyp", tfgld011.ttyp)
stpapi.put.field("tfcmg2100s000","tfcmg204.docn", str$(seq.number))
stpapi.put.field("tfcmg2100s000","tfcmg204.lino", str$(passe))
stpapi.put.field("tfcmg2100s000","tfcmg204.docd", str.date)
stpapi.put.field("tfcmg2100s000","tfcmg204.tran", "supplier.tran")
stpapi.put.field("tfcmg2100s000","tfcmg204.tinv", tfcmg999.ttyp)
stpapi.put.field("tfcmg2100s000","tfcmg204.ninv", str$(tfcmg999.docn))
stpapi.put.field("tfcmg2100s000","tfcmg204.suno", str$(tfcmg999.suno))
stpapi.put.field("tfcmg2100s000","tfcmg204.amnt", str$(tfcmg999.amnt))
stpapi.put.field("tfcmg2100s000","tfcmg204.ccur", tfcmg999.ccur)
ret = stpapi.insert("tfcmg2100s000", true, error.msg)
stpapi.end.session("tfcmg2100s000")
it does the stpapi.clear but hangs after that. :confused:
Am i missing something?
Do i need to do something more because it's a subsession?
Regards.
PB
blanchap
14th March 2016, 21:21
ok, changed my logic to this:
function insert.record()
{
stpapi.put.field("tfgld1100m000", "tfgld100.year", str$(year.f))
stpapi.put.field("tfgld1100m000", "tfgld100.btno", str$(btno.f))
rc = stpapi.find("tfgld1100m000", errmsg)
if rc <> 1 then
errmsg1 = "Batch not found"
stpapi.end.session("tfgld1100m000")
end()
endif
stpapi.handle.subproc("tfgld1100m000", "tfgld1101s000", "add")
stpapi.continue.process("tfgld1100m000", errmsg)
if not isspace(errmsg) then
errmsg1 = errmsg
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
end()
endif
stpapi.put.field("tfgld1101s000", "tfgld101.year", str$(year.f))
stpapi.put.field("tfgld1101s000", "tfgld101.btno", str$(btno.f))
stpapi.put.field("tfgld1101s000", "tfgld101.ttyp", ttyp.x)
rc = stpapi.find("tfgld1101s000", errmsg)
if rc <> 1 then
errmsg1 = ttyp.x&" not found"
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
end()
endif
stpapi.handle.subproc("tfgld1101s000","tfcmg2100s000","add")
stpapi.continue.process("tfglf1101s000", errmsg)
if not isspace(errmsg) then
errmsg1 = errmsg
stpapi.end.session("tfcmg2100s000")
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
end()
endif
stpapi.put.field("tfcmg2100s000","tfcmg204.ttyp", tfgld011.ttyp)
stpapi.put.field("tfcmg2100s000","tfcmg204.docn", str$(seq.number))
stpapi.put.field("tfcmg2100s000","tfcmg204.lino", str$(passe))
stpapi.put.field("tfcmg2100s000","tfcmg204.docd", str$(date.num()))
stpapi.put.field("tfcmg2100s000","tfcmg204.tran", str$(tfcmg.tran.supplier))
stpapi.put.field("tfcmg2100s000","tfcmg204.tinv", tfcmg999.ttyp)
stpapi.put.field("tfcmg2100s000","tfcmg204.ninv", str$(tfcmg999.docn))
stpapi.put.field("tfcmg2100s000","tfcmg204.suno", str$(tfcmg999.suno))
stpapi.put.field("tfcmg2100s000","tfcmg204.amnt", str$(tfcmg999.amnt))
stpapi.put.field("tfcmg2100s000","tfcmg204.ccur", tfcmg999.ccur)
stpapi.end.session("tfcmg2100s000")
}
everything is working up to the
stpapihandle.subproc("tfgld1101s000", "tfcmg2100s000","add")
after that i'm getting the message session not availalble.
??? if i do the steps manually, it's working.
does anybody have an idea of my problem?
Regards.
PB
Ajesh
15th March 2016, 06:55
If its a subsession then you need to put the values in a Multi Occ Main Session and then synchronize the Sub Session and then put the insert command.
stpapi.put.field("tfgld1100m000", "tfgld100.year", str$(year.f))
stpapi.put.field("tfgld1100m000", "tfgld100.btno", str$(btno.f))
rc = stpapi.find("tfgld1100m000", errmsg)
if rc = 1 then
ret = stpapi.synchronize.dialog("tfgld1100m000","add",error,msg)
if ret then
stpapi.put.field("tfcmg2100s000","tfcmg204.ttyp", tfgld011.ttyp)
stpapi.put.field("tfcmg2100s000","tfcmg204.docn", str$(seq.number))
stpapi.put.field("tfcmg2100s000","tfcmg204.lino", str$(passe))
stpapi.put.field("tfcmg2100s000","tfcmg204.docd", str.date)
stpapi.put.field("tfcmg2100s000","tfcmg204.tran", "supplier.tran")
stpapi.put.field("tfcmg2100s000","tfcmg204.tinv", tfcmg999.ttyp)
stpapi.put.field("tfcmg2100s000","tfcmg204.ninv", str$(tfcmg999.docn))
stpapi.put.field("tfcmg2100s000","tfcmg204.suno", str$(tfcmg999.suno))
stpapi.put.field("tfcmg2100s000","tfcmg204.amnt", str$(tfcmg999.amnt))
stpapi.put.field("tfcmg2100s000","tfcmg204.ccur", tfcmg999.ccur)
retval = stpapi.insert("tfcmg2100s000",1,error.message)
if not retval then
stpapi.recover("tfcmg2100s000",recover.msg)
endif
stpapi.end.session("tfcmg2100s000")
endif
stpapi.end.session("tfgld1100m000")
blanchap
15th March 2016, 14:31
Thanks but i forgot to say that i'm doing this in Baan4c4.
stpapi.synchronize.dialog does not work in that version.
PB
blanchap
15th March 2016, 15:26
ok, got it working (kind of).
The program does not hang anymore but..........
Does not update also.
here what i did.
function insert.record()
{
stpapi.put.field("tfgld1100m000", "tfgld100.year", str$(year.f))
stpapi.put.field("tfgld1100m000", "tfgld100.btno", str$(btno.f))
rc = stpapi.find("tfgld1100m000", errmsg)
if rc <> 1 then
errmsg1 = "Batch not found"
stpapi.end.session("tfgld1100m000")
end()
endif
stpapi.handle.subproc("tfgld1100m000", "tfgld1101s000", "add")
stpapi.continue.process("tfgld1100m000", errmsg)
if not isspace(errmsg) then
errmsg1 = errmsg
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
end()
endif
stpapi.put.field("tfgld1101s000", "tfgld101.year", str$(year.f))
stpapi.put.field("tfgld1101s000", "tfgld101.btno", str$(btno.f))
stpapi.put.field("tfgld1101s000", "tfgld101.ttyp", ttyp.x)
rc = stpapi.find("tfgld1101s000", errmsg)
if rc <> 1 then
errmsg1 = ttyp.x&" not found"
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
end()
endif
stpapi.handle.subproc("tfgld1101s000", "tfcmg2100s000", "add")
stpapi.continue.process("tfgld1101s000", errmsg)
if not isspace(errmsg) then
errmsg1 = errmsg
stpapi.end.session("tfcmg2100s000")
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
end()
endif
stpapi.put.field("tfcmg2100s000","tfcmg204.ttyp", tfgld011.ttyp)
stpapi.put.field("tfcmg2100s000","tfcmg204.docn", str$(seq.number))
stpapi.put.field("tfcmg2100s000","tfcmg204.lino", str$(passe))
stpapi.put.field("tfcmg2100s000","tfcmg204.docd", str$(date.num()))
stpapi.put.field("tfcmg2100s000","tfcmg204.tran", str$(tfcmg.tran.supplier))
stpapi.put.field("tfcmg2100s000","tfcmg204.tinv", tfcmg999.ttyp)
stpapi.put.field("tfcmg2100s000","tfcmg204.ninv", str$(tfcmg999.docn))
stpapi.put.field("tfcmg2100s000","tfcmg204.suno", str$(tfcmg999.suno))
stpapi.put.field("tfcmg2100s000","tfcmg204.amnt", str$(tfcmg999.amnt))
stpapi.put.field("tfcmg2100s000","tfcmg204.ccur", tfcmg999.ccur)
stpapi.insert("tfcmg2100s000", true, errmsg)
stpapi.end.session("tfcmg2100s000")
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
}
simple enough but does not update the table even after the stpapi.insert in the session tfcmg2100s000
???
a second pair of eyes on my script would be appreciated.
PB
blanchap
15th March 2016, 15:34
Never mind.
Got it working.
Thanks
PB
mark_h
20th March 2016, 01:54
Can you post your updated script. Not sure I have done one which involved a tfcmg2100s000. I might need an assist some day.
blanchap
21st March 2016, 13:57
Hi,
here is my function.
function insert.record()
{
stpapi.put.field("tfgld1100m000", "tfgld100.year", str$(year.f))
stpapi.put.field("tfgld1100m000", "tfgld100.btno", str$(btno.f))
rc = stpapi.find("tfgld1100m000", errmsg)
if rc <> 1 then
errmsg1 = "Batch not found"
stpapi.end.session("tfgld1100m000")
display("errmsg1")
end()
endif
stpapi.handle.subproc("tfgld1100m000", "tfgld1101s000", "add")
stpapi.continue.process("tfgld1100m000", errmsg)
if not isspace(errmsg) then
errmsg1 = errmsg
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
display("errmsg1")
end()
endif
stpapi.put.field("tfgld1101s000", "tfgld101.year", str$(year.f))
stpapi.put.field("tfgld1101s000", "tfgld101.btno", str$(btno.f))
stpapi.put.field("tfgld1101s000", "tfgld101.ttyp", ttyp.x)
rc = stpapi.find("tfgld1101s000", errmsg)
if rc <> 1 then
errmsg1 = ttyp.x&" not found"
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
display("errmsg1")
end()
endif
stpapi.handle.subproc("tfgld1101s000", "tfcmg2100s000", "add")
stpapi.continue.process("tfgld1101s000", errmsg)
if not isspace(errmsg) then
errmsg1 = errmsg
stpapi.end.session("tfcmg2100s000")
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
display("errmsg1")
end()
endif
stpapi.put.field("tfcmg2100s000","tfcmg204.ttyp", tfgld011.ttyp)
if passe = 1 then
stpapi.put.field("tfcmg2100s000","tfcmg204.docn", str$(tfgld011.dsrn))
else
stpapi.put.field("tfcmg2100s000","tfcmg204.docn", str$(seq.number))
endif
stpapi.put.field("tfcmg2100s000","tfcmg204.lino", str$(passe))
stpapi.put.field("tfcmg2100s000","tfcmg204.docd", str$(date.num()))
stpapi.put.field("tfcmg2100s000","tfcmg204.tran", str$(tfcmg.tran.supplier))
stpapi.put.field("tfcmg2100s000","tfcmg204.tinv", tfcmg999.ttyp)
stpapi.put.field("tfcmg2100s000","tfcmg204.ninv", str$(tfcmg999.docn))
stpapi.put.field("tfcmg2100s000","tfcmg204.suno", str$(tfcmg999.suno))
stpapi.put.field("tfcmg2100s000","tfcmg204.amnt", str$(tfcmg999.amnt))
stpapi.put.field("tfcmg2100s000","tfcmg204.ccur", tfcmg999.ccur)
stpapi.insert("tfcmg2100s000", true, errmsg)
errmsg1 = errmsg
display("errmsg1")
stpapi.end.session("tfcmg2100s000")
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
}
the only issue is that i was not able to program the update of table tfcmg205
with the function. i had to update the table tfcmg205 outside the function.
PB