.st0{fill:#FFFFFF;}

Write RPG joblog messages – simple code example 

 October 28, 2015

By  NickLitten

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.

ANOTHER NOTE: I just did come back and update it into RPG4 /FREE

NickLitten


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Trekkie, 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.

Nick Litten

related posts:




{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"cff50":{"name":"Main Accent","parent":-1},"a344d":{"name":"Accent Transparent","parent":"cff50"}},"gradients":[]},"palettes":[{"name":"Default","value":{"colors":{"cff50":{"val":"var(--tcb-skin-color-0)"},"a344d":{"val":"rgba(46, 138, 229, 0.85)","hsl_parent_dependency":{"h":210,"l":0.54,"s":0.78}}},"gradients":[]},"original":{"colors":{"cff50":{"val":"rgb(0, 178, 255)","hsl":{"h":198,"s":1,"l":0.5}},"a344d":{"val":"rgba(0, 178, 255, 0.85)","hsl_parent_dependency":{"h":198,"s":1,"l":0.5}}},"gradients":[]}}]}__CONFIG_colors_palette__

Get In Touch

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

>