ppchong
25th June 2012, 04:38
Dear Sir/Madam,

Currently my company using BAAN IV service pack 18. I have added 1 table field with option "mandatory input" in a baan standard table tdilc402 which is inbound table. I tried to use AFS to insert a record but fail, showed a message " ctnr not allow". Is it AFS not support the field which is not baan standard ? Below is the AFS function :

stpapi.put.field("tdilc4113s000", "tdilc402.clot", shiftr$(strip$(tdltc935.mbmr)))
stpapi.put.field("tdilc4113s000", "tdilc402.date", str$(tdltc935.edte))
stpapi.put.field("tdilc4113s000", "tdilc402.stun", strip$(str$(tdltc935.cntr)))
stpapi.put.field("tdilc4113s000", "tdilc402.qstr", qstr_str)
stpapi.put.field("tdilc4113s000", "tdilc402.qstc", inv_qty_str)

stpapi.put.field("tdilc4113s000", "tdilc402.ctnr", "3") |** tdilc402.ctnr not a Baan standard field

retval1b = stpapi.insert("tdilc4113s000", true, errmsg3)


Appreciate if you can give me the solution or help ..


Thanks & Regards,

PPchong
:)

mark_h
25th June 2012, 16:09
First verify 3 is correct - not " 3" or something like that. Then can you put the session in debug mode and walk through it seeing what happens to the ctnr field? There could very well be something in the script setting the field back to blank. After the insert have you tried a get.field to see what is in the field after the update?

ppchong
26th June 2012, 06:49
Dear Sir,

I have put the session in debug mode, but when reach the line "retval1b = stpapi.insert("tdilc4113s000", true, errmsg3)", errmsg3 will showed "cntr not allow". Thus fail to insert record to table tdilc402. Actually this table field "tdilc402.ctnr" is not a baan standard table field and the field type is integer type. We have set the option "mandatory input" in tdilc402 table level. Is it possible AFS not support ?

cintact
26th June 2012, 11:56
In our baan IV, the table tdilc402 has also a field cntr, which is used over a combined field cmbd in the fifth index. Maybe the index is the problem?

mark_h
26th June 2012, 15:37
Sorry -I was talking about putting tdilc4113s000 in debug mode, not the api code. Then step through the session. What I have found before is that for one reason or another, the standard baan session will wipe out a field after a stpapi.put. In some cases I can insert a record, then update it and in at least one case I actually put the field directly to the table to get it updated. I can't say this is the case or not.

Keep in mind I am assuming that if you ran the session manually then the data in the put fields above will actually work. So just be sure that the data is correct.

On our 4c4 system tdilc402 also has a cntr field, but it is a string field(length of 3) not numeric. But we are using A&D extension and service pack 27 or 28(can't remember) which. So I don't know if that makes a difference or not. Your code looks pretty close to mine, except for the cntr field.

stpapi.put.field("tdilc4113s000", "tdilc402.clot",purchase.lot)
stpapi.put.field("tdilc4113s000", "tdilc402.date",str$(purchaselot.date))
stpapi.put.field("tdilc4113s000", "tdilc402.qstr",str$(received.qty*conv.factor))
stpapi.put.field("tdilc4113s000", "tdilc402.qstc",str$(received.qty*conv.factor))
rc = stpapi.insert("tdilc4113s000",1,msg)
error_code = stpapi.get.mess.code("tdilc4113s000",msg)
|20080331.st Add the command cancelled check.
if strip$(error_code) = "tdilc40062" or strip$(msg) = "Command cancelled" then
msg = ""
endif
stpapi.end.session("tdilc4113s000")

mark_h
26th June 2012, 15:38
PS - the command cancel was added on 3-31-2008 and was caused during the SP24 install.