Ankita
8th May 2008, 07:07
I am updating the value of a table field (which is not a form field) through AFS. In the script of the session on which AFS calls are made, I am declaring a variable of the domain same as of the table field and assigning it to the that table field in the before.write and before.rewrite events of the main.table.io section. This variable is extern so that i can assign while making AFS calls.
When i am inserting (through AFS), the table field is set and inserted in the table. The problem is when i make AFS calls for updating: the table field is not updated with the new value even i have written in the before.rewrite. I am not understanding the reason behind it. Can anyone tell me how can i proceed?
mark_h
8th May 2008, 14:44
Not enough information to answer the question. Put the AFS code in debug mode, then put the session it calls in debug mode. As you step through the AFS code you can see what is happening in the session that it calls. This way you can see what all gets executed with a stpapi.update or insert. There have been times that in my AFS code I do go out an update a field(direct select/update) that the session being called from AFS would not update. I know I do this on purchase order header.
Ankita
8th May 2008, 16:05
Mark,
Thank u for reply. I would try debugging session as u said. But i want to know one thing that in your case, was that field a form field? As, in my case it isnt.
It is a table field that is not on the form. So, i am declaring one extern variable eg. quantity. The table field is: tdoes002.quan. Now, thorugh AFS calls i am setting value in quantity.
stpapi.put.field("tdoes0102s000","quantity",str$(kpoes042.quan))
And in the session (tdoes0102s000) on which AFS calls are made, I am setting its value in before.rewrite.
tdoes002.quan=quantity.
Now, i think the problem is more clear.
mark_h
8th May 2008, 18:21
Yes - my case it was a form field. In other cases what I have done is use the following to get script fields into the program(usually in before.program):
if api.mode then
import("some.var",some.var)
endif
Ankita
9th May 2008, 06:27
Mark,
While debugging the session on which AFS calls are made, events in main.table.io section are not executed. And i tried importing the variable as you told in the example script. But, this too doesnt wrk. Then, what could be the possible reason?
mark_h
9th May 2008, 14:24
Did you export the variable from the AFS program? I know the export/import works. Of course with the import you have to make sure you get it in the correct spot. I know before program is not always the correct event. Sometimes it needs to be right before you use it.
Ankita
9th May 2008, 19:42
Yes, Mark. I exported the value from AFS program. But dint get the result as required. As you are saying import/export works in AFS, i will try again the same. And secondly while debugging the session on which the AFS calls are made, pointer did not go in main.table.io section. Is it the issue of calling thru AFS? I am not getting the reason.
mark_h
9th May 2008, 19:50
Yes - it does. This is code I have in tdilc4123s000
main.table.io:
after.read:
if api.mode then
if first then
first = false
import("rcd.ttccom000", rcd.ttccom000)
import("rcd.ttdpur040", rcd.ttdpur040)
import("rcd.ttdpur041", rcd.ttdpur041)
import("rcd.ttdpur045", rcd.ttdpur045)
import("rcd.ttcmcs042", rcd.ttcmcs042)
select tdilc111.*
from tdilc111
where tdilc111._index1 = {tdilc.kooa.act.pur,:tdpur045.orno, :tdpur045.pono,:tdpur045.reno}
selectdo
endselect
execute(find.data)
execute(modify.set)
endif
endif
|#pobj added by QKEY 3.70
_pobj_exe1("after.read")
Since we do not own source we use qkey to extend the source and do things like the import. The key is - if you import a value, make sure the session script does not change it along the way. I have other examples - in this case the api program starts Maintain approvals which calls tdilc4123s000. So in this case it is one level deeper than you need.
Ankita
10th May 2008, 08:12
No, Mark. I am unable to get the value when imported in the session for which the AFS calls are made. Switching to my original problem. The field i want to set through AFS calls is not a form field. So, i am setting a extern variable and assiging to the table field in before.write and before.rewrite events. Insertion is happening properly but all problem is in updating this table field, as new value isnt assigned in the table field. So, is there any need of DLL for setting its value to updating the value of the table field which is not a form field.
Ankita
15th May 2008, 20:52
Its an urgent issue i am facing. Plz, reply ASAP. Is there is any other alternative way to do the same?
mark_h
16th May 2008, 03:14
Sorry, but not that I am aware of. I know this method works, but with out knowing your system or code I can not tell you exactly how to do this.
Ankita
16th May 2008, 06:26
Thank you Mark for your valuable replies.
Things worked without any need of export/import. What i am doing is,
In my AFS code, i am setting the extern variable quantity...
stpapi.put.field("tdoes0102s000","quantity",str$(kpoes042.quan))
In the BAAN session (tdoes0102s000) i am declaring quantity as the extern variable. The table field is: tdoes002.quan. And I am setting its value in before.rewrite.
tdoes002.quan=quantity
So, the value set through AFS call will be assigned into the table field.
Strange thing is, the same thing was not working before.. But now its working.
But import/export in AFS case, is still to try more. As, its not working now also.
mark_h
18th May 2008, 03:06
I did think of another solution that I used once, but not it this way. What I did was clone a session. So what you can do for this session is clone it to a new session and use the original form and script. Then add a new form to the cloned session - put the field on this new form. Phillipes response in the other thread made me think of this.
What I did so the user did not see it was to clone some sessions. Then I used the original scripts. I changed the form to have just the stuff I needed and formatted so it would work better with the AFS code. I did this cause I could not modify the original baan session. I have done this several times.
Better late than never and maybe this will help someone else in the future.