November 18

0 comments

RPG example – How to retrieve System21 Background Job status

By NickLitten

November 18, 2015

INFOR, JBA, SYSTEM21

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:

S21 background

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:

Rpg json libhttp example
// +-------------------------------------------------------------+ // | #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:

Background Jobname

AC_ACEPTUP
AS_ASNSNDE
AS_CNFDESP
AS_SHIPLBL
CS_UPDATE
DY_DOCEXTR
GL_UPDATE
IN_PMOERSV
IN_STKMONT
IN_STKUPDT
OE_ADPRICE
OE_INVRFSH
OE_RESGENM
PC_ORDUPDT
MJ_CONTROL
PL_UPDATE
WH_CNFMATI
WH_CONFDSP
WH_CONFUPD
WH_PUTAWAY
SL_UPDATE

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;
Quick and Dirty but it works… 🙂

Hope this helps someone out?

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Join the IBM i Community for FREE Presentations, Lessons, Hints and Tips

>