This week Carsten Flensburg provides two sample programs showing how to use the QjoRetrieveJournalEntries API, which is one of the APIs most requested by readers. Each of the two ILE RPG programs, CBX1041 and CBX1042, show how to use the QjoRetrieveJournalEntries API using format RJNE0100 and RJNE0200, respectively.
Both programs produce a simple printout of QSNADS journal entries, which you can easily modify for other journals. Program CBX1041, which uses format RJNE0100, works for V4R4 and up, while CBX1042, which uses format RJNE0200, works only for OS/400 V5R2 and greater.
Here's a list of the APIs and functions used in the program:
Retrieve Journal Entries (QjoRetrieveJournalEntries)
This API provides access to journal entry information, similar to what is
available in the Display Journal (DSPJRN), Receive Journal Entry (RCVJRNE),
and Retrieve Journal Entry (RTVJRNE) CL commands. Additionally, journal
entry data that can't be retrieved through these CL interfaces because of
length or structure is available through this API as pointers to the
additional data.
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/apis/QJORJRNE.htm
Delete Pointer Handle (QjoDeletePointerHandle)
This API deletes the specified pointer handle that was generated using the
QjoRetrieveJournalEntries API.
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/apis/QJODLTPH.htm
Convert Date and Time Format (QWCCVTDT)
This API converts date and time values from one format to another format.
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/apis/qwccvtdt.htm
Test Bit in String (tstbts)
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/c0924180.pdf
The sample programs contain detailed comments on how they operate, as well as API information. You can obtain the RPG IV sample programs at http://www.iseriesnetwork.com/noderesources/code/clubtechcode/RetrieveJournalEntries.zip.
The above source code was written by Carsten Flensburg. For questions regarding this tip, contact Carsten at mailto:flensburg@novasol.dk.