cherokee
19th August 2019, 04:07
Hello all,

I have a stack of orders to be printed, I use an AFS, it prints the first order, when loops for the next order does not work, no error message on the error.message var.

Note: I have changed the sort order in the stack, to print bottom to top and it prints the first instance but not the next one(it only works the first time no matter what order I want to print), is not data related.

for i = 1 to reqs.index
spool.device = <MY_ASCI_DEVICE>
l.orno = pur.req.stack(1,i;9)
spool.fileout = "c:\temp\"&logname$&"_req_"&strip$(shiftl$(l.orno))&".txt"
stpapi.put.field("timrpc421m000","orno.f",str$(l.orno))
stpapi.put.field("timrpc421m000","orno.t",str$(l.orno))
stpapi.put.field("timrpc421m000","psdt.f",str$(l.utc.f))
stpapi.put.field("timrpc421m000","psdt.t",str$(l.utc.t))
stpapi.put.field("timrpc421m000","pfdt.f",str$(l.utc.f))
stpapi.put.field("timrpc421m000","pfdt.t",str$(l.utc.t))
stpapi.set.report("timrpc421m000","rtimrpc42111001",spool.device,error.message)
stpapi.print.report("timrpc421m000",error.message)
stpapi.end.session("timrpc421m000")
endfor

Any inputs are welcome.

Thanks in advance

andreas.toepper
19th August 2019, 13:39
I'm using LN 10.2.1. When I did call a print session serveral times (i.e. in a loop) I had to "export" spool.device to the session controlled by AFS.

So I would try somethink like this:

stpapi.put.field("timrpc421m000", spool.fileout, "c:\temp\"&logname$&"_req_"&strip$(shiftl$(l.orno))&".txt")

This will set spool.fileout of the session timrpc421m000. You've set spool.fileout for your AFS session.

mark_h
19th August 2019, 15:11
Hmmm... - never tried it that way. I always exported(AFS session) and imported spool.fileout(baan session).

cherokee
19th August 2019, 15:12
Thank you Andreas for your help, it did work, really appreciated. Just to add to your solution, spool.device has to between quotes. (compiles without quotes but does not work) So, as any other stpapi.put.field, it has to be "spool.device".

stpapi.put.field("timrpc421m000", "spool.fileout", "c:\temp\"&logname$&"_req_"&strip$(shiftl$(l.orno))&".txt")