tomlbacon
4th January 2012, 00:04
I'm trying to do Stpapi command for session whinh3522m000 and whinh3122s000 to update the Approvals in table whinh211 in Baan V. I have a form and require the Order, set and position number to find the records that I want to process. Program goes thru the stpapi command and all err.msg's are ok but doesn't update the Records with new values. Would like any help can get.

Thanks, Code of stpapi is below

do.update = 1
do.save = 1

stpapi.put.field( "whinh3522m000", "whinh211.orno", orno.f )
stpapi.put.field( "whinh3522m000", "whinh211.oset", str$(whinh211.oset) )
stpapi.put.field( "whinh3522m000", "whinh211.pono", str$(whinh211.pono) )
stpapi.put.field( "whinh3522m000", "whinh211.seqn", str$(whinh211.seqn) )
stpapi.put.field( "whinh3522m000", "whinh211.sern", str$(whinh211.sern) )
stpapi.put.field( "whinh3522m000", "whinh211.apnr", str$(whinh211.apun) )
stpapi.put.field( "whinh3522m000", "whinh211.cwar", str$(whinh211.cwar) )
stpapi.put.field( "whinh3522m000", "whinh211.loca", str$(whinh211.loca) )
stpapi.put.field( "whinh3522m000", "whinh211.stra", str$(whinh211.stkt) ) |* Approved Inventory
stpapi.put.field( "whinh3522m000", "whinh211.strr", str$(whinh211.strr) ) |* Rejected Inventory
stpapi.put.field( "whinh3122s000", "whinh211.oorg", str$(whinh211.oorg)) |* Order Origin
stpapi.put.field( "whinh3122s000", "whinh211.orno", orno.f ) |* Order Number
stpapi.put.field( "whinh3122s000", "whinh211.oset", str$(whinh211.oset) ) |* Order Set
stpapi.put.field( "whinh3122s000", "whinh211.pono", str$(whinh211.pono) ) |* Position Number
stpapi.put.field( "whinh3122s000", "whinh211.seqn", str$(whinh211.seqn) ) |* Seqence Number
stpapi.put.field( "whinh3122s000", "whinh211.sern", str$(whinh211.sern) ) |* Advice Number
stpapi.put.field( "whinh3122s000", "whinh211.apun", whinh211.apun ) |* Approval UOM
stpapi.put.field( "whinh3122s000", "whinh211.stra", str$(whinh211.stkt) ) |* Approved Inventory
stpapi.put.field( "whinh3122s000", "whinh211.rjun", whinh211.rjun ) |* Rejected UOM
stpapi.put.field( "whinh3122s000", "whinh211.strr", str$(whinh211.strr) ) |* Rejected Inventory
stpapi.put.field( "whinh3122s000", "whinh211.resn", "" ) |* Reason Code
stpapi.mark( "whinh3522m000" )
stpapi.synchronize.dialog("whinh3522m000", "modify" , err.msg)
stpapi.update( "whinh3122s000", do.update, err.msg )
stpapi.save( "whinh3122s000", err.msg )
stpapi.handle.subproc( "whinh3522m000", "whinh3122s000", "modify" )
stpapi.update( "whinh3522m000", do.save, err.msg )
stpapi.save( "whinh3522m000", err.msg )
stpapi.end.session( "whinh3522m000" )
stpapi.end.session( "whinh3122s000" )

mark_h
4th January 2012, 01:47
See the sticky thread at the top of this forum. This code does not look like what I would expect using the synchronize.dialog statement.


stpapi.put.field("dtfsa1501m000", "dtfsa101.seno", str$(i.seno))
ret = stpapi.find("dtfsa1501m000", error.msg)
if ret then
ret = stpapi.synchronize.dialog("dtfsa1501m000", "modify", error.msg)
if ret then
stpapi.put.field("dtfsa1101s000", "dtfsa101.name", new.name)
ret = stpapi.update("dtfsa1501m000", true, error.msg)
endif
endif


Using the above sample I would expect to see a few puts on the main session, then a find on the main session, then the sync dialog statement, then a put to the subsession, then a update or insert on the main session. That is the flow I would expect to see based of the documentation. Since I do not really use LN or this session I can not really assist too much, but just speculate on what I see.

tomlbacon
4th January 2012, 22:27
Mark,
Thanks for your help. Changed the code to this:

do.update = 1
do.save = 1

stpapi.put.field( "whinh3522m000", "whinh211.orno", orno.f )
stpapi.put.field( "whinh3522m000", "whinh211.oset", str$(whinh211.oset) )
stpapi.put.field( "whinh3522m000", "whinh211.pono", str$(whinh211.pono) )
stpapi.put.field( "whinh3522m000", "whinh211.seqn", str$(whinh211.seqn) )
stpapi.put.field( "whinh3522m000", "whinh211.sern", str$(whinh211.sern) )
stpapi.put.field( "whinh3522m000", "whinh211.apnr", str$(whinh211.apun) )
stpapi.put.field( "whinh3522m000", "whinh211.cwar", str$(whinh211.cwar) )
stpapi.put.field( "whinh3522m000", "whinh211.loca", str$(whinh211.loca) )
ret = stpapi.find( "whinh3522m000", err.msg)
if ret then
ret = stpapi.synchronize.dialog("whinh3522m000", "modify" , err.msg)
if ret then
stpapi.put.field( "whinh3122s000", "whinh211.orno", orno.f ) |* Order Number
stpapi.put.field( "whinh3122s000", "whinh211.oset", str$(whinh211.oset) ) |* Order Set
stpapi.put.field( "whinh3122s000", "whinh211.pono", str$(whinh211.pono) ) |* Position Number
stpapi.put.field( "whinh3122s000", "whinh211.seqn", str$(whinh211.seqn) ) |* Seqence Number
stpapi.put.field( "whinh3122s000", "whinh211.sern", str$(whinh211.sern) ) |* Advice Number
stpapi.put.field( "whinh3122s000", "whinh211.stra", str$(approved.qty) ) |* Approved Inventory
stpapi.put.field( "whinh3122s000", "whinh211.stkt", str$(0)) |* To be Inspected Qty
ret = stpapi.update( "whinh3522m000", do.save, err.msg )
endif
endif

stpapi.end.session( "whinh3122s000" )
stpapi.end.session( "whinh3522m000" )

mark_h
5th January 2012, 15:56
Does that mean it worked? At least I hope so.