umadevi
8th September 2009, 16:23
Hi All,

I am automating the Match and Approval of Purchase Invoices.

My Problem is while i am insering the reocrd in tfacp111s000 ,tfacp1230s000 is running in the background.

Where in tfacp1230s000 session I have to set the Match and Approve fileds to "Yes". I am not understanding how its happening(this session tfacp1230s000 running in background).Hope i get the solution here.

My code is

transaction.type = "PRM"
stpapi.application.option("tfgld1101m000",1, 1, error.msg1)
stpapi.put.field("tfgld1101m000", "tedt.f", str$(tedt))
stpapi.put.field("tfgld1101m000", "tfgld101.year", str$(year))
ret.code = stpapi.change.view("tfgld1101m000", error.msg1)
stpapi.application.option("tfgld1101m000",1, 14, error.msg1)
stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", ransaction.type)
insert.retval = stpapi.insert("tfgld1101m000", true, message.i)
if not insert.retval then
fail.retval = stpapi.recover("tfgld1101m000", dummy.msg)
else
last.found = stpapi.browse.set("tfgld1101m000", "last.set",error1)
if last.found then
stpapi.get.field("tfgld1101m000","tfgld101.year",year1)
stpapi.get.field("tfgld1101m000","tfgld101.btno",btno)
stpapi.get.field("tfgld1101m000","tfgld101.ttyp",tfgld101.ttyp)
stpapi.put.field("tfgld1101m000","tfgld101.year",str$(year))
stpapi.put.field("tfgld1101m000","tfgld101.btno",str$(btno))
stpapi.put.field("tfgld1101m000","tfgld101.ttyp","tfgld101.ttyp")
retval = stpapi.find("tfgld1101m000", error.msg)
retval = stpapi.mark("tfgld1101m000", error.msg)
if retval = 1 then
stpapi.handle.subproc( "tfgld1101m000", "tfacp1110s000", "add")
stpapi.zoom.option("tfgld1101m000", 1, "tfacp1110s000", error.msg)
stpapi.continue.process("tfacp1110s000", process.error.msg)
browse.val = stpapi.browse.view("tfacp1110s000", "last.view", error.msg)
ret.code = stpapi.change.view("tfacp1110s000", error.msg1)
stpapi.put.field("tfacp1110s000", "tfacp200.suno",str$(tdpur040.suno))
stpapi.put.field("tfacp1110s000","screen.amnt",str$(tdpwn002.iamt))
stpapi.put.field("tfacp1110s000","tfacp200.isup",str$(tdpwn002.invn))
|stpapi.put.field("tfacp1110s000",tfacp200.orno,str$(tdpwn002.orno))
retval1 = stpapi.insert("tfacp1110s000", true, error.msg2) | At this Point of |time i am able to see tfacp1230s000 in the background
if retval1 = 1 then
last.found1 = stpapi.browse.set("tfacp1110s000", "last.set",error2)
if last.found1 then
stpapi.get.field("tfacp1110s000","tfacp200.ttyp",tfacp200.ttyp)
stpapi.get.field("tfacp1110s000","tfacp200.ninv",doc1)
stpapi.get.field("tfacp1110s000","tfacp200.line",line1)
stpapi.get.field("tfacp1110s000","tfacp200.tdoc",tfacp200.tdoc)
stpapi.get.field("tfacp1110s000","tfacp200.docn",doc2)
stpapi.get.field("tfacp1110s000","tfacp200.lino",line2)
stpapi.put.field("tfacp1110s000","tfacp200.ttyp","tfacp200.ttyp")
stpapi.put.field("tfacp1110s000","tfacp200.ninv","tfacp200.ninv")
stpapi.put.field("tfacp1110s000","tfacp200.line","tfacp200.line")
stpapi.put.field("tfacp1110s000","tfacp200.tdoc","tfacp200.tdoc")
stpapi.put.field("tfacp1110s000","tfacp200.docn","tfacp200.docn")
stpapi.put.field("tfacp1110s000","tfacp200.lino","tfacp200.lino")
retval = stpapi.find("tfacp1110s000", error.msg3)
retval = stpapi.mark("tfacp1110s000", error.msg4)
if retval = 1 then
stpapi.handle.subproc( "tfacp1110s000", "tfacp1230s000", "add")
stpapi.continue.process("tfacp1230s000", process.error.msg)
endif
endif
endif
endif

Regards,
Uma

mark_h
8th September 2009, 18:57
Well here is how we do some of the control between the various sessions - and of course this works on our Baan 4 system, I have no clue on higher versions of baan.

rc = stpapi.browse.set(sess.gld1101, "last.set", e.msg)
stpapi.handle.subproc(sess.gld1101, sess.acp1110, "add")
stpapi.continue.process(sess.gld1101, e.msg)
stpapi.save(sess.acp1110,e.msg)

Not that we find the batch first, then use continue to launch tfacp1110s000.

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

Now in our case we put a bunch of fields in tfacp1110s000 - then the insert activates tfacp1230s000. It looks like lots of extra code running around and stpapi.mark is not always necessary. I reduced your code to something like this:

transaction.type = "PRM"
stpapi.put.field("tfgld1101m000", "tedt.f", str$(tedt))
stpapi.put.field("tfgld1101m000", "tfgld101.year", str$(year))
ret.code = stpapi.change.view("tfgld1101m000", error.msg1)

stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", ransaction.type)
insert.retval = stpapi.insert("tfgld1101m000", true, message.i)
if not insert.retval then
fail.retval = stpapi.recover("tfgld1101m000", dummy.msg)
return | Failed stop the process
else | Insert worked for the transaction type
stpapi.handle.subproc( "tfgld1101m000", "tfacp1110s000", "add")
stpapi.continue.process("tfgld1101m000", error.msg)
| Now tfacp1110s000 is started just put the fields
stpapi.put.field("tfacp1110s000", "tfacp200.suno",str$(tdpur040.suno))
stpapi.put.field("tfacp1110s000","screen.amnt",str$(tdpwn002.iamt))
stpapi.put.field("tfacp1110s000","tfacp200.isup",str$(tdpwn002.invn))
stpapi.put.field("tfacp1110s000","tfacp200.ttyp","tfacp200.ttyp")
stpapi.put.field("tfacp1110s000","tfacp200.ninv","tfacp200.ninv")
stpapi.put.field("tfacp1110s000","tfacp200.line","tfacp200.line")
stpapi.put.field("tfacp1110s000","tfacp200.tdoc","tfacp200.tdoc")
stpapi.put.field("tfacp1110s000","tfacp200.docn","tfacp200.docn")
stpapi.put.field("tfacp1110s000","tfacp200.lino","tfacp200.lino")
| The stpapi.handle should always be before the next session is launched
stpapi.handle.subproc( "tfacp1110s000", "tfacp1230s000", "add")
retval1 = stpapi.insert("tfacp1110s000", true, error.msg2)
.
.
. Put any fields required or any handle.suproc commands
stpapi.continue.process("tfacp1230s000", process.error.msg)
.
.
. Anything else........or other sessions
endif