hujiehujie
8th February 2007, 09:17
hi :
a question to ask all expert, I write a program with afs, in order to production order completed. but is not successful,new record inserted and
old record updated can not be successful.

the program script is following:

pdno.str=760006
stpapi.put.field("tisfc0202m000","tisfc001.pdno",pdno.str)
count=stpapi.find("tisfc0202m000")
if count=1 then
|stpapi.put.field("tisfc0202m000","tisfc001.cwar","M01")
stpapi.put.field("tisfc0202m000","qdlv.frm","1")
stpapi.enum.answer("tisfc0202m000","tisfc02029",tcyesno.yes)
stpapi.put.field("tisfc0202m000","tisfc001.cwar","M01")
stpapi.handle.subproc("tisfc0202m000","tdilc4113s000","add")
stpapi.continue.process("tisfc0202m000",error.msg)
endif
if isspace(error.msg) then
stpapi.put.field("tdilc4113s000","tdicl402.koor","2")
stpapi.put.field("tdilc4113s000","tdilc402.orno",pdno.str)
stpapi.put.field("tdilc4113s000","tdicl402.pono","0")
stpapi.put.field("tdilc4113s000","tdicl402.sera","0")
count=stpapi.find("tdilc4113s000")
if count<> 1 then
stpapi.put.field("tdilc4113s000","tdicl402.koor","2")
stpapi.put.field("tdilc4113s000","tdilc402.orno",pdno.str)
stpapi.put.field("tdilc4113s000","tdicl402.pono","0")
stpapi.put.field("tdilc4113s000","tdicl402.sera","0")
stpapi.put.field("tdilc4113s000","tdicl402.serb","1")
stpapi.put.field("tdilc4113s000","tdicl402.item",tisfc001.mitm)
stpapi.put.field("tdilc4113s000","tdicl402.clot",tisfc200.clot)
stpapi.put.field("tdilc4113s000","tdicl402.cwar","M01")
stpapi.put.field("tdilc4113s000","tdicl402.stun","PCS")
stpapi.put.field("tdilc4113s000","tdicl402.qstr","1")
stpapi.put.field("tdilc4113s000","tdicl402.qstc","1")
insert.flag=stpapi.insert( "tdilc4113s000", true, error.msg)
else
stpapi.put.field("tdilc4113s000","tdicl402.stun","PCS")
stpapi.put.field("tdilc4113s000","tdicl402.qstr","2")
stpapi.put.field("tdilc4113s000","tdicl402.qstc","2")
stpapi.get.field( "tdilc4113s000", "tdilc402.qstc", temp.qstc )
update.flag=stpapi.update( "tdilc4113s000", 1, error.msg)
endif
endif
commit.transaction()
stpapi.end.session("tdilc4113s000")
stpapi.end.session("tisfc0507m000")
stpapi.end.session("tisfc0202m000")

mark_h
8th February 2007, 15:45
I am not sure I understand what you are doing. Are you doing a partial delivery from the production order? Because from just looking at the sessions I would expect the first delivery to receive 1 from the insert. Then the second delivery would do a another insert not an update. I am basing this on my receiving program where I always do an insert for each receipt on tdilc4113s000. We really do not build lot controlled items, so I may not be much help and am just guessing at this point.