kuldeepsharma
9th July 2008, 09:59
Hi All,
I have delete Po Lines thru AFS. which should be simple.
following is my code

stpapi.put.field( "tdpur4101m000", "tdpur040.orno", str$(tdsil909.orno))
ret_val = stpapi.find( "tdpur4101m000",error )
if ret_val = 1 then
stpapi.handle.subproc("tdpur4101m000", session.code, "add")
stpapi.continue.process("tdpur4101m000", error )
stpapi.put.field( session.code, "tdpur041.pono", str$(tdsil909.pono))
ret_val = stpapi.find( session.code,error )
if ret_val = 1 then
stpapi.enum.answer(session.code,"ttstpq0100",tcyesno.yes)
ret_val = stpapi.delete(session.code, true, error)
if not isspace(error) then
message("%s of this P.O %d and Position %d " , error,tdsil909.orno,tdsil909.pono)
endif
stpapi.end.session("tdpur5106s000", error)
stpapi.end.session(session.code, error)
endif
stpapi.end.session(session.code, error)
endif
stpapi.end.session("tdpur4101m000", error)

Its working fine till it encounters stpapi.end.session. its hanging when controls comes to stpapi.end session for ending tdpur4105s000 (session.code)
it has given value 1 for stpapi.delete cammnd and no errors are filled.

i don't now why it is hanging.

May be it is some thing to do with a message which session fires when deleting PO line
"This action can take long time becaus of checking restricted references"
"OK"

i don't know how to pass enter for this message thru afs (if this is the problem)

I have tried to searh the forum for this but I have not got anything on this.
can somebody please help me on this.

Lots of thanks in advance.
in anticipation on an early reply.
Thanks again

kuldeep sharma

mark_h
9th July 2008, 15:10
First I do not see a stpapi.handle.subproc for the sub-session before it is started. Below is a piece of my code to change the qty on a line:

| Go find the correct line.
| Add the line
stpapi.handle.subproc( "tdpur4107s000", "tdpur9151s00b", "add" )
stpapi.handle.subproc( "tdpur4107s000", "tcmcs9551s00b", "add" )
stpapi.handle.subproc( "tdpur4107s000", "tdpur5106s000", "add" )

rc = stpapi.enum.answer("tdpur4107s000", "tdpur41095",tcyesno.no)
rc = stpapi.enum.answer("tdpur4107s000", "tdpur01001.b",tcyesno.yes)
stpapi.put.field( "tdpur4107s000", "tdpur041.orno", str$(temp.po) )
stpapi.put.field( "tdpur4107s000", "tdpur041.pono", str$(temp.line) )

ret.code = stpapi.find( "tdpur4107s000" )
if(ret.code <> 1) then
message("Find Error add: %s",fserr)
end_sessions()
return
endif

| Change the qty.
stpapi.put.field( "tdpur4107s000", "tdpur041.oqua", str$(total.oqua) )
rc = stpapi.update( "tdpur4107s000", 1, fserr )
if(strip$(fserr)<>"" ) then
message("Line Save: %s",fserr)
end_sessions()
return
endif
stpapi.end.session( "tdpur5106s000" )