Ab Keur
9th October 2007, 05:59
Hello,

I am trying to automate our approval step for the purchase goods with AFS.
But the session acts funny on session tdpur4121m000 and tdilc4123s000.

We use only the location's and not the lotcontrol.

This is the script is use:

stpapi.put.field("tdpur4121m000", "tdpur045.reno", str$(tdpur045.reno))
stpapi.put.field("tdpur4121m000", "tdpur045.orno", str$(tdpur045.orno))
stpapi.put.field("tdpur4121m000", "tdpur045.pono", str$(tdpur045.pono))
ret = stpapi.find("tdpur4121m000", error.msg)
if ret = 1 then
stpapi.handle.subproc("tdpur4121m000", "tdilc4123s000", "add")
stpapi.put.field("tdpur4121m000", "tdpur045.quap", str$(approved.quantity))
ret = stpapi.update("tdpur4121m000",1, error.msg)
stpapi.put.field("tdilc4123s000", "tdilc111.stra", str$(approved.quantity))
stpapi.put.field("tdilc4123s000", "tdilc111.strd", str$(tdpur045.dqua - approved.quantity))


ret = stpapi.update("tdilc4123s000",1,error.msg)
ret = stpapi.save("tdilc4123s000",error.msg)

stpapi.end.session("tdilc4123s000",error.msg)
stpapi.end.session("tdpur4121m000",error.msg)
endif


The script runs with no problem, the result from AFS are all OK.
But when you lookup the results in Baan. The data is stored in the subsession, but the entered values are not stored in the main session.

Does anyone have experience with automating this session, or a working example for me.

Thanks in advance.

mark_h
9th October 2007, 14:15
Here is a snippet of my code:

stpapi.handle.subproc("tdpur4121m000","tcmcs9551s00b","add")
| 072704 Use the purchase order line unit.
if tiitm001.kltc = tckltc.batch or conversion.factor<> 1.0 or purchase.unit <> tiitm001.stgu then
| 20050616.st Prevent users from trying this until session is fixed.
| msg = "May not store lot controlled/Conversion factor items until session is fixed."
| if not isspace(msg) then
| stpapi.end.session("tdpur4121m000")
| return
| endif |20050616.end
|



stpapi.handle.subproc("tdpur4121m000","tdilc4123s000","add")
stpapi.put.field("tdpur4121m000","tdpur045.quap",str$(appr.qty))
rc = stpapi.update("tdpur4121m000",1,msg)

stpapi.put.field("tdilc4123s000","tdilc111.stra",str$(appr.qty))
stpapi.put.field("tdilc4123s000","tdilc111.strd",str$(rej.qty)) |20050615.end
stpapi.put.field("tdilc4123s000","tdilc111.stka",str$(appr.qty))
stpapi.put.field("tdilc4123s000","tdilc111.stkd",str$(rej.qty)) |20050615.end
rc = stpapi.update("tdilc4123s000",1,msg)
if not isspace(msg) then
stpapi.recover("tdilc4123s000",msg)
endif

Notice that one commented out section. We had some problems that required me to use Qkey to change the source code on tdilc4123s000 to get it to work. I will admit I have not tried to remove this code from tdilc4123s000 to see if it works with just the stpapi commands. I can't remember what was happening - two years ago sp18.

Ab Keur
15th October 2007, 00:07
Thanks Mark

But the code you showed, produced the same results. I don't know what I should try to get this session working with AFS.

mark_h
15th October 2007, 02:03
Like I mentioned - I did have to add some code into the sessions to get them to work. I used Qkey - just not sure if that would work for you. Have you reported it to Baan support?

Ab Keur
19th October 2007, 20:52
I did report it to baan support.
The script I posted was judged as incorrect and proven wrong. The sniplet I got from them didn't work either.
But now the case is closed, no solution is provided, since my script is wrong. Therefore I like to know if somebody has a working example of the approval step (location control and no lotcontrol)

mark_h
22nd October 2007, 04:02
You should be able to go back into the case and re-open it. Somewhere there is a status on the case that you can change online. I would do that.