aartsn
27th June 2005, 09:48
I'm trying to add postadresses to an purchase order
The first part to add an record in tdpur041 is working, but when the second part to insert an deliveryadress in subsession tdpur4103s000 (tdpur042) no error message is seen during debugging but no record is added.

Added the program part where the afs is used

function maak.kopregel() | add pruchaseorder headline
{
stpapi.put.field("tdpur4101m000", "tdpur040.orno", str$(orno.orno))
bepaal.orno.suno()
stpapi.put.field("tdpur4101m000", "tdpur040.suno", orno.suno)
stpapi.put.field("tdpur4101m000", "tdpur040.cotp", orno.cotp)
orno.ddat = date.to.num(mat.ljr, mat.lmd, mat.ldg)
stpapi.put.field("tdpur4101m000", "tdpur040.odat", str$(orno.ddat))
stpapi.put.field("tdpur4101m000", "tdpur040.ddat", str$(orno.ddat))
stpapi.put.field("tdpur4101m000", "tdpur040.refa", orno.refa)
retval = stpapi.insert("tdpur4101m000", true, err.msg)
if retval = 0 then
start.error.routine()
else
stpapi.get.field("tdpur4101m000", "tdpur040.orno", hulp.orno)
if tel.pur42 = 3 then
>> here the problem starts,
stpapi.application.option("tdpur4101m000", 1, 1, err.msg)
stpapi.put.field("tdpur4103s000", "tdpur042.nama", orno.nama)
stpapi.put.field("tdpur4103s000", "tdpur042.namc", orno.namc)
stpapi.put.field("tdpur4103s000", "tdpur042.name", orno.name)
stpapi.put.field("tdpur4103s000", "tdpur042.ccty", "NL")
retval = stpapi.update("tdpur4103s000", false, err.msg)
if retval = 1 then
retval = stpapi.save("tdpur4103s000", err.msg)
endif
stpapi.end.session("tdpur4103s000")
endif
stpapi.end.session("tdpur4101m000")
endif
}

mark_h
27th June 2005, 16:24
You might want to include this:

stpapi.handle.subproc("tdpur4101m000","tdpur4103s000","add")
stpapi.application.option("tdpur4101m000", 1, 1, err.msg)

Also I do not know about your system, but on ours when doing this manually session tdpur5106s000 comes up. Does this happen on your system? If so then you need to handle that session also.

aartsn
28th June 2005, 08:50
I also tried that but it didn't work. The session mentioned (tdpur51....) doesn't start. We are working with Baan IVc.

The session tdpur4103s000 is an user option within the session tdpur4101m000. When checking the afsl.og no error's noticed.

mark_h
28th June 2005, 15:16
We are on 4c4 and this little blurb of test code worked for me:

stpapi.put.field("tdpur4101m000", "tdpur040.orno", str$(450211))
rc = stpapi.find("tdpur4101m000", err)
if rc = 0 then
message("Not found")
stpapi.end.session("tdpur4101m000")
return
else
stpapi.handle.subproc("tdpur4101m000","tdpur5106s000","add")
stpapi.handle.subproc("tdpur4101m000","tdpur4103s000","add")
stpapi.application.option("tdpur4101m000", 1, 1, err)
stpapi.put.field("tdpur4103s000", "tdpur042.ccty", " US")
stpapi.put.field("tdpur4103s000", "tdpur042.nama", "MBAE")
stpapi.insert("tdpur4103s000",true,err)
stpapi.end.session("tdpur4103s000")
stpapi.continue.process("tdpur5106s000",err)
stpapi.end.session("tdpur5106s000")
endif
stpapi.end.session("tdpur4101m000")

As mentioned in my first post after changing or inserting the address on our system the session tdpur5106m000(which is used for change code and reason codes) pops up. We might have something turned on that you do not have. Anyway this inserts the specific address on our system.

Also something to note is that on our system when specific address is started and one does not exist in starts in the add.set mode. Sometimes this causes problems and you need to try a stpapi.save or stpapi.clear first on the session.

Also keep in mind my signature below.

Juergen
28th June 2005, 15:28
Session tdpur5106s000 pops up only if field "Prompt for Change Codes" in the Parameters PUR is set to "Yes".

Juergen