joanfuentes
25th March 2015, 16:41
Hi,

We work in baan4 c4 with one client, they have a customized fields in table tdpur040, when we tried execute afs, the value for the customized field is always empty.

We check with afs.log, but we don't found anything strange, also I tried changing the code, from check.input section to before.input section, but the before.input section is not executed

Anybody, have any idea why the afs code can't put the value?

Thanks

stpapi.put.field("tdpur4101m000", "tdpur040.orno", str$(tdsls998.ornc))
stpapi.put.field("tdpur4101m000", "tdpur040.suno", x.suno)
stpapi.put.field("tdpur4101m000", "tdpur040.cotp", tdsls998.cotc)
stpapi.put.field("tdpur4101m000", "tdpur040.refa", str$(tdsls933.invn))
stpapi.put.field("tdpur4101m000", "tdpur040.cdel", cdel)
stpapi.put.field("tdpur4101m000", "tdpur040.nspr", str$(x.nspc)) (this is the field with the problem)
sw = stpapi.insert("tdpur4101m000", true, err)

mark_h
25th March 2015, 19:40
I have seen this happen - with a standard baan field. I am not sure why it happens or what causes. I am assuming you have the right table field, data and domain for the field. In my case what I did was a select table for update for the field - and guess what? It is the very same session you have - but the field is buyer. A snippet of my code is below. I know I have seen this on a couple of other sessions, but this is the one that popped into mind with your post. The buyer never gets updated on the form.


stpapi.get.field( "tdpur4101m000", "tdpur040.orno", dummy )
created.po = val(dummy)
| IF buyer did not update correctly update it here.
stpapi.get.field( "tdpur4101m000", "tdpur040.ccon", dummy )
buyer = val(dummy)
if(tipgc520.buyr <> 0 and buyer = 0) then
db.retry.point()
select tdpur040.*
from tdpur040 for update
where tdpur040._index1 = {:created.po}
as set with 1 rows
selectdo
tdpur040.ccon = tipgc520.buyr
db.update(ttdpur040,db.retry)
endselect
commit.transaction()
endif

| Close the session.
stpapi.end.session( "tdpur4101m000" )

vinceco252
25th March 2015, 21:32
Just to check: is tdpur040.nspr on one of the forms for session tdpur4101m000? AFS is based on interacting with the form definition, not the table definition...

Vince

joanfuentes
25th March 2015, 21:52
Hi Vinceco252,

Yes, tdpur040.nspr is a field in form.

Regards

joanfuentes
25th March 2015, 22:02
Thanks Mark for your answer, but the field not take value, have validations in the script, thats the reason that i cant use your example, but realy tks

mark_h
26th March 2015, 14:19
Thanks Mark for your answer, but the field not take value, have validations in the script, thats the reason that i cant use your example, but realy tks

How complicated are the validations? Make it a library and just run them in the afs script also. Or just put the validations in itself in the script. Pretty much all my api code is in libraries.

Some of my sessions have hundreds of lines of data validation before I ever start the AFS code. In some cases the sessions will do the validation, but I do not want to get 2 or 3(or more) sessions deep before I run into an error. Backing out the other sessions would probably be more code that the validations themselves.