Journal Before/After image not in plain text

40 pts.
IBM i 7.1
I have a journaled file that I need to review the before and after image of a field change. When I look at the field, the characters in both the before and after images are unreadable (strange characters, blocks, etc.). How do I view the journal image in plain text, or convert it to plain text?

Software/Hardware used:
IBM i, V7R1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Here is a link to a CMD you can download

The command is EXPJRNE. It will allow you to select the Journal Entries you want and then put the data in the format of the original file that was journaled.

Discuss This Question: 6  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • CollickB
    I'm not sure that's a possible solution Charlie Brown... I would prefer to export the file locally (to my PC for instance) and convert it rather than run a command I'm not familiar with on a production box. I'd guess it's safe, but I would only be guessing without evaluating every line of code. Perhaps a better question is why is the before image and after image in an unreadable format? The file itself is in plain text, I can see the current field data. 
    40 pointsBadges:
  • CharlieBrowne
    Which fields are in unreadable format. Are they packed numeric?All the EXPJRNE command does is a normal DSPJRN but instead of having all the data for the PF that was journaled put in one field, It will add all the fields from the field description for the PF to the end of the record so you can acutally do SQL commands or any other normal access to look at the data.
    62,385 pointsBadges:
  • philpl1jb
    Sounds like you are getting to the outfile..which has the journalling details and then a long field which contains the actual data. Make a new file which contains the journalling details followed by all the fields in your original file.  Then copy the outfile to this newfile file with format *nochk you will have the data as it was.  That's what the command Charlie Browne suggested does.  Then you can do anything you want with the new file.
    54,090 pointsBadges:
  • philpl1jb
    If you have TAATOOL on your system, I believe it contains a similar command.
    54,090 pointsBadges:
  • TomLiotta

    I put a basic REXX proc together overnight that should work for many journaled files. Put it into a QREXSRC source member with type REXX. Run it with STRREXPRC, or PDM member option 16, and specify [ lib/file ] for the REXX proc parameter:

    /* Show basic journal entries for LIB/FILE                             */
    parse arg inparm
    qfile = translate( inparm )
       /* */
    parse var qfile part1 '/' part2
    if part2 = '' then
          lib = '*LIBL     '
          file = substr( part1, 1, 10 )
          lib = substr( part1, 1, 10 )
          file = substr( part2, 1, 10 )
       /* */
    qfile = (file)(lib)
       /* */
    fd = Copies('00'x, 1024)
       /* */
         "call QSYS/QDBRTVFD ( ",
                               " &fd              ",
                               " x'00000400'      ",
                               " '                    ' ",
                               " 'FILD0100'       ",
                               " &qfile           ",
                               " '*FIRST    '     ",
                               " '0'              ",
                               " '*LCL      '     ",
                               " '*EXT      '     ",
                               " x'0000000000000000' ",
                            ")                   "
       /* */
    /* Extract journal info...                             */
    xfd    = c2x( fd )
    ofsjrn = x2d( substr( xfd, 757, 8 ) ) + 1
    qjrn   = substr(  fd, ofsjrn, 20 )
    jrn    = substr(  qjrn, 1, 10 )
    jlib   = substr(  qjrn, 11, 10 )
       /* */
    'crtdupobj   QADSPJR4  QSYS  *file  QTEMP  MyDSPJRN4'
    'addpfm      QTEMP/MyDSPJRN4  mbr( MyMbr4 )'
       /* */
    /* Display journal entries into temp file...           */
    'dspjrn      'strip( jlib )'/'strip( jrn ) ,
                 ' file(( 'strip( lib )'/'strip( file )' )) ' ,
                 ' rcvrng( *CURRENT ) ' ,
                 ' enttyp( ' ,
                         ' BR DL DR PT PX UB ' ,
                         ' UP UR ' ,
                       ' ) ' ,
                 ' output( *OUTFILE ) outfilfmt( *TYPE4 ) ' ,
                 ' outfile( QTEMP/MYJRNOUT4 ) ' ,
                 ' entdtalen( *CALC ) '
       /* */
    address '*EXECSQL' execsql ,
            ' SELECT JOENTL, JOSEQN, JOCODE, ' ,
            ' JOENTT, JOTSTP, JOJOB, JOUSER, ' ,
            ' JONBR, JOPGM, JOOBJ, JOLIB, JOMBR, ' ,
            ' JOCTRR, JOFLAG, JOCCID, JOUSPF, ' ,
            ' JOSYNM, JOJID, JORCST, JOTGR, ' ,
            ' JORES, JONVI ' ,
            ' FROM QTEMP/mydspjrn4 '
       /* */
    address '*EXECSQL' execsql ,
            'CREATE TABLE QTEMP/MyDATA4  AS (' ,
               'select a.*, b.* from QTEMP/MyDSPJRN4V a,' ,
                strip( lib )'/'strip( file )' b ) WITH NO DATA'
    address '*EXECSQL' execsql 'COMMIT'
       /* */
    /* Do an image-copy of the displayed entries into our  */
    /* fully described format...                           */
    'cpyf        fromfile( QTEMP/MYJRNOUT4 ) ' ,
               ' tofile( QTEMP/MyDATA4 ) ' ,
                 ' mbropt( *REPLACE ) ' ,
                 ' fmtopt( *NOCHK ) '
       /* */
    address '*EXECSQL' execsql ,
            'UPDATE  QTEMP/MyDATA4 ' ,
               'set JOJID = ''        '' ' ,
               'with NC'
       /* */
    /* Now view the fully-described entries... */ 'runqry *n QTEMP/MyDATA4 ' /* */ /*CleanUp: */ address '*EXECSQL' execsql , 'DROP VIEW QTEMP/MYDSPJRN4V ' address '*EXECSQL' execsql 'COMMIT' 'dltf QTEMP/MyDSPJRN4 ' address '*EXECSQL' execsql , 'DROP TABLE QTEMP/MyDATA4 ' 'dltf QTEMP/MYJRNOUT4 ' /* */ exit

    The result should be a list of journal entries for the LIB/FILE that you specified. Each entry should show both the journal entry header fields and the formatted file fields.


    Copy and paste the code into a text file in your home directory using Notepad. Use CPYFRMSTMF to copy from your home directory into a QREXSRC source member.


    The biggest problem will probably be that this editor messes up leading and trailing apostrophes (and possibly leading & trailing double-quotes). After I paste code from here into Notepad, I find one of the messed up leading apostrophes and paste into a Find & Replace box. Then I put an apostrophe into the .Replace field and click [Replace All]. I then do the same thing for a trailing apostrophe. Once all are replaced, that's when I save it into my IFS home directory. (Double-quotes might need the same treatment.)


    After it's in a source member and opened in SEU, any oddly translated characters usually show up on an emulator screen because they mess with display attributes. You can type over those characters with corrections in SEU, but it's easier when I do it in Notepad first.


    This REXX should work on essentially every AS/400 or iSeries or System i, regardless of whatever products you have installed, with one possible exception. There is one [CREATE TABLE AS <result set>] statement that might need a more recent OS version. I can't recall when the <result set> option was added, but it was quite a while ago.


    The proc runs on my 6.1 system and one of my V5R3 systems. It's not sophisticated enough to handle errors, but that's a good learning exercise for REXX coders. I could supply a generic REXX error proc if I took more time.


    If anyone wants to, it can be converted to CL. If you have any kind of RUNSQL command that runs dynamic SQL, the conversion would be easy. I did this in REXX because it runs SQL natively without any added requirements (except your system has to be newer than approximately V2R1).



    125,585 pointsBadges:
  • TomLiotta
    The editor here seems to be acting up badly today, so I put a copy of the previous REXX utility up at for reasonable copying. It should be available there for the next month. At least it allows copy & paste without changing characters, and blank lines can exist in code areas. -- Tom
    125,585 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: