baanfans
16th December 2010, 17:49
Hello all!
I´m trying to development cancell sales order way tdsls4500m000 (BaanERP 5.0c) using the next sentences:
select tdsls400.*
from tdsls400
where tdsls400._index1 inrange {:orno.f} and {:orno.t}
selectdo
stpapi.put.field("tdsls4500m000","tdsls400.orno", tdsls400.orno)
retval1 = stpapi.find("tdsls4500m000", err1)
if retval1 = 1 then
ret = stpapi.synchronize.dialog("tdsls4500m000","modify",err1)
if ret then
stpapi.form.command("tdsls4100s000", 5, "exec.user.1", err1)
stpapi.enum.answer("tdsls4100s000", "tdsls41001", tcyesno.yes)
|* Cancelar orden
stpapi.enum.answer("tdsls4100s000", "tdsls41013", tcyesno.yes)
|* Aún hay artículos en línea; desea continuar?
stpapi.put.field("tdsls4100s000","chng.reason.lines", "DIGIT1")
stpapi.put.field("tdsls4100s000","chng.type.lines", "V70001")
ret = stpapi.update("tdsls4100s000", true, err1)
stpapi.enum.answer("tdsls4100s000", "tdsls410001", tcyesno.yes)
|* El tipo y código de cambio para el cambio de cabecera se ha
|* introducido correctamente?
ret = stpapi.update("tdsls4100s000", true, err1)
stpapi.end.session("tdloc0101s000", err1)
stpapi.end.session("tdsls4100s000", err1)
endif
endif
stpapi.end.session("tdsls4500m000", err1)
endselect
But the order does not cancell! I don't know what can I do in order to cancell the sales order correctly.
I attach the AFS.LOG
Please!
Thanks in advance!
mark_h
16th December 2010, 19:07
First if you use the sync dialog command then your update should be on the main session, not the subsession. If you are syncing 4500m000 with 4100s000 then the update should be on the main session. See the sticky thread for documentation
Second why two updates on the session? Is that how you do it manually? I see two updates for tdsls4100s000. I would expect one update on the main session setting all the fields. I guess it could be two steps, but we do not use these sessions.
Third - what is up with this tdloc? I see nothing to control it, but you end the session.
baanfans
16th December 2010, 20:13
Hello! Thanks for your comments.
I tried with only one api.update an referred by main session:
select tdsls400.*
from tdsls400
where tdsls400._index1 inrange {:orno.f} and {:orno.t}
selectdo
stpapi.put.field("tdsls4500m000","tdsls400.orno", tdsls400.orno)
retval1 = stpapi.find("tdsls4500m000", err1)
if retval1 = 1 then
ret = stpapi.synchronize.dialog("tdsls4500m000","modify",err1)
if ret then
stpapi.form.command("tdsls4100s000", 5, "exec.user.1", err1)
stpapi.enum.answer("tdsls4100s000", "tdsls41001", tcyesno.yes)
|* Cancelar orden
stpapi.enum.answer("tdsls4100s000", "tdsls41013", tcyesno.yes)
|* Aún hay artículos en línea; desea continuar?
stpapi.put.field("tdsls4100s000","chng.reason.lines", "DIGIT1")
stpapi.put.field("tdsls4100s000","chng.type.lines", "V70001")
stpapi.enum.answer("tdsls4100s000", "tdsls410001", tcyesno.yes)
|* El tipo y código de cambio para el cambio de cabecera se ha
|* introducido correctamente?
ret = stpapi.update("tdsls4500m000", true, err1)
stpapi.end.session("tdloc0101s000", err1)
stpapi.end.session("tdsls4100s000", err1)
endif
endif
stpapi.end.session("tdsls4500m000", err1)
endselect
}
But nothing happens. I can not simulate the correct process that cancels an order... :confused:
Session "tdloc0101s000" is a customization that pop ups when a sales orders is update.
mark_h
17th December 2010, 15:53
From glancing at your post this piece of the code works
select tdsls400.*
from tdsls400
where tdsls400._index1 inrange {:orno.f} and {:orno.t}
selectdo
stpapi.put.field("tdsls4500m000","tdsls400.orno", tdsls400.orno)
retval1 = stpapi.find("tdsls4500m000", err1)
if retval1 = 1 then
So you found the correct order. Now the next piece of code:
ret = stpapi.synchronize.dialog("tdsls4500m000","modify",err1)
if ret then
Are you sure in it is a synchronized session? Probably is, but want to confirm that the tdsls4100s000 is sync'ed session?
Next code:
stpapi.form.command("tdsls4100s000", 5, "exec.user.1", err1)
If this is a sync'ed session I am not sure why you are executing a form command? I guess it could be the command to cancel the order, but I am not sure how the session works. When doing manually do you do this first and then tdsls4100s000 comes up? Then you update and continue on the tdsls4100s000 session? It makes a difference. Plus at this point you should check you check in the option dialog the processes you have running and what the parent process is for subprocesses. No knowledge on baan 5, but this is what I use in baan 4.
stpapi.enum.answer("tdsls4100s000", "tdsls41001", tcyesno.yes)
|* Cancelar orden
stpapi.enum.answer("tdsls4100s000", "tdsls41013", tcyesno.yes)
|* Aún hay artículos en línea; desea continuar?
Can you check that you have the correct order on the session? Add some code between the above section and below section to just get some fields off the form - usually there are at least some read fields for index or order type information. Read them and confirm that they work.
stpapi.put.field("tdsls4100s000","chng.reason.lines", "DIGIT1")
stpapi.put.field("tdsls4100s000","chng.type.lines", "V70001")
stpapi.enum.answer("tdsls4100s000", "tdsls410001", tcyesno.yes)
|* El tipo y código de cambio para el cambio de cabecera se ha
|* introducido correctamente?
Now if tdsls4100s000 is not a sync'ed session then the update would be on it and not the main session.
ret = stpapi.update("tdsls4500m000", true, err1)
Not sure what to do with the tdloc session yet, but usually you have a stpapi.handle.subproc statement for other called subsessions. But until the update works there is no reason to worry about that.
stpapi.end.session("tdloc0101s000", err1)
stpapi.end.session("tdsls4100s000", err1)
endif
endif
stpapi.end.session("tdsls4500m000", err1)
endselect
}
baanfans
17th December 2010, 17:23
Hello, thanks again!
I attached doc file with the correct sequence that occurs in the process to Cancel Sales Order in BaanERP5.0c.
I checked sync session tdsls4100s000...
I don't know what happens with AFS but I cannot reached cancel order with the AFS sentences in script. :mad:
Anything else that I must check?
Thanks!
mark_h
17th December 2010, 22:37
Here is a question I cannot answer - maybe a baan 5 user can. If continue is a form command - could this save also be a form command? Just not sure.
Based off your document I made some changes to the code:
select tdsls400.*
from tdsls400
where tdsls400._index1 inrange {:orno.f} and {:orno.t}
selectdo
stpapi.put.field("tdsls4500m000","tdsls400.orno", tdsls400.orno)
retval1 = stpapi.find("tdsls4500m000", err1)
if retval1 = 1 then
ret = stpapi.synchronize.dialog("tdsls4500m000","modify",err1)
if ret then
| Answer questions before executing cancel
stpapi.enum.answer("tdsls4100s000", "tdsls41001", tcyesno.yes)
stpapi.enum.answer("tdsls4100s000", "tdsls41013", tcyesno.yes)
stpapi.form.command("tdsls4100s000", 5, "exec.user.1", err1)
|* Aún hay artículos en línea; desea continuar?
stpapi.put.field("tdsls4100s000","chng.reason.lines", "DIGIT1")
stpapi.put.field("tdsls4100s000","chng.type.lines", "V70001")
| Again make sure answer is set before executing command.
stpapi.enum.answer("tdsls4100s000", "tdsls410001", tcyesno.yes)
|* El tipo y código de cambio para el cambio de cabecera se ha
|* introducido correctamente?
| Try this
ret = stpapi.update("tdsls4500m000", true, err1)
| and if does not work try, but comment out update.
|ret = stpapi.save("tdsls4500m000", err1)
| and if that does not work commenting out above update and save
|ret = stpapi.update("tdsls4500m000", false, err1)
|ret = stpapi.save("tdsls4500m000", err1)
endif
endif
stpapi.end.session("tdloc0101s000", err1)
stpapi.end.session("tdsls4100s000", err1)
stpapi.end.session("tdsls4500m000", err1)
endselect
Notice - you always want to make sure questions are answered before the command the gets executed and asks them. I also have this thing where I like to start and stop sessions even in a loop - while this causes extra overhead it has solved some problems for me in the past.
Also notice I also recommend trying update, then save, then update(with false) and save. Do you have source code? Then you could debug what happens in the session.
baanfans
18th December 2010, 00:18
Thank you very much!
I will try with this recommendations... :)