zakir_h
14th February 2011, 07:41
Hello Guys,

Can some one help me out with this strange problem...IT is really urgent.... i am trying to automate the receipts in BAANERP 5.0c . I am attaching below the code which does the confirming of receipt after linking to a receipt number.

Note: i am able to link the PO lines to receipt number successfully...


function confirm.receipt()
{
domain tcdate temp.ddte,temp.ddtc,temp.prdt
string temp.ardt(10)
string temp.pono(4)
long pono.temp,ardt.temp


flag = tcyesno.no

| ********************** Confirm Receipt *************************


| stpapi.enum.answer("whinh3520m000","whinhs312002",tcyesno.yes)
stpapi.put.field("whinh3520m000", "whinh210.rcno", temp.rcno)
ret = stpapi.find("whinh3520m000", error.msg)

if ret and not isspace(temp.rcno) then

ret = stpapi.browse.set("whinh3520m000","first.set",err.mesg)
while ret

stpapi.mark("whinh3520m000",err.mesg)
ret = stpapi.synchronize.dialog("whinh3520m000", "modify", err.mesg)

if ret then
stpapi.form.command("whinh3120s000",5,"exec.user.4",err.mesg)
stpapi.get.field("whinh3120s000", "whinh210.clot", temp.lot)
ret = stpapi.update("whinh3120s000", true, error.msg)
error.code = stpapi.get.mess.code("whinh3120s000",error.msg)


ret = stpapi.save("whinh3120s000", error.msg)
flag = tcyesno.yes


stpapi.end.session("whinh3120s000")
endif

ret = stpapi.browse.set("whinh3520m000","next.set",err.mesg)
| message(str$(ret))

endwhile

stpapi.form.command("whinh3520m000",5,"exec.user.4",err.mesg)

endif
if flag = tcyesno.yes then
message("Receipt Number %s for PO %s was made and confirmed.",temp.rcno,tdafi018.orno)

endif

stpapi.end.session("whinh3822m000")
stpapi.end.session("whinh3520m000")
stpapi.end.session("whinh3120s000") | End confirm Receipt Sessions

err.mesg=""


}


what happens is at the time of stpapi.update command,, it returns an error code.. .which is "whinhs312002" and does not update the table whinh210...

Now what is strange, is that this error message doesnot come when we simulate the confirmation manually, then why is AFS throwing this error code... and how to handle this ..because.. .a similar message of "tolerance" we are already handling it while linking the lines to the PO..

regards
zakir

mark_h
15th February 2011, 02:33
Well I don't know anything about these sessions, so I recommend searching on them. What I did notice is that you use the ret = stpapi.synchronize.dialog("whinh3520m000", "modify", err.mesg) and then use ret = stpapi.update("whinh3120s000", true, error). I believe when you use sync dialog the update goes against the main session and not the sub-session.