kishoremeher
26th December 2011, 11:43
Dear Baanboard,

I have made a AFS programme for session whwmd2570m000 and
whwmd2170s000.

First I am calling session whwmd2570m000, applying synchronize dialog and session whwmd2170s000 get opened.
I am passing quantity and reason code and from specific selecting "Destroy Good".
It is giving error message:- "The quantity to process must be greater than zero." even if i ma passing value to that.

Any suggestion please.

Also find the script.

select whwmd270.*
from whwmd270
where whwmd270._index1 = {"UIG-01", "REJ-01 ", " VZ30ALR762", "V01S11000820A28"}
selectdo
reason.code = "1001"
stpapi.put.field( "whwmd2570m000", "whwmd270.cwar", whwmd270.cwar )
stpapi.put.field( "whwmd2570m000", "whwmd270.loca", whwmd270.loca )
stpapi.put.field( "whwmd2570m000", "whwmd270.item.segment.1", whwmd270.item(1; 9) )
stpapi.put.field( "whwmd2570m000", "whwmd270.item.segment.2", whwmd270.item(10; 38) )
stpapi.put.field( "whwmd2570m000", "whwmd270.clot", whwmd270.clot )
stpapi.put.field( "whwmd2570m000", "whwmd270.idat", str$(whwmd270.idat) )
stpapi.put.field( "whwmd2570m000", "whwmd270.rcno", whwmd270.rcno )
stpapi.put.field( "whwmd2570m000", "whwmd270.rcln", str$(whwmd270.rcln) )
stpapi.put.field( "whwmd2570m000", "whwmd270.serl", whwmd270.serl )
stpapi.put.field( "whwmd2570m000", "whwmd270.huid", whwmd270.huid )

ret = stpapi.find( "whwmd2570m000" , error )
ret = stpapi.mark( "whwmd2570m000" , error )
to.process = whwmdf2570m000.get.To_be_Handled()
stpapi.synchronize.dialog("whwmd2570m000", "modify" , err.mesg)
to.process = whwmdf2170s000.get.To_be_Processed( )
whwmdf2170s000.put.Quantity( to.process )
unit = whwmdf2170s000.get.inp.unit( )
whwmdf2170s000.put.Reason( reason.code )
whwmdf2170s000.put.Quantity( to.process )
to.process = whwmdf2170s000.get.Quantity( )
stpapi.put.field( "whwmd2170s000", "whwmd270.resp", str$(3) )
stpapi.put.field( "whwmd2170s000", "inp.qty", str$(to.process) )
to.process1 = whwmdf2170s000.get.Quantity( )
stpapi.get.field( "whwmd2170s000", "reason.code", reason.code1 )

stpapi.form.command( "whwmd2170s000", 5, "exec.user.0", error )

stpapi.enum.answer("whwmd2170s000", "whinh0056",whinh.emsg.ok)
stpapi.end.session( "whwmd2170s000" )
stpapi.end.session( "whwmd2570m000" )
endselect

Thanks & Regards,
Kishore

mark_h
27th December 2011, 18:55
This is the correct forum for these type threads.

Do not know the session - but I see where you answer a question after a form command. Questions should always be answered before the command that starts the processing. So I would expect to see this:

stpapi.enum.answer("whwmd2170s000", "whinh0056",whinh.emsg.ok)
stpapi.form.command( "whwmd2170s000", 5, "exec.user.0", error )

Next I noticed that the form command is on the subsession. When you sync the dialog the form.command(or update) gets executed against the mainsession. I put an example from the sticky thread here (http://www.baanboard.com/baanboard/showthread.php?t=61677). I do not know if the session needs the sync dialog or not, but if you look at the documentation it usually has an update or insert running against the main session.

mboberda1
28th November 2021, 18:59
Hi Kishore,

I am trying to do the same thing as you to confirm automatially rejected inventory.

I tryied to use your script but I don't where to you get the functions for whwmdf2570m000 & whwmdf2170s000

Can you please help me on this ?

Thank you for your help & support on this.

Michel

mark_h
29th November 2021, 14:32
Are you talking about the stpapi commands? I always included this in my api type sessions:

#pragma used dll ottstpapihand