VishalMistry
30th March 2017, 13:55
Hello Everyone,

NOTE:THIS IS REGARDING BAAN IV

I want to call the Print storage list session through AFS and specify specific order numbers manually. But the session is not printing the storage list report. My code is attached for reference.

I already searched the forum and found one suitable post but still I am not able to get things done.

Please see the attached code and suggest changes.

Thanks and regards,
Vishal

mark_h
30th March 2017, 17:27
Never could get that to work for our system. So the way I defeated this was to just run the reports(not this specific report) one a time using a look. Worked the same in the end. So basically I asked the user to input 10 orders - then just did a for loop to print all 10 or how ever many they listed. The end result was the same as if they ran the session manually and picked enter specific orders.


for i = 1 to 10
if(ornos(i)=0) then
break
endif

| Setup the sessions fields for the tdpur9901m000 session which is a
| clone of tdpur4401m000.

stpapi.put.field( "tdpur9901m000", "tdpur999.send", str$(tdpur.dist.account) )
| 20071004.st Add fields to put onto session
stpapi.put.field( "tdpur9901m000", "selection", str$(tcyesno.no) )
stpapi.put.field( "tdpur9901m000", "suno.f", " " )
stpapi.put.field( "tdpur9901m000", "suno.t", "ZZZZZZ" ) | 20071004.end
stpapi.put.field( "tdpur9901m000", "orno.f",str$(ornos(i)))
stpapi.put.field( "tdpur9901m000", "orno.t",str$(ornos(i)))

VishalMistry
31st March 2017, 14:09
Hi Mark,

Thanks for the update. But it does not serve the purpose. The flow will be like below:

1.User will start session tdpur4421m000
2.In this session, user will set specific order to yes(first field in tdpur4421m000)
3.Now session tdpur4820s000 will start where user can specify specific order numbers. Maximum upto 10 and user will click on Ok then control will return to session tdpur4421m00
4.Now user will select report and report will be fired. Finally the field tdpur045.spur will be updated with next step to be executed (probably 9).

I just want to know how can i call the session tdpur4820s000 and specify order numbers through AFS.

If anyone else faced similar requirement and solved it, please post your code.

Vishal

mark_h
31st March 2017, 14:26
Maybe you do not understand me - all session tdpur4820s000 does is let you enter 10 order numbers. So what I did was write my own session to get 10 orders. Then I run them thru something like tdpur4401m000 one at a time. It does all the same steps, but you just sent them one at a time. That versus letting the session track all 10 orders. It accomplishes the same as if the user just did them one at a time thru the session.

If you are dead set doing it thru tdpur4820s000 then the first thing you need to look at are these two steps.

stpapi.put.field( "tdpur4421m000", "selection", str$(tcyesno.yes))
stpapi.handle.subproc( "tdpur4421m000", "tdpur4820s000", "send")

First you want the subproc before the action that will start the subsession. That way the main program has control. So I would do something like this

stpapi.handle.subproc( "tdpur4421m000", "tdpur4820s000", "add")
stpapi.put.field( "tdpur4421m000", "selection", str$(tcyesno.yes))

Now just doing a put on our system to yes would not activate tdpur4820s000. So I suspect you need some kind of action to get it to check that field. So I would try a stpapi.save or stpapi.update - something to make tdpur4421 to start processing and find that the flag is yes and launch tdpur4820s000. Then after that I would do a continue on tdpur4820s000 and not an end session.

mark_h
31st March 2017, 15:35
Actually see if this works:

stpapi.handle.subproc( "tdpur4421m000", "tdpur4820s000", "add")
stpapi.put.field( "tdpur4421m000", "selection", str$(tcyesno.yes))
stpapi.continue.process("tdpur4421m000",err)

This should get 8420s000 started - it did on my system. I am thinking you want all you setups for tdpur4421m000 done before that continue. Something like this:

i.spooler = spool.open("", "", 1)
stpapi.set.report( "tdpur4421m000", "rtdpur442101100", spool.device, error.msg )
stpapi.handle.subproc( "tdpur4421m000", "tdpur4820s000", "add")
stpapi.put.field( "tdpur4421m000", "selection", str$(tcyesno.yes))
stpapi.continue.process("tdpur4421m000",err)
stpapi.put.field( "tdpur4820s000", "orno.select", str$(load.long(receipts.array(pos.orno,1))), 1)
stpapi.put.field( "tdpur4820s000", "orno.select", str$(load.long(receipts.array(pos.orno,2))), 2)
stpapi.continue.process( "tdpur4820s000" , error.msg)

I am not really sure what will happen after the continue on 4820s000, but I think tdpur4421m000 might start processing. I could be wrong, not really sure.

VishalMistry
3rd April 2017, 16:37
Actually see if this works:

stpapi.handle.subproc( "tdpur4421m000", "tdpur4820s000", "add")
stpapi.put.field( "tdpur4421m000", "selection", str$(tcyesno.yes))
stpapi.continue.process("tdpur4421m000",err)

This should get 8420s000 started - it did on my system. I am thinking you want all you setups for tdpur4421m000 done before that continue. Something like this:

i.spooler = spool.open("", "", 1)
stpapi.set.report( "tdpur4421m000", "rtdpur442101100", spool.device, error.msg )
stpapi.handle.subproc( "tdpur4421m000", "tdpur4820s000", "add")
stpapi.put.field( "tdpur4421m000", "selection", str$(tcyesno.yes))
stpapi.continue.process("tdpur4421m000",err)
stpapi.put.field( "tdpur4820s000", "orno.select", str$(load.long(receipts.array(pos.orno,1))), 1)
stpapi.put.field( "tdpur4820s000", "orno.select", str$(load.long(receipts.array(pos.orno,2))), 2)
stpapi.continue.process( "tdpur4820s000" , error.msg)

I am not really sure what will happen after the continue on 4820s000, but I think tdpur4421m000 might start processing. I could be wrong, not really sure.

I tried your given code snippet but no luck. The session still hangs. The other way I tried is also attached as a script. Still I am facing session hang.

Vishal

VishalMistry
4th April 2017, 15:49
Hello Everybody,

Any clue regarding the above post ? I shall appreciate help in this regard.

Vishal

mark_h
5th April 2017, 03:13
I will look again when I get back to the office next week. I will have to try with another session, never could find anything to print for this one.

cherokee
7th April 2017, 20:34
Hello,

I did this and works for me. The only down side is that I couldn't make it work for "Include Printed Lines", other than that works fine.



function print.storage.list()
{
domain tcmcs.str100 error.msg
domain tcmcs.long l.pid
domain tcmcs.long l.orno(10)

stpapi.put.field( "tdpur4421m000", "selection", str$(tcyesno.yes))
stpapi.handle.subproc( "tdpur4421m000", "tdpur4820s000", "kill")
l.pid = find.a.process("tdpur4421m000")
put.var(l.pid,"orno.1",l.orno(1))
put.var(l.pid,"orno.2",l.orno(2))
put.var(l.pid,"orno.3",l.orno(3))
put.var(l.pid,"orno.4",l.orno(4))
put.var(l.pid,"orno.5",l.orno(5))
put.var(l.pid,"orno.6",l.orno(6))
put.var(l.pid,"orno.7",l.orno(7))
put.var(l.pid,"orno.8",l.orno(8))
put.var(l.pid,"orno.9",l.orno(9))
put.var(l.pid,"orno.10",l.orno(10))
stpapi.set.report("tdpur4421m000", "rtdpur442101101", spool.device, error.msg)
stpapi.print.report("tdpur4421m000", error.msg)
stpapi.end.session("tdpur4421m000")
}

function domain tcmcs.long find.a.process(domain tcmcs.str14 i.baan.sess)
{
long hold.pno
long pno
long info(256)
string pname(15)
domain tcbool sess.found

sess.found = false
pno = 0
hold.pno = pno
pno = pstat (pno, pname, info)
while pno > 0 and not sess.found
hold.pno = pno
pno = pstat (pno, pname, info)
if strip$(pname)=strip$(i.baan.sess) then
sess.found = true
return(info(2))
endif
endwhile
return(0)
}