baanguy2
8th July 2005, 22:37
Hi,

I am trying to ,ake an AFS for the session tdpur4120m000 (with no ILC implemented), but it's not working, I am posting my code here, need some help with this.

function enter.receipts()
{
long isu,ret
string errm(100)
domain tcdate tdate
tdate = date.num()

stpapi.enum.answer("tdpur4120m000","tdpur41206",tcyesno.no)
stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(receipt.no))
stpapi.put.field("tdpur4120m000","form.dino",str$(shsfc004.dino))
stpapi.handle.subproc("tdpur4120m000","tdpur4131s000","add")
ret = stpapi.change.view("tdpur4120m000")

stpapi.put.field("tdpur4131s000","tdpur045.suno","SUBSUP")
| stpapi.put.field("tdpur4131s000","tdpur045.orno",str$(shsfc004.orno))
| stpapi.put.field("tdpur4131s000","tdpur045.pono",str$(shsfc004.pono))
ret = stpapi.find("tdpur4131s000")
ret = stpapi.mark("tdpur4131s000")
stpapi.continue.process("tdpur4131s000",errm)
stpapi.end.session("tdpur4131s000")
stpapi.put.field("tdpur4120m000","tdpur045.diqu",str$(shsfc004.dqua))
stpapi.put.field("tdpur4120m000","tdpur045.date",str$(tdate))
stpapi.put.field("tdpur4120m000","tdpur045.dqua",str$(shsfc004.dqua))
stpapi.put.field("tdpur4120m000","tdpur045.bqua","1")
stpapi.save("tdpur4120m000",errm)
stpapi.end.session("tdpur4120m000")
}

Thank you.

mark_h
9th July 2005, 03:38
Where does it go wrong? Are there any error messages?

baanguy2
11th July 2005, 19:03
After the change view it's returning a valaue 2 instead of one (If I do it manually it's going through fine.

Thank you,

mark_h
11th July 2005, 19:30
You may not need change.view - just a guess(since we use ILC), but could you just put the reno and dino fields using insert? Would this launch the session you mentioned. How does it work manually?

baanguy2
11th July 2005, 19:42
Manually I have to do a change view (group enter) and enter the receipt number series and then a question aksed whether a supply chain receipt is required or not and here I need to answer 'no' and then enter the packing slip number and after that the sub session comes up for me to choose the line to be received against, but it's not acting this way when AFS is executed.

Thank you,

mark_h
11th July 2005, 20:09
Do you have source? What about one of the wrapper programs? I have a feeling it may not be working because of the events Baan used to activate things. You may also need to contact Baan to get a new source - the good news is that this is one of the supported sessions for AFS(at least according to the last list I have).

baanguy2
11th July 2005, 20:17
We don't have source code, I guess I will open a baan case and see.

Thank You Mark.

Thomasm
12th July 2005, 10:08
Looking at your code and comparing with what I have picked up from Baanboard and adjusted to our settings (not using ILC, not using Supply Chain) I can see that your listing calls the handle.subproc in a different order than mine. I call the handle.subproc before setting values to the fields. I don't know if it will make a difference but it could be worth a try.

| Creating a receipt always use 0 for the tdpur045.reno field.
msg = ""
stpapi.handle.subproc("tdpur4120m000","tdpur4224s000","add")
stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(0))
stpapi.change.view("tdpur4120m000",msg)
if not isspace(msg) then
stpapi.end.session("tdpur4120m000")
return(receipt.number)
endif

Greatings to Mark for posting the original code (http://www.baanboard.com/baanboard/showthread.php?t=22771)