jhargett
3rd August 2009, 19:23
I am having a problem using AFS to populate the subsession tdsls4103s000 which allows adding a special delivery address to the Sales Order header. After filling out the Sales Order header and saving it, then storing the returned Sales Order number, this function is called:
function long save_delivery_address()
{
long ret
string last_error(255)
string msg(255)
last_error = ""
output("Handle Subsession for Delivery Address: " & del_session)
stpapi.handle.subproc(main_session, del_session, "add")
stpapi.application.option(main_session, 1, 2, last_error)
if (last_error = "") then
output("ERROR: Could not start subsession for delivery to address:" & last_error)
return (0)
endif
stpapi.put.field( del_session, "tdsls042.orno", str$(orno) )
ccty = "USA"
stpapi.put.field( del_session, "tdsls042.ccty", ccty )
ret = stpapi.update( del_session, false, last_error)
if (ret = 0) then
output("ERROR: Could not update data to subsession for delivery to address:" & last_error)
return (0)
endif
stpapi.get.field( del_session, "tdsls042.nama", msg )
output("Value of Nama: " & msg)
stpapi.put.field( del_session, "tdsls042.nama", nama )
stpapi.get.field( del_session, "tdsls042.nama", msg )
output("Value of Nama: " & msg)
stpapi.get.field( del_session, "tdsls042.orno", msg )
stpapi.put.field( del_session, "tdsls042.namb", namb )
stpapi.put.field( del_session, "tdsls042.namc", namc )
stpapi.put.field( del_session, "tdsls042.namd", namd)
stpapi.put.field( del_session, "tdsls042.name", name )
stpapi.put.field( del_session, "tdsls042.namf", namf )
ret = stpapi.insert( del_session, true, last_error)
if (ret = 0) then
output("ERROR: Could not insert to subsession for delivery to address:" & last_error)
return (0)
endif
stpapi.end.session(del_session)
output("End Subsession for Delivery Address")
return (1)
}
The program returns an error after the stpapi.insert that says "Country not found in the Countries table". This is the error you get in the session if you try to leave the country field blank, but as you can see, I am setting the ctty field to "USA", which is a valid country in the countries table. Normally, when you pull up this session in Baan, all of the fields are filled out with the default delivery address of the customer. It seems when I pull up the session using AFS, these fields are not filled out. That makes it seem like maybe some initialization is not happening. I tried resolving that by adding the stpapi.update call to call the field sections, but it didn't seem to work. Any suggestions?
function long save_delivery_address()
{
long ret
string last_error(255)
string msg(255)
last_error = ""
output("Handle Subsession for Delivery Address: " & del_session)
stpapi.handle.subproc(main_session, del_session, "add")
stpapi.application.option(main_session, 1, 2, last_error)
if (last_error = "") then
output("ERROR: Could not start subsession for delivery to address:" & last_error)
return (0)
endif
stpapi.put.field( del_session, "tdsls042.orno", str$(orno) )
ccty = "USA"
stpapi.put.field( del_session, "tdsls042.ccty", ccty )
ret = stpapi.update( del_session, false, last_error)
if (ret = 0) then
output("ERROR: Could not update data to subsession for delivery to address:" & last_error)
return (0)
endif
stpapi.get.field( del_session, "tdsls042.nama", msg )
output("Value of Nama: " & msg)
stpapi.put.field( del_session, "tdsls042.nama", nama )
stpapi.get.field( del_session, "tdsls042.nama", msg )
output("Value of Nama: " & msg)
stpapi.get.field( del_session, "tdsls042.orno", msg )
stpapi.put.field( del_session, "tdsls042.namb", namb )
stpapi.put.field( del_session, "tdsls042.namc", namc )
stpapi.put.field( del_session, "tdsls042.namd", namd)
stpapi.put.field( del_session, "tdsls042.name", name )
stpapi.put.field( del_session, "tdsls042.namf", namf )
ret = stpapi.insert( del_session, true, last_error)
if (ret = 0) then
output("ERROR: Could not insert to subsession for delivery to address:" & last_error)
return (0)
endif
stpapi.end.session(del_session)
output("End Subsession for Delivery Address")
return (1)
}
The program returns an error after the stpapi.insert that says "Country not found in the Countries table". This is the error you get in the session if you try to leave the country field blank, but as you can see, I am setting the ctty field to "USA", which is a valid country in the countries table. Normally, when you pull up this session in Baan, all of the fields are filled out with the default delivery address of the customer. It seems when I pull up the session using AFS, these fields are not filled out. That makes it seem like maybe some initialization is not happening. I tried resolving that by adding the stpapi.update call to call the field sections, but it didn't seem to work. Any suggestions?