-   AFS/DDC/OLE: Function servers (
-   -   generate outbound advice with API in Baan 5 (

Kingsto88 21st September 2005 11:30

generate outbound advice with API in Baan 5
Hi experts,

I am trying to run whinh4201m000 to generate using API. (baan5c)

Has anyone done this before?

My code is as below. No error message is appearing when i run stpapi.form.command. Anyone know what is wrong?

Thanks and regards,

function update.table()
        long ret
        string tmp.orno(6)



| 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( "whinh4201m000", "pradvice", str$( )
        stpapi.put.field( "whinh4201m000", "prshortage", str$( )
        |spool.fileout = "tmp0001"
        | "whinh4201m000","rwhinh420101000","ASCIF", msg )
        if not isspace(msg) then


Paul P 21st September 2005 12:02

As per API manual, when sending enumerator to BaanERP session under API, always send the string version of the long integer version of the enumerator (e.g. stpapi.put.field("whinh4201m000","oorg.f",str$(etol(whinh.oorg.sales))) ) . I saw you made several syntax errors in this regard. Please correct and let us know the result. I've never done generate outbound advice through API before, but I've implemented WMS-ERP integration through the use of create (not generate) outbound advise via BaanERP API


Kingsto88 22nd September 2005 07:07

Dear Paul,

There is no syntax error when i compile my program.

Anyway, I still changed the program to add in the etol function.

But still it is unsuccessful. No Outbound advice is created.

Hope someone has used API in baan 5 before.

I am trying this exercise in baan 5.
In baan 4, i have no problem generating outbound with API.

Can someone tell me how do I know/check the API in baan 5 in my system is actually working.

Thanks and regards,

Paul P 22nd September 2005 10:44

One more thing you should get used to when switching to and fro BaanERP is that BaanERP uses UTC (Universal Time Coordinated). So in your case, I'd expect the program to give unexpected result, because you used the date.num() function while calculating value to pass to dldt.f and dldt.t (which are in UTC). Please read the Tools on line help to learn more about UTC.
To cut story short, when passing values to a from/to date/time in BaanERP, I usually send utc.num()-7*24*60*60 (i.e. exactly 7 days before the current date & time) to the from field and send utc.num()+7*24*60*60 to the to field. Use this approach and your API program should work better in BaanERP (provided the planned delivery date is +/- 1 week from current date & time)


Kingsto88 23rd September 2005 12:08

Thank you
Dear Paul,

I have changed it to utc.num()
and it works fine.

Thank you very much, appreciate your help.

Very exciting when it works.


eric.dizon 21st March 2014 22:57

I am trying to create an AFS for this in ERP LN FP7. I am trying to follow the same code you have but I am having no luck, with my code below it generates a Run Number in whinh4500m000 but no outbound advise can any body review and let me know what possible issues i might have. We do need to print the outbound advise and outbound shortages.

res = utc.add(utc.num(),0,0,100,0,0,0,ddta.t)

stpapi.put.field("whinh4201m000", "runnumber", trim$(runnumber))
stpapi.put.field("whinh4201m000", "overwrite.range", str$(ltoe(1)))

stpapi.put.field("whinh4201m000", "dldt.t", str$(ddta.t) )
stpapi.put.field("whinh4201m000", "cwar.f", " " )
stpapi.put.field("whinh4201m000", "cwar.t", "ZZZZZZ" )
stpapi.put.field("whinh4201m000", "stty.f", str$(ltoe(1)) ) |Warehouse
stpapi.put.field("whinh4201m000", "stty.t", str$(ltoe(4)) ) |Work Center
stpapi.put.field("whinh4201m000", "stco.f", " " )
stpapi.put.field("whinh4201m000", "stco.t", "ZZZZZZZZZ" )
stpapi.put.field("whinh4201m000", "shpt.f", " " )
stpapi.put.field("whinh4201m000", "shpt.t", "ZZZZZZZZZ" )
stpapi.put.field("whinh4201m000", "crte.f", " " )
stpapi.put.field("whinh4201m000", "crte.t", "ZZZZZ" )
stpapi.put.field("whinh4201m000", "carr.f", " " )
stpapi.put.field("whinh4201m000", "carr.t", "ZZZ" )

stpapi.put.field("whinh4201m000", "oorg.f", str$(ltoe(1)) )
stpapi.put.field("whinh4201m000", "oorg.t", str$(ltoe(90)) )
stpapi.put.field("whinh4201m000", "grid.f", " " )
stpapi.put.field("whinh4201m000", "grid.t", " " )
stpapi.put.field("whinh4201m000", "orno.f", cxcsb005.orno )
stpapi.put.field("whinh4201m000", "orno.t", cxcsb005.orno )
stpapi.put.field("whinh4201m000", "oset.f", "0" )
stpapi.put.field("whinh4201m000", "oset.t", "999999" )
stpapi.put.field("whinh4201m000", "pono.f", "0" )
stpapi.put.field("whinh4201m000", "pono.t", "9999" )


stpapi.put.field("whinh4201m000", "pradvise", str$(ltoe(1)) )
stpapi.put.field("whinh4201m000", "prshortage", str$(ltoe(1)) )

stpapi.put.field("whinh4201m000", "include.returns", str$(ltoe(2)) )
stpapi.put.field("whinh4201m000", "rush.orders.only", str$(ltoe(2)) )

stpapi.form.command( "whinh4201m000", 5, "advise", err.cmd )
if not isspace(err.cmd) then

mark_h 23rd March 2014 18:58

Not sure this is it since we do not use the session, but the first thing that jumped out to me is the grid.f and grid.t have both set to blank.

If it is not that then the next thing I would try is commenting out all ranges that you are setting to the default. They do not have to be set - unless the user id you are testing with has some defaults saved on the session that you do not what to test with. Just put the bare minimum you would need to run it to test with. Then if you get that working you can add the fields back in - one at a time until you locate which one is causing the issue.

eric.dizon 24th March 2014 18:30

Hi mark, I've populated grid.f and grid.t as well but still no luck. Run number is being generated by the AFS code but not the outbound advise. I can't see any error either being returned. I am currently stuck on what else to try...

mark_h 24th March 2014 21:24

Try using stpapi.get.mess.code right after the stpapi.form.command( "whinh4201m000", 5, "advise", err.cmd ). See if your getting "no data found" or any error message. I suspect the put fields for now. For example - I notice cxcsb005.orno is used directly. Is this a string value? If not make it str$(cscsb005.orno). Next I would pull out every range in the code that is wide open. I would also open the date range up with like -1000 and +1000 like the original code. Also is the item segmented?

I also noticed the original program uses stpapi.form.command("whinh4201m000",5,"exec.user.0",msg) and you use stpapi.form.command( "whinh4201m000", 5, "advise", err.cmd ). I am not sure which is correct.

eric.dizon 26th March 2014 18:17

Thanks for all the good pointers Mark, I think the item being segmented is the one that resolved my issue.

All times are GMT +2. The time now is 22:20.

©2001-2018 - -