Kingsto88
8th September 2005, 12:15
Hi experts,
Have anyone done API for generate outbound in Baan 5c?
Appreciate it if you can give me some ideas or the code to make this happen.
Thanks and regards,
Paul P
9th September 2005, 10:55
Hi Kingsto88,
I've done the whole outward movement management using API. But I don't have the source code with me. Left it in customer's server. Are you having any problem with a particular part?
Rgds,
Paul
Kingsto88
12th September 2005, 09:03
Hi Paul,
Is the one that you did,,, in Baan 5 or Baan 4?
I am currently looking into it and want to know in advance whether it can be done or not in Baan 5. Once I start programming and hit any problems I will put my code into this thread.
In the meantime, when you say outward movment...does it include
Generate Outbound, Release Outbound?
What about Confirm Shipment? Can it be done using API?
Thanks and regards,
Kingsto88
19th May 2006, 12:49
Hi everyone,
I managed to handle generate and release outbound thru API.
But when i run confirm shipment in API, it hangs there.
i checked the order line already goes to status "shipped"
How do I solve so that the API dont hang up after confirming shipment.
I also checked in my script already have end session.
thanks and regards
Paul P
22nd May 2006, 05:11
Hi Kingsto88,
Wow, it took you a long time to do it, huh? Please post your code and I may be able to help. As I mentioned, I've done the complete cycle of this in 5.0c all the way to the printing of packing slip
Rgds,
Paul
Kingsto88
24th May 2006, 10:39
Dear all,
Below is the code to confirm shipment. But it hangs after running the function. I have to use Start bshell to kill the session.
Can anyone give me a suggestion as to what to do and how to overcome this.
rgds,
function confirm.shipment()
{
long ret
message("confirm")
string tmp.orno(6)
stpapi.put.field("whinh4275m000","confirm.by",str$(etol(whinh.cnsh.whs.order)))
stpapi.put.field("whinh4275m000","inv.adj.date",str$(utc.num()))
stpapi.put.field("whinh4275m000","worg",str$(etol(whinh.oorg.sales)))
stpapi.put.field("whinh4275m000","worn.f",ln.sono)
stpapi.put.field("whinh4275m000","worn.t",ln.sono)
stpapi.put.field("whinh4275m000","wset.f","0")
stpapi.put.field("whinh4275m000","wset.t","999")
stpapi.put.field("whinh4275m000","wpon.f","0")
stpapi.put.field("whinh4275m000","wpon.t","9999")
stpapi.put.field("whinh4275m000","wseq.f","0")
stpapi.put.field("whinh4275m000","wseq.t","9999")
| The next 4 lines generate both the advice and shortages, if you want
| just one report then set the flags correctly, but always point the report
| to the advice report - This is the only way to get it to work.
| Advice Report
|stpapi.put.field( "whinh4275m000", "pradvice", str$(tcyesno.no) )
|stpapi.put.field( "whinh4275m000", "prshortage", str$(tcyesno.no) )
spool.fileout = "tmp0001"
spool.device = "D"
stpapi.set.report( "whinh4275m000","rwhinh427511000","D", msg )
stpapi.form.command("whinh4275m000",5,"exec.cont.process",msg)
if not isspace(msg) then
|stpapi.continue.process("whinh4275m000",msg)
message("%s",msg)
endif
stpapi.end.session("whinh4275m000")
}
Paul P
24th May 2006, 13:42
Hi Kingsto88,
We constructed the API for confirming shipments based on whinh4531m000 (Shipment lines) session. I now forgot whether we did it this way because doing it through whinh4275m000 (Confirm shipments) didn't work or because of other reason. But doing this through whinh4531m000 does work in our system. Wanna give it a go? Simply find the shipment line, mark it and do a form command exec.user.0 then exit
Rgds,
Paul
Kingsto88
25th May 2006, 03:48
Hi Paul,
How do you find a line and mark it using API. Have not try this before.
Need your advice or sample of how to do it.
Thanks and regards
Paul P
26th May 2006, 04:49
Hi Kingsto88,
You can look up the latest AFS manual from SSA OnePoint Online support or download from the sticky thread on top of this AFS forum. Anyway, here's my code snippet for confirming shipments:
stpapi.put.field("whinh4531m000","whinh431.shpm",whinh431.shpm)
stpapi.put.field("whinh4531m000","whinh431.pono",str$(whinh431.pono))
stpapi.find("whinh4531m000")
stpapi.mark("whinh4531m000")
stpapi.synchronize.dialog("whinh4531m000","modify",err.mesg)
stpapi.put.field("whinh4131s000","whinh431.iadt",str$(whinh915.addt))
stpapi.update("whinh4531m000",true,err.mesg)
if not isspace(err.mesg) then
while true
stpapi.get.mess.code("whinh4131s000",err.mesg)
if isspace(err.mesg) then break endif
err.mesg="4131 Form cmd: "&err.mesg
print.err.rprt()
endwhile
prev.proc.ok=false
endif
stpapi.end.session("whinh4131s000")
stpapi.form.command("whinh4531m000",5,"exec.user.0",err.mesg)
if isspace(err.mesg) then
prev.proc.ok=true
else
while true
stpapi.get.mess.code("whinh4531m000",err.mesg)
if isspace(err.mesg) then break endif
err.mesg="4531 Form cmd: "&err.mesg
print.err.rprt()
endwhile
prev.proc.ok=false
endif
stpapi.end.session("whinh4531m000")
Rgds,
Paul
Kingsto88
8th June 2006, 06:48
Hi Paul,
using your session whinh4531m000, also hangs.
Hi Mark,
Do you have any suggestion?
Regards,
Paul P
8th June 2006, 08:52
Well, usually if the same code works in one BaanERP server but not the other, that means there's difference in STP module or the objects of the program being controlled. Please try to update your STP as well as the session object for whinh4531m000.
Rgds,
Paul
veyant
8th June 2006, 12:15
Hi,
It might be a bug in STPAPI. Samething happened with me. it was hanging in the end after doing all required actions and control was not returning back to Form.
Hwoever, for time being i have put end.transction to end session.
But does anybody has permanent solution for this problem.
Kingsto88
12th June 2006, 05:35
Hi veyant,
What is the command you used to end.transaction???
I used exit() but the confirm shipment api is in a loop.
I dont want to exit completely from the program. Want to continue in the loop to confirm shipment for other sales orders.
Please help anyone!
rgds
Paul P
14th June 2006, 05:59
Hi Kingsto88,
Until you actually state that you've updated your objects, I won't give any more reply. And simply looking at veyant's profile, you can tell that he might be talking about BaanIV 4.0c4 not BaanERP 5.0c
Rgds,
Paul
mark_h
14th June 2006, 15:42
What is the command you used to end.transaction???
I used exit() but the confirm shipment api is in a loop.
I dont want to exit completely from the program. Want to continue in the loop to confirm shipment for other sales orders.
I agree with Paul you need to make sure objects are current. Also I am not sure what you mean by - in a loop. If you are talking about confirming multiple shipments there are two methods that I use:
start loop for some condition
open session with stpapi.put
do find
update/process record
loop
close session
OR
start loop for some condition
open session with stpapi.put
do find
update/process record
close session
loop
The second opens and close the session for each record processed. I find this is cleaner in most instances. But in some cases I do not have problems with method 1. So you probably need to define what you mean by loop.
Kingsto88
15th June 2006, 06:07
Thanks Paul and Mark,
I have not updated the objects because I do not have the time now.
Anyway, I have managed to overcome the problem by killing the session instead.
Mark, I am using your method - 1 to loop around.
Thanks and regards,
mark_h
15th June 2006, 15:28
If you are using method 1 you might want to just try closing the session each time through - sometimes it helps, but then again sometimes it does not help. These little problems are one of the things that make AFS so much fun.