“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;