“How do I check the status of the System 21 (JBA/GEAC/INFOR) background jobs from an RPG program?“
I was asked to hack together a quick little routine to check the status of the System21 background jobs, for some specific web-service calls that were talking to an IBM i system running INFOR’s System21 ERP. Hmmm… That is an awful lot of words in that sentence! Let’s try it again. I am trying to say this “a web-service call to JBA SYSTEM21 needs to know if a background job is running before it does something”. In this case the background job its checking for is called “WH_CONFDSP” the warehousing confirm dispatch job (or post shipment as Americans call it).
So, we know that System21 ERP does some things interactively and some things in background (aka “batch”) mode.
We can easily view the background job status’ using the System21 Menus: we can either goto menu /L1S (or L1SUS if American) in both the green screen and Infor Client or simply call the program from the command line:
But, with this little code snippet you can add it to your programs as well.
I added a little procedure to a common service program so I could check this from any webservice:
// +-------------------------------------------------------------+ // | #BACKGROUNDACTIVE - check if background job is active | // +-------------------------------------------------------------+ dcl-proc #BackgroundActive export; dcl-pi #BackgroundActive ind; ProcName char(10) const; RtnErrorCode char(32766) options(*varsize:*nopass); end-pi; dcl-ds S21backgroundJobs qualified extname('L1P99') end-ds; Monitor; exec SQL declare cursorL1P99 cursor for select * from L1P99 exec SQL open cursorL1P99; exec SQL fetch next from cursorL1P99 into :S21backgroundJobs; If sqlstt='00000' or %subst(sqlstt:1:2)='01'; = *on; else; = *off; endif; exec SQL close CursorL1P99; on-error; = *off; RtnErrorCode = 'WEBSERVICE(#BackGroundActive) Failed!' + ' Process(' + %trim(ProcName) + ')' + ' created an unrecoverable error!'; endmon; Return ; end-proc;
is a single character ‘n’ logical value that is defined globaly.
So the nice thing about this is you can check all the different background jobs by name. The names I know of include:
To use it just make sure your program is using the service program that contains the #BackgroundActive procedure and then you simply add these lines of code in the program initialization stage. You could check the status something like this:
If not #BackgroundActive('WH_CONFDSP'); RtnMessageA = '*ERROR* WHSE Background job(WH_CONFDSP)' + ' is not active! Contact Support Desk.'; Endif;
Hope this helps someone out?
IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Alpha Nerd and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and in the words of the most interesting man in the world: Stay thirsty my friend.
Example RPGLE program to populate the JBA System21 *LDA – Fully Free
Example RPG program to populate the Infor System21 *LDA
Toby Schofield 3PSC – Chicago IBMi (AS400) JBA Consultant
Start Stop System21 Background Jobs (WHSE, GL, IN, OE – BACK3)
Can I upgrade JBA SYSTEM21 from IBM-i v5r4 to V6 or V7?
User guide to the JBA System21 application on the AS400
The rise and fall of JBA software – AS400 ERP System21
How to Upload a SAVF with IBM I ACS a.k.a. Upgrade HTTPAPI (LIBHTTP) to V7.2