Kingsto88
19th October 2006, 17:37
Hi experts
I am trying to do the above.
I tried many times with different methods, but it failed.
I managed to insert a sales order header but when trying to insert SO lines...FAIL
Can someone please direct me to a thread that has the program that works. I looked up some threads in this forum and tried using their program but also fails.
Does anyone has any suggestion?
Thanks and regards,
mark_h
19th October 2006, 18:23
In this thread (http://www.baanboard.com/baanboard/showthread.php?t=22694&highlight=sales+order+line+baan) Doug states that he got it working in the second post. He also specified that you had to get menus and such correct. I am not on Baan V so I would recommend trying to send Doug a message. I am not sure how often he visits the board.
Kingsto88
19th October 2006, 18:32
Hi Mark and Doug,
How do i send a message to Doug?
I am already using Doug's suggestion here but it does not work.
It gives message 'Sales order not found in table Sales order'
Would really appreciate your help with this.
Thanks,
The below is my code:
function main()
{
maintain.so()
process.order.line()
}
function maintain.so()
{
message("maintain so")
stpapi.put.field("tdsls4100s000","tdsls400.ofbp","BA0000002")
stpapi.put.field("tdsls4100s000","tdsls400.sotp","SSO")
stpapi.put.field("tdsls4100s000","tdsls400.orno","310")
stpapi.put.field("tdsls4100s000","tdsls400.cwar","PSFG1")
ret = stpapi.insert("tdsls4100s000",1,msg)
if not isspace(msg) then
message("mess %s",msg)
endif
stpapi.get.field("tdsls4100s000","tdsls400.orno",orderno)
message("tt %s",orderno)
stpapi.end.session("tdsls4100s000")
}
function process.order.line()
{
message("order line")
stpapi.put.field("tdsls4500m000","tdsls400.orno",orderno)
ret = stpapi.find("tdsls4500m000",msg)
stpapi.mark("tdsls4500m000")
stpapi.handle.subproc("tdsls4500m000", "tdsls4501m000", "add")
stpapi.form.command("tdsls4500m000", 5, "to.lines", err.msg)
ret = stpapi.synchronize.dialog("tdsls4501m000", "add", err.msg)
if ret then
stpapi.put.field("tdsls4101s000", "tdsls401.pono", "10")
stpapi.put.field("tdsls4101s000", "tdsls401.item.segment.1", "")
stpapi.put.field("tdsls4101s000", "tdsls401.item.segment.2", "UDI-002")
stpapi.put.field("tdsls4101s000", "tdsls401.oqua", "2")
stpapi.put.field("tdsls4101s000", "tdsls401.cwar", "PS-RM1")
ret = stpapi.insert("tdsls4501m000", true, err.msg)
if not ret then
message("recover %s",err.msg) |ERROR APPEARING HERE
ret = stpapi.recover("tdsls4101s000", err.msg)
else
err.msg = "Line Record Added"
message("%s",err.msg)
endif
endif
stpapi.end.session("tdsls4101s000")
stpapi.end.session("tdsls4501m000")
}
mark_h
19th October 2006, 18:52
I do not see stpapi.handle.subproc("tdsls4101s000", "mtdsls00009047","13") this in your code anywhere. I am not sure where Doug intended this command to be - my speculation is before the insert on tdsls4101s000. According to Doug you have to get the correct menu and sequence.
You can try to send him a PM or email message. I think(not sure) that he has both options turned on at this point.
Andreas
20th October 2006, 08:24
Hi,
i managed to import sales orders only partially with the help of AFS.
There is a usefull dll in standard, called tdslsdll1234. Have a look at it.
With this dll you can manage imports very easy.
Hope it helps,
Andreas
forchinacn
19th November 2006, 14:47
hi Andreas,
How to use tdslsdll1234? can you give me a sample script?
thinks.
nidyar
23rd November 2006, 13:20
Hi
when you enter a sales order line and input the quantity, you will have inventory shortage handling menu. If you do not handle it properly you may not be able to insert the line. in Baan 50c, inventory shortage handling dialog box opens a menu (list of sessions!!) and you have to select the options from it.
do you think this is the problem here? If so, will stpapi.handle.subproc() be able to handle it (since i is not a session, message, question or dialog but a menu)?
forchinacn
26th November 2006, 02:42
Hi exports,
I create a baan session to create sales order lines,but I have a strange problem: when the program script is compiled with debugger and run step by step, it works properly, BUT it cannot work when it is compiled normally.
I handle popup menu with code "stpapi.handle.subproc("tdsls4101s000", "mtdsls00009047","13")". My baan version is baan v.
thinks in advance.
stpapi.put.field("tdsls4500m000", "tdsls401.orno", m_orno)
ret = stpapi.find("tdsls4500m000", error.msg)
if ret = 1 then
ret = stpapi.mark("tdsls4500m000", error.msg)
if ret = 1 then
stpapi.handle.subproc( "tdsls4500m000","tdsls4501m000", "add" )
stpapi.form.command("tdsls4500m000", 5, "to.lines",error.msg)
ret = stpapi.synchronize.dialog("tdsls4501m000", "add", error.msg)
if ret then
stpapi.handle.subproc("tdsls4101s000", "mtdsls00009047","13")
stpapi.put.field( "tdsls4101s000", "tdsls401.item.segment.1", m_item(1;9) )
stpapi.put.field( "tdsls4101s000", "tdsls401.item.segment.2", m_item(10;37) )
stpapi.put.field( "tdsls4101s000", "tdsls401.oqua", str$(m_oqua) )
stpapi.put.field( "tdsls4101s000", "tdsls401.cuqs", m_cuqp )
stpapi.put.field( "tdsls4101s000", "tdsls401.pric", str$(m_pric) )
stpapi.put.field( "tdsls4101s000", "tdsls401.cwar", m_cwar )
|*****stpapi.insert return 0 when it was compiled normally
|***** and error.msg was filled like "E","S"...
ret = stpapi.insert("tdsls4501m000", true, error.msg)
if not ret then
ret = stpapi.recover("tdsls4501m000", error.msg)
endif
endif
endif
endif
nidyar
26th November 2006, 04:47
If a sales order has no lines, when you go to tdsls4501m000 by using "to.lines" from tdsls4500m000, new record is invoked which causes tdsls4101s000 to open automatically. Try putting a stpapi.handle.subproc to that also.
Also, you can directly go to session tdsls4501m000, put the order number, change.view and then call stpapi.synchronize.dialog... "add"... and avoid going through tdsls4500m000.
forchinacn
27th November 2006, 13:49
Hi,all
I have soluted the strange problem by adding code "suspend(20)", It's SO funny! I think the reason is session need some time to handle stpapi.synchronize.dialog()
I am attaching my code,
stpapi.put.field("tdsls4500m000", "tdsls401.orno", m_orno)
ret = stpapi.find("tdsls4500m000", error.msg)
if ret = 1 then
ret = stpapi.mark("tdsls4500m000", error.msg)
if ret = 1 then
stpapi.handle.subproc( "tdsls4500m000","tdsls4501m000", "add" )
stpapi.form.command("tdsls4500m000", 5, "to.lines",error.msg)
suspend(20) | give some time to session's openning, :)
ret = stpapi.synchronize.dialog("tdsls4501m000", "add", error.msg)
if ret then
stpapi.handle.subproc("tdsls4101s000", "mtdsls00009047","13")
stpapi.put.field( "tdsls4101s000", "tdsls401.item.segment.1", m_item(1;9) )
stpapi.put.field( "tdsls4101s000", "tdsls401.item.segment.2", m_item(10;37) )
stpapi.put.field( "tdsls4101s000", "tdsls401.oqua", str$(m_oqua) )
stpapi.put.field( "tdsls4101s000", "tdsls401.cuqs", m_cuqp )
stpapi.put.field( "tdsls4101s000", "tdsls401.pric", str$(m_pric) )
stpapi.put.field( "tdsls4101s000", "tdsls401.cwar", m_cwar )
ret = stpapi.insert("tdsls4501m000", true, error.msg)
if not ret then
ret = stpapi.recover("tdsls4501m000", error.msg)
endif
endif
endif
endif