RPG example – How to retrieve System21 Background Job status 

 November 18, 2015

By  NickLitten

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:

// +-------------------------------------------------------------+ // | #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


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

Hope this helps someone out?


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad 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 remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

Swap Homes and Travel the World – Join Home Exchange
Surf the Web Securely with OPEN DNS
IBM i Software Change Management – CMS vs ALM – What’s in a Name?
Want to learn CL Programming?
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Get In Touch

I’m always looking for awesome input, feedback and critique!


Snug CBD

 20% Discount

I have partnered with SNUG CBD givING you Organic CBD
20% discount code "NL20"