alibaba
16th September 2004, 17:32
hi guys:
I was tried insert a BOm record into tibom1501m000 via AFS, in AFS manual,insert a record to type3 form I must set stpapi.change.view first,
but I want insert a new line of record into bom , execute stpapi.change.view return value equal "2"(Another view found (err.mesg is empty)).and other stapi.insert/stpapi.syna...can't be execute!

example in the manual:
stpapi.put.field("dtfsa1502m000", "dtfsa102.seno", str$(i.seno)
ret = stpapi.change.view("dtfsa1502m000", error.msg)
if ret = 1 then
ret = stpapi.synchronize.dialog("dtfsa1502m000", "add", error.msg)
if ret then
stpapi.put.field("dtfsa1102s000", "dtfsa102.pono", str$(new.pono)
stpapi.put.field("dtfsa1102s000", "dtfsa102.name", new.name)
ret = stpapi.insert("dtfsa1502m000", true, error.msg)
if not ret then
ret = stpapi.recover("dtfsa1102s000", error.msg)
endif
endif
stpapi.end.session("dtfsa1502m000", error.msg)

if insert a new record into "dtfsa1502m000"."ret = stpapi.change.view("dtfsa1502m000", error.msg)" return 2!

why?
and how to insert a new record into a type3 form?
thank a lot!

lbencic
16th September 2004, 18:17
This setup has worked for me several times. Sometimes I have a problem with the change view but usually only if there are multiple fields on it. The tibom1510m000 session only has the item as the main field.

Can you post your code that is not working? Did you fill the item right in accordance with the wacky Baan V rules (Segmented Domain / AFS post (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=9586&highlight=item+segment) )

garias
16th September 2004, 19:14
I think that the function stpapi.change.view has a problem or bug.

try don“t make your validation about de stpapi.change.view with the return value.

stpapi.put.field("dtfsa1502m000", "dtfsa102.seno", str$(i.seno)
ret = stpapi.change.view("dtfsa1502m000", error.msg)
| if ret = 1 then | OLD LINE
if not isspace(strip$(error.msg)) then | NEW LINE


regards

Gerard

lbencic
16th September 2004, 19:23
Right, with the change view and the finds as well. I would just add that if you are going to ignore the return value, which I certainly have, I would do a 'get.field' on the key fields and validate that it is in fact on the record you expect.

garias
16th September 2004, 19:40
Right, with the change view and the finds as well. I would just add that if you are going to ignore the return value, which I certainly have, I would do a 'get.field' on the key fields and validate that it is in fact on the record you expect.

a good idea!!

Gerard

alibaba
17th September 2004, 05:19
thanks garias and thanks lbencic :)

I was wrong write code for form field! :(

in AFS.log,I found error because field error:)

so , It's worked now !

garias: you right! the stpapi.change view have a BUG, if insert a new reocrd of primary key , the return value equal 2 ! but other stpapi.* can be execute.