ppchong
22nd September 2011, 03:10
Hi Baan Expert,

i face a problem of using the AFS to delete record in a session call "Maintain Estimated End items (pspmg0113m000). Found that not able to select/mark a record and delete it. Details of the script as below :

*****************************************************
long retValFind, retValMark, retValDelete, retVal1, retVal2,rc

stpapi.put.field("pspmg0113m000", "pspmg013.orno", strip$(str$(ornoTxt)))
stpapi.put.field("pspmg0113m000", "pspmg013.cntr", strip$(str$(pspmg801.cntr)))

retValFind = stpapi.find("pspmg0113m000",error.msg)


if retValFind then |found


rc = stpapi.change.view("pspmg0113m000",error.msg)
retValMark = stpapi.Mark("pspmg0113m000")


if retValMark then
retValDelete = stpapi.delete("pspmg0113m000", true, error.msg)


if not isspace(error.msg) then
retval2 = stpapi.recover("pspmg0113m000", recover.msg)
Error.desc = "Error occur in Maintain Estimated end item -- during Delete container"
brp.ready(brp1.id)
else

|** Production size will be changed; Continue ?
stpapi.enum.answer("pspmg0113m000", "pspmg01132", tcyesno.yes)
stpapi.continue.process("pspmg0113m000",error.msg)


endif
endif


else

Error.desc = "Error occur in maintain Estimated end item FIND process -- during Delete container"
brp.ready(brp1.id) |**** send_error_report
endif

stpapi.end.session("pspmg0113m000")



*********************************************


Regards & Thanks
chong

mark_h
22nd September 2011, 15:47
To me it looks this easy:

stpapi.put.field("pspmg0113m000", "pspmg013.orno", strip$(str$(ornoTxt)))
stpapi.put.field("pspmg0113m000", "pspmg013.cntr", strip$(str$(pspmg801.cntr)))
retValFind = stpapi.find("pspmg0113m000",error.msg)


if retValFind then |found
stpapi.enum.answer("pspmg0113m000", "pspmg01132", tcyesno.yes)
retValDelete = stpapi.delete("pspmg0113m000", true, error.msg)
endif
stpapi.end.session("pspmg0113m000")


Granted we do no use the session, but just looking at the session on my 4c4 system this is what I would expect the code to look like. So for a delete - find the record, answer all the possible questions that might get asked, and then delete the record. No reason for change view, mark record or the continue. I did remove the error checking on the delete just to shorten the code.