RPG CODE EXAMPLE – “Write to joblog”
Write to joblog lets us send messages from inside a running RPG program. It’s simple using one of IBM’s API’s – Qp0zLprintf
I’ve used this little technique for ever. Simple define a procedure calling the API (in this example I call it “writejoblog”) and then in your mainline code you can just use the “writejoblog” command and squirt things into the joblog. I find this really useful when testing webservices, or anyh other batch processes, and cant be bothered to debug with a service job but just want to quickly write values to the joblog to trace what it’s upto.
RPGLE Code Example
H OPTION(*SRCSTMT) DFTACTGRP(*NO)
D writeJobLog PR 10I 0 ExtProc('Qp0zLprintf') D logMsg * Value OPTIONS(*STRING) D s1 * Value OPTIONS(*STRING:*NOPASS) D s2 * Value OPTIONS(*STRING:*NOPASS) D s3 * Value OPTIONS(*STRING:*NOPASS) D s4 * Value OPTIONS(*STRING:*NOPASS) D s5 * Value OPTIONS(*STRING:*NOPASS) D s6 * Value OPTIONS(*STRING:*NOPASS) D s7 * Value OPTIONS(*STRING:*NOPASS) D s8 * Value OPTIONS(*STRING:*NOPASS) D s9 * Value OPTIONS(*STRING:*NOPASS) D s10 * Value OPTIONS(*STRING:*NOPASS)
once you have defined this you can just use the writeJobLog opcode in your mainline:
writeJobLog ( 'Invalid Customer Number %s %s' : '1234' : 'ABC Customer' );
writeJobLog (X'25'); // EBCDIC code for carriage return
So – that’s a simple code example using older style RPG.
Don’t do that – DO THIS!
This blog is from way back in 2014 – So, let’s update it into RPG4 /FREE