pruthirajpahi
20th June 2009, 16:27
Hi,
I was trying to write AFS For Receipt Linking. In this every things is working fine except that when last session “tfcmg2114s000” is opened up we have click on “OK” button or save n exist then message comes that “Document no.. created”. After this reference table gets updated.

In this session we click on OK some reference table update happens and closes this(tfcmg2114s000) session.
I am getting problem in clicking OK to message box.
Below is the code which i was writing..


stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", ttyp)
ret_val = stpapi.insert("tfgld1101m000", true, error)
if ret_val then
stpapi.get.field("tfgld1101m000", "tfgld101.btno", x.btch)
ret = stpapi.mark("tfgld1101m000", error.msg)

if ret then
stpapi.continue.process("tfgld1101m000",error)
stpapi.handle.subproc("tfgld1101m000", "tfcmg2130s000", "add")

select tfmsl111.*
from tfmsl111
where tfmsl111._index1 = {:v.cuno,
:v.orno }
| and tfmsl111.stat = tgyenox.yes
selectdo
balance = tfmsl111.balh

stpapi.put.field("tfcmg2130s000","tfacr200.cuno", tfmsl111.cuno)
stpapi.put.field("tfcmg2130s000","tfacr200.ttyp", ttyp)
stpapi.put.field("tfcmg2130s000","tfacr200.ninv", str$(tfmsl111.ninv))

ret = stpapi.mark("tfcmg2130s000", error.msg)
if ret then
stpapi.handle.subproc("tfcmg2130s000", "tfcmg2105s000", "modify")
stpapi.continue.process("tfcmg2130s000",error)
batch.l = val(x.btch)
if balance > 0 then
stpapi.put.field("tfcmg2105s000","tfcmg207.cuno", tfmsl111.cuno)
stpapi.put.field("tfcmg2105s000","tfcmg207.comp", str$(get.compnr()) )
stpapi.put.field("tfcmg2105s000","tfcmg207.ttyp", str$(tfmsl111.ttyp) )
stpapi.put.field("tfcmg2105s000","tfcmg207.ninv", str$(tfmsl111.ninv) )

ret_val = stpapi.find("tfcmg2105s000", error)
if ret_val then
ret = stpapi.mark("tfcmg2105s000", error.msg)

stpapi.get.field("tfcmg2105s000","tfcmg207.ninv", edsc )
|message("%s",edsc )

|stpapi.put.field("tfcmg2105s000","tfcmg207.type", str$(tfcmg.rcpt.manual))
stpapi.handle.subproc("tfcmg2105s000", "tfcmg2107s000", "modify")
stpapi.put.field("tfcmg2105s000","tfcmg207.type", str$(ltoe(3)) )
ret_val = stpapi.update("tfcmg2105s000",true, error.msg)

stpapi.get.field("tfcmg2105s000","tfcmg207.type", edsc )
message("%s", edsc)


stpapi.put.field("tfcmg2107s000","amnt.rcvd",str$(abs(tfmsl110.amth)) )
balance = abs(tfmsl110.amth)
ret_val = stpapi.insert("tfcmg2107s000",true,error.msg)
stpapi.end.session("tfcmg2107s000", error)

stpapi.put.field("tfcmg2105s000","tfcmg207.cuno", tfmsl111.cuno)
stpapi.put.field("tfcmg2105s000","tfcmg207.comp", str$(get.compnr()) )
stpapi.put.field("tfcmg2105s000","tfcmg207.ttyp", str$(tfmsl111.ttyp) )
stpapi.put.field("tfcmg2105s000","tfcmg207.ninv", str$(tfmsl111.ninv) )

ret_val = stpapi.find("tfcmg2105s000", error)
ret = stpapi.mark("tfcmg2105s000", error.msg)

stpapi.handle.subproc("tfcmg2105s000", "tfcmg2114s000", "modify")
stpapi.continue.process("tfcmg2105s000",error)

stpapi.put.field("tfcmg2114s000","main.docn", str$(700))
ret_val = stpapi.update("tfcmg2114s000",true,error.msg)
|ret_val = stpapi.save( "tfcmg2114s000", error)

stpapi.get.field("tfcmg2114s000","main.docn", edsc )
message("%s", edsc)

stpapi.enum.answer("tfcmg2114s000","tfcmgs2114.01", tcyesno.yes)
stpapi.continue.process("tfcmg2114s000",error)

| edsc = stpapi.get.mess.code("tfcmg2114s000",error)
| message("%s", edsc)

|suspend(5000)
stpapi.end.session("tfcmg2114s000", error)

endif
else
break
endif
stpapi.end.session("tfcmg2105s000", error)
stpapi.end.session("tfcmg2130s000", error)
endif
endselect
endif
else
error = " Transaction Type Not Found."
endif

if isspace(error) then
error = "1 Batch " & x.btch & " Completed."
else
error = "2" & strip$(error)
endif
stpapi.end.session("tfgld1101m000", error)

return(error)
}



This Error message come at the end is attached.

Please reply soon if you have some solutions
Regards
Ranjan

mark_h
22nd June 2009, 16:35
(1) Why do your stpapi.handle.subproc have modify in them? I would expect add - is this 4c4?
(2) You say when you run manually, the tfcmg2114s000 opens and you click the ok button. So why are you putting the main.docn field?
(3) I do not understand several things around the code you posted. You seem to put cuno, ttyp, ninv on several sessions starting with tfcmg1130s000 - do you have to do this when you run manually? This should emulate what happens when you do it manually. Another example is I see on tfcmg2105s000 you do a continue and tfcmg2107s000 is launched. Then when you end tfcmg2107s000, you drop back into tfcmg2105s00 and do a find - not sure why and I am not sure that is necessary.

Just somethings I noticed.