vinceco252
20th July 2009, 19:43
Ok, I really hope I'm doing something obviously wrong here. I am creating a session to process a custom table populated from a text file into a sales order. Here is the code for the AFS portion of the session:

function domain tcbool process.tdair101.to.sales.order(ref domain tcorno h.orno, ref domain tcpono h.pono)
{
domain tcbool h.return
long count, ret


h.return = false

string error(100)
string error.mesg(100)
string value(6)

boi.call = "tdboidll0005"

|*tdsls4101m000
| Header
stpapi.put.field( "tdsls4101m000", "tdsls040.orno", "10") |SO Number/Series
stpapi.put.field( "tdsls4101m000", "tdsls040.cuno", tdair101.cuno) |Customer
stpapi.put.field( "tdsls4101m000", "tdsls040.cotp", tdair101.cwar) |Order Type
stpapi.put.field( "tdsls4101m000", "tdsls040.odat", str$(tdair101.date)) |Order Date
stpapi.put.field( "tdsls4101m000", "tdsls040.prdt", str$(tdair101.date)) |Planned Receipt Date
stpapi.put.field( "tdsls4101m000", "tdsls040.ddat", str$(tdair101.date)) |Planned Delivery Date
stpapi.put.field( "tdsls4101m000", "tdsls040.refa", tdair101.refa) |Reference A
stpapi.put.field( "tdsls4101m000", "tdsls040.refb", tdair101.refa) |Reference B
stpapi.put.field( "tdsls4101m000", "tdsls040.scom", str$(tcyesno.no)) |Ship Complete
stpapi.put.field( "tdsls4101m000", "tdsls040.eono", tdair101.refa) |Customer PO

ret = stpapi.insert( "tdsls4101m000", 1, error )
if ret = 1 then
stpapi.get.field( "tdsls4101m000", "tdsls040.orno", value )
h.orno = lval(value)
h.return = true
ret = 0
else
h.return = false
endif

|* Insert lines

stpapi.handle.subproc("tdsls4101m000", "tdsls4105s000", "add")
stpapi.continue.process("tdsls4101m000", error)

stpapi.handle.subproc( "tdsls4105s000", "mtdsls00009045", "10" )
| stpapi.handle.subproc("tdsls4105s000", "tdsls4504s000", "kill")
stpapi.enum.answer("tdsls4105s000", "tdsls4102l.01", tcyesno.yes) |Recalculate taxes?
stpapi.enum.answer("tdsls4105s000", "tdsls41043", tcyesno.yes)

stpapi.put.field("tdsls4105s000", "tdsls041.item", tdair101.item) |Item
stpapi.put.field("tdsls4105s000", "tdsls041.oqua", str$(tdair101.dqua)) |Ordered Qty
stpapi.put.field("tdsls4105s000", "tdsls041.cwar", tdair101.cwar) |Warehouse
| stpapi.put.field("tdsls4105s000", "tdsls041.drct", str$(tcyesno.no)) |Direct Delivery?
| stpapi.put.field("tdsls4105s000", "tdsls041.scom", str$(orno)) |Ship Complete
| stpapi.put.field("tdsls4105s000", "tdsls041.epos", tdair101.abid) |Customer PO Position
| stpapi.put.field("tdsls4105s000", "tdsls041.eseq", str$(orno)) |Customer PO Line

ret = stpapi.insert("tdsls4105s000", 1, error)
if strip$(error) <> "" then
message(error)
error.mesg = stpapi.get.mess.code("tdsls4105s000", error.mesg)
endif

if ret = 1 then
stpapi.save("tdsls4105s000", error)
stpapi.get.field( "tdsls4105s000", "tdsls041.pono", value)
h.pono = lval(value)
h.return = true
else
h.return = false
endif

| stpapi.end.session("tdsls4504s000")
stpapi.end.session("tdsls4105s000")
stpapi.end.session("tdsls4101m000")

return(h.return)
}

The sales order header gets created successfully. When I get to ret = stpapi.insert("tdsls4105s000", 1, error) in the debugger, it hangs. If I check the running processes, the process for tdsls4105s000 goes through a cycle of the ticks increasing to a very large number, turning to a negative number, then decreasing, then repeating the cycle. Also, the ntbshell process on the server consumes most of the CPU resources.

I have updated tdsls4102 to the latest objects, and have installed the latest stpapi objects.

Several statements are commented out. I have tried various combinations of these statements being active. I have also tried tdsls4105m000 with no luck. I cannot get the stpapi.change.view function to work in that session to get to the order I want to insert a line for.

Any suggestions/thoughts?

Thanks,

Vince :confused:

mark_h
20th July 2009, 20:43
See if this thread helps you (http://www.baanboard.com/baanboard/showthread.php?t=54578&highlight=tdsls4105s000). It looks like they use:

stpapi.handle.subproc( "tdsls4101m000", "tdsls4105s000", "add")
stpapi.zoom.option( "tdsls4101m000",1,"tdsls4105s000", error)

In 4c4 if the choice calls a menu you are suppose to be able to use stpapi.zoom to call that subsession on the menu. So maybe trying this will work.

vinceco252
20th July 2009, 21:46
Thanks Mark. I actually did try that one too (I forgot to mention it, and already removed it from my script). I did search before I asked... :)

mark_h
20th July 2009, 22:27
Okay try this - basing this on something I just tested for another post:

stpapi.handle.subproc("tdsls4101m000", "tdsls4105s000", "add")
stpapi.handle.subproc( "tdsls4101m000", "mtdsls000090451", "10" )
stpapi.zoom.option("tdsls4101m000",10,"tdsls4105s000",err)
| The 10 assumes this session is the 10th item on the list of sessions.

mark_h
20th July 2009, 22:32
Forgot to mention on mtdsls000090451 the 1 is the sequence of the menu itself. I added that onto the command.

vinceco252
21st July 2009, 00:47
Thanks. I'm not seeing a zoom option on tdsls4101m000. mtdsls000090451 is a zoom menu for handling insufficient inventory off of tdsls4105s000.

stpapi.zoom.option does not seem to be doing anything either.

Thanks though,

Vince

mark_h
22nd July 2009, 00:23
Sorry Vincent I just realized this is just like doing maintain purchase orders. It should just be this easy:

stpapi.handle.subproc("tdsls4101m000", "tdsls4105s000", "add")
stpapi.continue.process("tdsls4101m000", error)
stpapi.enum.answer("tdsls4105s000", "tdsls4102l.01", tcyesno.yes) |Recalculate taxes?
stpapi.enum.answer("tdsls4105s000", "tdsls41043", tcyesno.yes)

stpapi.put.field("tdsls4105s000", "tdsls041.item", tdair101.item) |Item
stpapi.put.field("tdsls4105s000", "tdsls041.oqua", str$(tdair101.dqua)) |Ordered Qty
stpapi.put.field("tdsls4105s000", "tdsls041.cwar", tdair101.cwar) |Warehouse
| stpapi.put.field("tdsls4105s000", "tdsls041.drct", str$(tcyesno.no)) |Direct Delivery?
| stpapi.put.field("tdsls4105s000", "tdsls041.scom", str$(orno)) |Ship Complete
| stpapi.put.field("tdsls4105s000", "tdsls041.epos", tdair101.abid) |Customer PO Position
| stpapi.put.field("tdsls4105s000", "tdsls041.eseq", str$(orno)) |Customer PO Line
ret = stpapi.insert("tdsls4105s000", 1, error)

The continue should activiate tdsls4105s000 and you should have control. In the later releases I found you did not have to worry about the display session that starts with the line sub-session. It really should be this easy - have you double checked all the fields? Plus have you checked the boi.call variable? I am not sure what it should be, but it has caused things to hang on me before. Sorry not much help.