alibaba
26th June 2006, 13:54
Hi:
I was test AFS receipt in Baan4C4 sch.before develpe, I sought some examples in baanboard,but not same with us :

* My script for sub.order receipt,so input serial of receipt only.and call tdpur4131s000 only (sch).

select tdpur045.*
from tdpur045
where tdpur045._index4 = {:temp.pdno,:temp.opno}
as set with 1 rows
selectdo
stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(temp.rcno))
stpapi.enum.answer("tdpur4120m000","tdpur41206",tcyesno.no)
stpapi.handle.subproc("tdpur4120m000","tdpur4131s000","add")

|****in fact the choice.cont.process not any define in tdpur4120m000*****
| stpapi.continue.process("tdpur4120m000", error.cont)
stpapi.zoom.option("tdpur4120m000",1,"tdpur4131s000",error.zoom)

stpapi.put.field("tdpur4131s000","tdpur045.reno",str$(temp.rcno))
stpapi.put.field("tdpur4131s000","tdpur045.suno",tdpur045.suno)
stpapi.put.field("tdpur4131s000","tdpur045.orno",str$(tdpur045.orno))
stpapi.put.field("tdpur4131s000","tdpur045.pono",str$(tdpur045.pono))
stpapi.put.field("tdpur4131s000","tdpur045.ddtb",str$(tdpur045.ddtb))

ret.find.s = stpapi.find("tdpur4131s000")
ret.mark = stpapi.mark("tdpur4131s000")

|choice cont.process and db.save not any define in tdpur4131s000 also...
|stpapi.continue.process("tdpur4131s000", error.cont)
|stpapi.save("tdpur4131s000", error.cont)

stpapi.end.session("tdpur4131s000")

stpapi.get.field("tdpur4131s000","tdpur045.reno",ret.rcno)
stpapi.end.session("tdpur4120m000")
endselect


at step stpapi.get.field("tdpur4131s000","tdpur045.reno",ret.rcno),I cant get receipt number,and I find the last number of receipt serial (tcmcs047),that not any changed.

so, I think maybe not geranated receipt number when runtime. but in AFS LOG , that find/mark was successful!
why ? how to geranate receipt number?


thanks!

mark_h
26th June 2006, 15:57
I do not actually see anything to create the receipt - of course it looks like your version is different than mine. We do not use tdpur4131s000. You can try this in your code:

stpapi.enum.answer("tdpur4120m000","tdpur41206",tcyesno.no)
stpapi.handle.subproc("tdpur4120m000","tdpur4131s000","add")
ret = stpapi.change.view("tdpur4120m000")


This might automatically start tdpur4131s000 - at least that is the impression I get from other posts. Once tdpur4131s000 comes up I really can't help. I can tell you this - on our system this session does have a "OK" button, which is usually the same as continue.

Just guessing.

alibaba
27th June 2006, 04:23
thanks for you reply Mark!
Yes, when put : stpapi.change.view("tdpur4120m000") to script,that same with stpapi.zoom.option("tdpur4120m000",1,"tdpur4131s000",error.zoom) in backguard(start tdpur4131s000),but message "<tdpur4120m000 2 another view found!" was appeard in log.I think maybe put fields not key field .so I put zoom.option call tdpur4131 directly.
so , I think my problem is gerenate receipt number only ,why can not auto generate after 4131s000(find = 1 mark = succ.). when and who? 4120m000 or 4131s000? if 4120m000. then another action needed when retrun from 4131s000?
.......................................

mark_h
27th June 2006, 15:53
I do not think I am going to be much help. On our system tdpur4131s000 uses supplier, delivery date, order and position to find a record. So it sounds like our systems work differently. I would expect your API code to mimic almost exactly what you do manually to create a receipt. From just glancing at my system this is how I think it should work - but this is only a guess.

|* Find existing receipt
stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(receipt.number))
stpapi.put.field("tdpur4120m000","tdpur045.orno",str$(purchase.order))
stpapi.put.field("tdpur4120m000","tdpur045.pono",str$(purchase.line))
rc = stpapi.find("tdpur4120m000",msg)

stpapi.enum.answer("tdpur4120m000","tdpur41206",tcyesno.no)
stpapi.handle.subproc("tdpur4120m000","tdpur4131s000","add")
rc = stpapi.change.view("tdpur4120m000")
|* The above change view launches tdpur4131s000
stpapi.put.field("tdpur4131s000","tdpur045.suno",tdpur045.suno)
stpapi.put.field("tdpur4131s000","tdpur045.ddtb",str$(tdpur045.ddtb))
stpapi.put.field("tdpur4131s000","tdpur045.orno",str$(tdpur045.orno))
stpapi.put.field("tdpur4131s000","tdpur045.pono",str$(tdpur045.pono))
|* Find the new receipt in tdpur4131s000
rc = stpapi.find("tdpur4131s000",msg)
|* Mark the record
ret.mark = stpapi.mark("tdpur4131s000")
stpapi.continue.process("tdpur4131s000",msg)
stpapi.end.session("tdpur4224s000")
|Note for the continue you might get message Process is Gone
|At this point this would to the existing receipt found in tdpur4120m000

I did not do any error checking and if you are trying a brand new receipt I would expect you could leave the stpapi.find on tdpur4120 out of the code and just do the change view. Again this is all guessing since our system does not work like that.

What I do in my code is check to see if a receipt exists for the line and position - if yes I run a modify existing receipt routine. If no I run the create a receipt routine, then when it completes I run modify existing receipt.

Paul P
4th September 2006, 11:36
Just looking through the AFS forum and saw this thread. Alibaba, please look at the script that Pedro posted in Nov 2002. That one works. Don't worry about stpapi.change.view("tdpur4120m000")=2. I got the same return for that command, but my AFS sequence works as it should be (and it follows the same pattern as Pedro's)

By the way, stpapi.get.field("tdpur4120m000","tdpur045.reno",ReceiptNumber) failed in my test server until we updated our STP module. So, make sure you have latest STP too (solution 10923 in Baan Support)

Rgds,
Paul

Rgds,
Paul