pradbaan
7th July 2005, 00:24
Hi
I would like to write an afs for the tisfc0202m000 along with the handling of the subsession tdilc4113s000 - maintain receipts.
can someone help me get started.

mark_h
7th July 2005, 13:35
This thread (http://www.baanboard.com/baanboard/showthread.php?t=24296&highlight=tisfc0202m000) has my version of tisfc0202m000 in it. This is a starting point. If when you complete a production order it calls tdilc4113s000 then you will need to add a stpapi.handle.subproc statement to try to control the sub-session. The outline would look something like this:

stpapi.put.field("tisfc0202m000",.....)
stpapi.put.field("tisfc0202m000",.....)
stpapi.put.field("tisfc0202m000",.....)
stpapi.handle.subproc("tisfc0202m000","tdilc4113s000",somemsg)
rc = stpapi.update("tisfc0202m000",1,msg)
stpapi.put.field("tdilc4113s000",.....)
stpapi.put.field("tdilc4113s000",.....)
rc = stpapi.update("tdilc4113s000",1,msg)

It is not always as easy as it looks. I have problems with programs that call tdilc4113 and tdilc4123 before.

Good Luck!

pradbaan
8th July 2005, 05:07
Thanks mark for your help
I did run the session with the afs but it doesn't seem to be doing anything at all. it goes thru fine without any error and i check in the debug mode. but it does seem to anything at all.
any thoughts on this

thanks

mark_h
8th July 2005, 13:28
If you post the code someone might see something. You can also set turn on the afs log and post it (-set AFSLOG=1 in bwc login). That will also help.

pradbaan
8th July 2005, 17:54
function extern domain tcbool tisfcdll9110.create.afs.report.production.order.completed(
| domain tfgld.docn docn.f,
| domain tfgld.lino lino.f,
| domain tcncmp comp.f,
domain tcpdno pdno.f,
domain tiqep1 qcmp.f,
domain tccwar cwar.f,
domain tdltc.clot clot.f,
domain tcitem item.f,
| domain tcyesno comp.frm,
| domain tcyesno updt.popr,
| domain tcyesno post.stock,
domain tidate date.f,
ref string o.mess())
{
long ret.val
long retval
string msg
long gapi.error.code
long rc
string somemsg
stpapi.put.field("tisfc0202m000","tisfc001.pdno",str$(pdno.f))
rc = stpapi.find("tisfc0202m000",o.mess)
if not isspace(o.mess) or rc<>1 then
stpapi.end.session("tisfc0507m000")
stpapi.end.session("tisfc0202m000")
return(false)
endif
| Update the warehouse
stpapi.put.field("tisfc0202m000","tisfc001.cwar",cwar.f)
rc = stpapi.update("tisfc0202m000",1,o.mess)
if not isspace(o.mess) or rc<>1 then
stpapi.end.session("tisfc0202m000")
return(false)
endif

| stpapi.get.field("tisfc0202m000","tisfc001.osta",qcmp)
| stpapi.get.field("tisfc0202m000","tisfc001.pdno",qcmp)
| stpapi.get.field("tisfc0202m000","qdlv.frm",qcmp)
stpapi.put.field("tisfc0202m000","qdlv.frm",str$(qcmp.f))
rc = stpapi.enum.answer("tisfc0202m000","tisfc02024",tcyesno.yes)
rc = stpapi.enum.answer("tisfc0202m000","tisfc02029",tcyesno.yes)
stpapi.put.field("tisfc0202m000","tisfc001.cwar",cwar.f)
stpapi.continue.process("tisfc0202m000",o.mess)
if isspace(o.mess) then
stpapi.handle.subproc("tisfc0202m000","tdilc4113s000",somemsg)
stpapi.put.field("tdilc4113s000","tdilc402.item",item.f)
stpapi.put.field("tdilc4113s000","tdilc402.clot",clot.f)
stpapi.put.field("tdilc4113s000","tdilc402.date",str$(date.f))
stpapi.put.field("tdilc4113s000","tdilc402.qstr",str$(qcmp.f))
| rc = stpapi.insert("tfacp1120s000", true, o.mess)
rc = stpapi.update("tdilc4113s000",1,o.mess)
if not isspace(o.mess) or rc<>1 then
stpapi.end.session("tdilc4113s000")
stpapi.end.session("tisfc0507m000")
stpapi.end.session("tisfc0202m000")
return(false)
else
stpapi.end.session("tdilc4113s000")
rc = stpapi.update("tisfc0202m000",1,o.mess)
if not isspace(o.mess) or rc<>1 then
stpapi.end.session("tisfc0507m000")
stpapi.end.session("tisfc0202m000")
endif
endif
stpapi.get.mess.code("tisfc0202m000",o.mess)
else
return(false)
endif
stpapi.end.session("tisfc0202m000")
return(true)
}

mark_h
8th July 2005, 19:00
The first thing I notice is that your stpapi.handle.subproc should be before the continue. From looking at your code I am assuming that when you run it manually you may change the warehouse(this is the only field I change), then you click continue and then the session tdilc4113s000 comes up. Is that correct? Also what version of Baan are you on? It makes a difference in some cases.

The whole key behind these function servers is to try to mirror what you do manually on your system - which may be different from my system. So on my system I can get asked two questions, those are what you have in your code. Make sure these match your system and make sure you do not get asked additional questions. Those will also need to be built into your code. I usually run through the session manually tracking what I did to get it to work - then just translate it into code.