Paul HaynesBR
30th October 2013, 13:14
I have a problem with an api call to a standard Baan session. It works ok when I run it online but fails with the message 'Process is gone' when run from a batch job. It's failing after the call to stpapi.continue.process. I have put in a message to show the output file name that it's tryng to create and it's forming that name and path properly. Has anyone any ideas please? Code is below:
stpapi.put.field("tfcmg1270m000","batch",str$(batch.f))
stpapi.put.field("tfcmg1270m000","payment.date",str$(date.f))
hold.fileout = STRIP$(bse.tmp) & "/" & str$(batch.f) & "tmp1270.s"
message("Spool filename %s", hold.fileout)
stpapi.put.field("tfcmg1270m000","spool.fileout",hold.fileout)
stpapi.put.field("tfcmg1270m000","spool.device","ASCIF")
stpapi.set.report("tfcmg1270m000","rtfcmg127012000","ASCIF", error1 )
if error1 <> "" then
message ("error setting report : %s",error1)
endif
stpapi.continue.process("tfcmg1270m000",error1)
if error1 <> "" then
message ("error creating file : %s",error1)
endif
stpapi.end.session("tfcmg1270m000")
bhushanchanda
30th October 2013, 13:48
Hi,
Try to put suspend(500) or some time after stpapi.continue.process(). May be you are ending the session before its processed.
Paul HaynesBR
31st October 2013, 11:17
Hi, I have tried putting a suspend in various places - before and after the cont process and after the set.report but still getting the same message I'm afraid. Anything else I could try?
mark_h
31st October 2013, 14:48
You can search this http://www.baanboard.com/baanboard/forumdisplay.php?f=59 forum for "running in job". Lots of people have had issues running them in job mode - in some cases SPs were needed. I have asked for the thread to be moved to the correct forum.
My first question or comment would be - I have never done it this way. I just set spool.device to ASCIF. And I set spool.fileout to the file name.
stpapi.put.field("tfcmg1270m000","spool.fileout",hold.fileout)
stpapi.put.field("tfcmg1270m000","spool.device","ASCIF")
Not sure that makes a difference in batch mode.
mark_h
31st October 2013, 16:58
Another question I have - do you run it once or multiple times? I mean do you run this code once per batch job? Or do you kick of a batch job and the AFS code gets run multiple times for different batches?
Paul HaynesBR
31st October 2013, 17:21
Hi Mark,
Thanks for the advice, I will trawl through these posts and see what I can find. Changing the way I set the spool file didn't work though.
Paul
Paul HaynesBR
31st October 2013, 17:23
It gets run multiple times in theory as it's selecting records from a table and calling the session for each table entry. At the moment though I have been testing it with only one record and it's failing on that one.
mark_h
31st October 2013, 18:05
I did not think it would, but worth a shot. The only other thing I can think of is there anything in any log files? I have actually had sessions come back with process is gone, yet they still worked. I don't think that is the case here - I assume you temp file is still empty. Are you launching the batch job or is it through like cron or something?
The problem I have run into on our 4c4 system is that the spool.fileout - while you change the file name, the session you are running keeps using the first spool.fileout you set. Again this is running my AFS session manually - not using batch. Below is some code I just wrote recently. I actually ended up exporting the spool.fileout and importing into tdpur4401 to get around the issue.
function print.po()
{
string cmd(1000) | Unix Command
string temp.file(256) | Temp file name
string email.addr(100)
long rc
msg = ""
if tdexi305.subm = tdexi.method.email then
spool.device = "ASCIF"
spool.fileout = creat.tmp.file$( bse.tmp.dir$() )
spool.fileout = strip$(spool.fileout)
rpt_id = spool.open("",spool.device,0)
export("spool.fileout",spool.fileout)
else
spool.device = "D66"
spool.fileout = ""
rpt_id = spool.open("",spool.device,1)
export("spool.fileout",spool.fileout)
endif
spool.close()
stpapi.put.field( "tdpur4401m000", "tdpur999.send", str$(tdpur.dist.vendor) )
stpapi.put.field( "tdpur4401m000", "selection", str$(tcyesno.no) )
stpapi.put.field( "tdpur4401m000", "suno.f", " " )
stpapi.put.field( "tdpur4401m000", "suno.t", "ZZZZZZ" )
stpapi.put.field( "tdpur4401m000", "orno.f",str$(tdexi305.orno))
stpapi.put.field( "tdpur4401m000", "orno.t",str$(tdexi305.orno))
stpapi.put.field( "tdpur4401m000", "comp.f", str$(0) )
stpapi.put.field( "tdpur4401m000", "comp.t", str$(999) )
stpapi.put.field( "tdpur4401m000", "tdpur999.dpas", str$(tcyesno.yes) )
stpapi.put.field( "tdpur4401m000", "prnt.pric", str$(tcyesno.yes) )
stpapi.put.field( "tdpur4401m000", "printed", str$(tdsls.kofl.all) )
stpapi.put.field( "tdpur4401m000", "quan.to.print", str$(tdsls.koqu.ordered.quan) )
stpapi.put.field( "tdpur4401m000", "prnt.options", str$(tcyesno.yes) )
stpapi.put.field( "tdpur4401m000", "prnt.deladro", str$(tcyesno.no) )
stpapi.put.field( "tdpur4401m000", "chgflag", str$(tcyesno.no) )
stpapi.put.field( "tdpur4401m000", "chgordnum", str$(0) )
stpapi.put.field( "tdpur4401m000", "chgorddte", str$(0) )
stpapi.set.report("tdpur4401m000","rtdpur440101000", spool.device, msg)
stpapi.continue.process( "tdpur4401m000", msg)
if(strip$(msg)<>"") then
message("Err. %s PO:%d", msg, tdexi305.orno)
endif
stpapi.end.session( "tdpur4401m000" )
PS - yes I know I only need one export statement before the spool.close - just been too lazy to retest everything.