VishalMistry
10th November 2015, 07:35
Hi all,

I have a session where I ask user to put maximum of five purchase order number and then print them one by one. for then in declaration section I have defined an array of 5 element as below:

extern domain tcorno orno(5)

and through loop, I am trying to print all the purchase order one by one:
for element = 1 to 5
stpapi.put.field("tdpur4401m000","orno.f",spool.fileout)
stpapi.put.field("tdpur4401m000","orno.t",orno(element))
stpapi.put.field("tdpur4401m000","printed",str$(printed))
stpapi.set.report("tdpur4401m000", "rtdtri440106000", "NOTEPAD", error.msg)
export("spool.fileout",spool.fileout)
stpapi.print.report("tdpur4401m000", error.msg)
stpapi.end.session( "tdpur4401m000", error.msg)
endfor

But I am getting an error mesasge as indicated in screen shot. I am unable to identify what is wrong with the code. Can anybody help me sort this out ?

Vishal

VishalMistry
10th November 2015, 07:47
Hi,
The reason was I was assigning it like below:
spool.fileout = orno instead of spool.fileout(element) here element looped from 1 to 5
now after modifying this, the first error is gone but now I am getting another error

"Illegal number of subscripts for array 'orno'".
code is as below:

for element = 1 to 5
spool.fileout = orno(element)
stpapi.put.field("tdpur4401m000","orno.f",spool.fileout)
stpapi.put.field("tdpur4401m000","orno.t",orno(element))
stpapi.put.field("tdpur4401m000","printed",str$(printed))
stpapi.set.report("tdpur4401m000", "rtdtri440106000", "NOTEPAD", error.msg)
export("spool.fileout",spool.fileout)
stpapi.print.report("tdpur4401m000", error.msg)
stpapi.end.session( "tdpur4401m000", error.msg)
endfor

Vishal

VishalMistry
10th November 2015, 08:03
Hi all,

Sorry for annoying all. Now everything works but there is one catch.

Every time file is generated in notepad the file name should be the purchase order number.
CRM110001, CRM110002 CRM110003 etc.

But system generates file text files with same order number CRM110001.
Code is below:

for element = 1 to 5
spool.fileout = orno(1,element)
stpapi.put.field("tdpur4401m000","orno.f",spool.fileout)
stpapi.put.field("tdpur4401m000","orno.t",orno(1,element))
stpapi.put.field("tdpur4401m000","printed",str$(printed))
stpapi.set.report("tdpur4401m000", "rtdtri440106000", "NOTEPAD", error.msg)
export("spool.fileout",spool.fileout)
stpapi.print.report("tdpur4401m000", error.msg)
stpapi.end.session( "tdpur4401m000", error.msg)
endfor

Can anybody help in this regard ?

Vishal