Trisli
14th October 2005, 17:39
Hi all,
In LN6 I have been trying to make a rather simple script to update a sales order using AFS.
Despite a lot of efforts I have still not reached any working result. Does anybody have positive experiences with this or similar sessions in LN6 (or maybe in BaanERP - the method may be the same...)
I have attached my sample function. If I run the first version (the basic attempt) the system hangs when the "stpapi.synchronize.dialog" is issued. I suppose the problem is that tdsls4100m900 is not a multi-occ session.
If I Try to go the normal "user dialog" way through (the "Alternative try"), I open tdsls4100m000, synchronize it (starting tdsls4100m900) and activate form option: "open.sales.order" (starting tdsls4100m000 in single.occ mode) I receive an error message: "Editable synchronized dialog not started". I suppose this is due to the reason that tdsls4100m000 is started twice, and AFS tries to access the wrong instance.
Finally I have tried to start tdsls4100m900 directly and from there activate the above form option without synchronizing. When updating is this scenario, I receive a: "...use the synchronized dialog".
Does any of you folks know how to break this problem?
Thanks!
:confused:
table ttdsls400 | Sales Orders
domain tcmcs.long afs.ret
domain tcmcs.long afs.ret.rec
domain tcmcs.str16 afs.value
domain tcmcs.str80 recover.mess
#pragma used dll ottstpapihand
#pragma used session tdsls4100m900
#pragma used session tdsls4100m000
function update.sales.order( domain tcncmp i.ncmp, |* Company
domain tcorno i.orno,
domain tcdate i.ddat, |* Pln. Delv Date
domain tcrefa i.refa, |* Your ref
domain tcrefb i.refb, |* Our ref
domain tcemno i.crep, |* Internal Sales rep
domain tccpay i.cpay, |* Terms of Payment
ref domain tcmcs.str80 o.mess)
{
o.mess = ""
stpapi.put.field("tdsls4100m900","tdsls400.orno", strip$(shiftl$(i.orno)) )
afs.ret = stpapi.find("tdsls4100m900", o.mess)
if afs.ret <> 1 then
o.mess = sprintf$("Cannot find sales order: %s in session tdsls4100m900", i.orno)
else
afs.ret = stpapi.synchronize.dialog("tdsls4100m900", "modify", o.mess) |* Causes the program to hang
if afs.ret = 1 then
stpapi.form.command("tdsls4100m900", 5, "open.sales.order", o.mess)
|* *** starts synchronized session session tdsls4100m000 as a child process ***
| |* *** as sessions are not synchronized in AFS, ...
| stpapi.put.field("tdsls4100m000","tdsls400.orno", strip$(shiftl$(i.orno)) )
| afs.ret = stpapi.find("tdsls4100m000", o.mess)
|
| if afs.ret <> 1 then
| o.mess = sprintf$("Cannot find sales order: %s in session tdsls4100m000", i.orno)
| else
stpapi.put.field("tdsls4100m000","tdsls400.ddat", str$(i.ddat))
stpapi.put.field("tdsls4100m000","tdsls400.refa", strip$(shiftl$(i.refa)))
stpapi.put.field("tdsls4100m000","tdsls400.refb", strip$(shiftl$(i.refb)))
stpapi.put.field("tdsls4100m000","tdsls400.crep", strip$(shiftl$(i.crep)))
stpapi.put.field("tdsls4100m000","tdsls400.cpay", strip$(shiftl$(i.cpay)))
afs.ret = stpapi.update("tdsls4100m900", true, o.mess)
if afs.ret <> 1 then
afs.ret.rec = stpapi.recover("tdsls4100m000", recover.mess)
if isspace(o.mess) then
o.mess = sprintf$("Error during update of sales order: %s", i.orno)
endif
endif
| endif
endif
stpapi.end.session("tdsls4100m000")
return(afs.ret = 1)
}
Alternative try:
stpapi.put.field("tdsls4100m000","tdsls400.orno", strip$(shiftl$(i.orno)) )
afs.ret = stpapi.find("tdsls4100m000", o.mess)
if afs.ret <> 1 then
o.mess = sprintf$("Cannot find sales order: %s in session tdsls4100m900", i.orno)
else
afs.ret = stpapi.synchronize.dialog("tdsls4100m000", "modify", o.mess) |* Causes the program to hang
if afs.ret = 1 then
stpapi.form.command("tdsls4100m900", 5, "open.sales.order", o.mess)
|* *** starts synchronized session session tdsls4100m000 as a child process ***
stpapi.put.field("tdsls4100m000","tdsls400.orno", strip$(shiftl$(i.orno)) )
afs.ret = stpapi.find("tdsls4100m000", o.mess)
if afs.ret <> 1 then
o.mess = sprintf$("Cannot find sales order: %s in session tdsls4100m000", i.orno)
else
stpapi.put.field("tdsls4100m000","tdsls400.ddat", str$(i.ddat))
stpapi.put.field("tdsls4100m000","tdsls400.refa", strip$(shiftl$(i.refa)))
stpapi.put.field("tdsls4100m000","tdsls400.refb", strip$(shiftl$(i.refb)))
stpapi.put.field("tdsls4100m000","tdsls400.crep", strip$(shiftl$(i.crep)))
stpapi.put.field("tdsls4100m000","tdsls400.cpay", strip$(shiftl$(i.cpay)))
afs.ret = stpapi.update("tdsls4100m900", true, o.mess)
if afs.ret <> 1 then
afs.ret.rec = stpapi.recover("tdsls4100m000", recover.mess)
if isspace(o.mess) then
o.mess = sprintf$("Error during update of sales order: %s", i.orno)
endif
endif
endif
endif
endif
|* **** end of source ****
In LN6 I have been trying to make a rather simple script to update a sales order using AFS.
Despite a lot of efforts I have still not reached any working result. Does anybody have positive experiences with this or similar sessions in LN6 (or maybe in BaanERP - the method may be the same...)
I have attached my sample function. If I run the first version (the basic attempt) the system hangs when the "stpapi.synchronize.dialog" is issued. I suppose the problem is that tdsls4100m900 is not a multi-occ session.
If I Try to go the normal "user dialog" way through (the "Alternative try"), I open tdsls4100m000, synchronize it (starting tdsls4100m900) and activate form option: "open.sales.order" (starting tdsls4100m000 in single.occ mode) I receive an error message: "Editable synchronized dialog not started". I suppose this is due to the reason that tdsls4100m000 is started twice, and AFS tries to access the wrong instance.
Finally I have tried to start tdsls4100m900 directly and from there activate the above form option without synchronizing. When updating is this scenario, I receive a: "...use the synchronized dialog".
Does any of you folks know how to break this problem?
Thanks!
:confused:
table ttdsls400 | Sales Orders
domain tcmcs.long afs.ret
domain tcmcs.long afs.ret.rec
domain tcmcs.str16 afs.value
domain tcmcs.str80 recover.mess
#pragma used dll ottstpapihand
#pragma used session tdsls4100m900
#pragma used session tdsls4100m000
function update.sales.order( domain tcncmp i.ncmp, |* Company
domain tcorno i.orno,
domain tcdate i.ddat, |* Pln. Delv Date
domain tcrefa i.refa, |* Your ref
domain tcrefb i.refb, |* Our ref
domain tcemno i.crep, |* Internal Sales rep
domain tccpay i.cpay, |* Terms of Payment
ref domain tcmcs.str80 o.mess)
{
o.mess = ""
stpapi.put.field("tdsls4100m900","tdsls400.orno", strip$(shiftl$(i.orno)) )
afs.ret = stpapi.find("tdsls4100m900", o.mess)
if afs.ret <> 1 then
o.mess = sprintf$("Cannot find sales order: %s in session tdsls4100m900", i.orno)
else
afs.ret = stpapi.synchronize.dialog("tdsls4100m900", "modify", o.mess) |* Causes the program to hang
if afs.ret = 1 then
stpapi.form.command("tdsls4100m900", 5, "open.sales.order", o.mess)
|* *** starts synchronized session session tdsls4100m000 as a child process ***
| |* *** as sessions are not synchronized in AFS, ...
| stpapi.put.field("tdsls4100m000","tdsls400.orno", strip$(shiftl$(i.orno)) )
| afs.ret = stpapi.find("tdsls4100m000", o.mess)
|
| if afs.ret <> 1 then
| o.mess = sprintf$("Cannot find sales order: %s in session tdsls4100m000", i.orno)
| else
stpapi.put.field("tdsls4100m000","tdsls400.ddat", str$(i.ddat))
stpapi.put.field("tdsls4100m000","tdsls400.refa", strip$(shiftl$(i.refa)))
stpapi.put.field("tdsls4100m000","tdsls400.refb", strip$(shiftl$(i.refb)))
stpapi.put.field("tdsls4100m000","tdsls400.crep", strip$(shiftl$(i.crep)))
stpapi.put.field("tdsls4100m000","tdsls400.cpay", strip$(shiftl$(i.cpay)))
afs.ret = stpapi.update("tdsls4100m900", true, o.mess)
if afs.ret <> 1 then
afs.ret.rec = stpapi.recover("tdsls4100m000", recover.mess)
if isspace(o.mess) then
o.mess = sprintf$("Error during update of sales order: %s", i.orno)
endif
endif
| endif
endif
stpapi.end.session("tdsls4100m000")
return(afs.ret = 1)
}
Alternative try:
stpapi.put.field("tdsls4100m000","tdsls400.orno", strip$(shiftl$(i.orno)) )
afs.ret = stpapi.find("tdsls4100m000", o.mess)
if afs.ret <> 1 then
o.mess = sprintf$("Cannot find sales order: %s in session tdsls4100m900", i.orno)
else
afs.ret = stpapi.synchronize.dialog("tdsls4100m000", "modify", o.mess) |* Causes the program to hang
if afs.ret = 1 then
stpapi.form.command("tdsls4100m900", 5, "open.sales.order", o.mess)
|* *** starts synchronized session session tdsls4100m000 as a child process ***
stpapi.put.field("tdsls4100m000","tdsls400.orno", strip$(shiftl$(i.orno)) )
afs.ret = stpapi.find("tdsls4100m000", o.mess)
if afs.ret <> 1 then
o.mess = sprintf$("Cannot find sales order: %s in session tdsls4100m000", i.orno)
else
stpapi.put.field("tdsls4100m000","tdsls400.ddat", str$(i.ddat))
stpapi.put.field("tdsls4100m000","tdsls400.refa", strip$(shiftl$(i.refa)))
stpapi.put.field("tdsls4100m000","tdsls400.refb", strip$(shiftl$(i.refb)))
stpapi.put.field("tdsls4100m000","tdsls400.crep", strip$(shiftl$(i.crep)))
stpapi.put.field("tdsls4100m000","tdsls400.cpay", strip$(shiftl$(i.cpay)))
afs.ret = stpapi.update("tdsls4100m900", true, o.mess)
if afs.ret <> 1 then
afs.ret.rec = stpapi.recover("tdsls4100m000", recover.mess)
if isspace(o.mess) then
o.mess = sprintf$("Error during update of sales order: %s", i.orno)
endif
endif
endif
endif
endif
|* **** end of source ****