avy666
21st January 2010, 12:51
Hi :)
I need to update the field "frm.mat.to.cancel" in session "timfc0101m000" and to run process change quantity (process.chg.qty). But when the field "frm.mat.to.cancel" has been changed,the action "when.field.changes" is not ran and the variable "changed.header" is not changed to "true" at the script.

stpapi.put.field("ticst0101m000","ticst001.pdno",_pdno)
stpapi.put.field("ticst0101m000","ticst001.pono",str$(_pono))
ret=stpapi.find("ticst0101m000", err.msg)
if ret then
ret=stpapi.mark("ticst0101m000", err.msg)
if ret then
stpapi.handle.subproc("ticst0101m000", "timfc0101m000", "add")
stpapi.form.command("ticst0101m000",2,"timfc0101m000", err.msg)
stpapi.put.field("timfc0101m000","timfc001.pdno",_pdno)
stpapi.put.field("timfc0101m000","timfc001.pono",str$(_pono))
ret=stpapi.find("timfc0101m000", msg.out)
if ret then
stpapi.synchronize.dialog("timfc0101m000", "modify", err.msg)
stpapi.put.field("timfc0101m000","frm.mat.to.cancel",str$(_iswh))
stpapi.update("timfc0101m000", false, err.msg)
stpapi.form.command("timfc0101m000",5,"process.chg.qty",err.msg)
endif
endif
stpapi.end.session("timfc0101m000")
endif
stpapi.end.session("ticst0101m000")


How can i cancel the material line in this session via AFS?

mark_h
25th January 2010, 22:58
Have you tried stpapi.update("timfc0101m000", true, err.msg) instead of stpapi.update("timfc0101m000", false, err.msg). No promises this will work, nor am I familiar with this feature.

baan_guru
15th May 2021, 13:25
After 'change.view' it resets the frm.mat.to.cancel to zero. Thus using put.var to set the variable 'frm.mat.to.cancel' again in AFS.




select timfc001.*
from timfc001
where timfc001._index1 = {:i.pdno, :i.pono}
order by timfc001._index1
as set with 1 rows
selectdo
afs.process.id = -1
stpapi.put.field("timfc0101m000", "timfc001.pdno", timfc001.pdno)

procid = pid
procid = pstat(procid, progname, info)
while procid > 0
prev.progname = progname
afs.process.id = procid
procid = pstat(procid, progname, info)
if progname = "timfc0101m000" and pos(prev.progname, "ottstpapiserv") > 0 then
break
else
afs.process.id = -1
endif
endwhile

if afs.process.id < 0 then
o.err.msg = "Error in starting AFS."
return(false)
endif

stpapi.put.field("timfc0101m000", "timfc001.pono", str$(timfc001.pono))
stpapi.put.field("timfc0101m000", "timfc001.effn", str$(timfc001.effn))
stpapi.put.field("timfc0101m000", "timfc001.seqn", str$(timfc001.seqn))
stpapi.put.field("timfc0101m000", "timfc001.ittp", str$(etol(timfc001.ittp)))
if stpapi.find("timfc0101m000", o.err.msg) = 1 then
stpapi.put.field("timfc0101m000", "frm.mat.to.cancel", str$(i.qnty))
if stpapi.change.view("timfc0101m000", o.err.msg) = 1 then
put.var(afs.process.id, "frm.mat.to.cancel", i.qnty)
stpapi.form.command("timfc0101m000", 5, "process.chg.qty", o.err.msg)
if isspace(o.err.msg) then
return(true)
endif
endif
else
o.err.msg = "Record not found in 'Production warehouse Orders'"
endif
endselect