× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Peter Vidal wrote:

I need to develop a program that must be "shared", meaning that no matter
the *LIBL setup, if the files needed are present, the program should
process it.  In other words, this will be used for different production
environments.    However, I wanna to do things a little more complicated.
What I want to do is:

1) Do a DSPJRN of a file I am journaling and output the data to a work
file.
2) Run this program that will read my work file and output the data into a
database.

I need to do this 5 times because I am journaling 5 files and each file
has different record formats, fields and lengths.  I also need to write
the results on 5 different databases, each one corresponding to each work
file processed, with the same file naming convention as the file being
read, like for example: "ITEMAS" it will be "ITEMASJRN".

Summarizing, I was hoping that I can use just one simple RPGLE program
with EXTFILE and using data structures I would be able to accomplish this.
But before I start my endeavor for this solution, I wanted to throw the
ball to the court and see if somebody has some advise here.  It is easy to
do 5 programs, one per file, but I need to see if it is possible, what I
need to do.

Peter -

I have a crude process that I have built for a single file that could easily be enhanced and expanded to process journal entries for multiple files.

What I do is this:

1) Create DDS for the work file(s) having exactly the same fields names as the original journaled file, but I add several fields to the end of the DDS for journal-entry specific information (for my use when examining the data in the work file to determine who did what and when).

Example:

--------

Partial DDS of the file being journaled (File F4102):

0010.00       A          R I4102X
0011.00 A TEXT('Branch Master File + 0012.00 A ') 0013.00 A IBITM R REFFLD(ITM F98FRFI ) 0014.00 A IBLITM R REFFLD(LITM F98FRFL )
0015.00       A                                      CCSID(65535)
0016.00 A IBAITM R REFFLD(AITM F98FRFA )
0017.00       A                                      CCSID(65535)
0018.00 A IBMCU R REFFLD(MCU F98FRFM )
0019.00       A                                      CCSID(65535)

---------

Partial DDS of the work file (F4102X) where the journal image data will be written:

0010.00       A          R I4102X
0011.00 A TEXT('Branch Master File + 0012.00 A ') 0013.00 A IBITM R REFFLD(ITM F98FRFI ) 0014.00 A IBLITM R REFFLD(LITM F98FRFL )
0015.00       A                                      CCSID(65535)
0016.00 A IBAITM R REFFLD(AITM F98FRFA )
0017.00       A                                      CCSID(65535)
0018.00 A IBMCU R REFFLD(MCU F98FRFM )
0019.00       A                                      CCSID(65535)



* Additional fields - These fields are also defined in the outfile created by DSPJRN...

0226.00       A            JOENTT         2          COLHDG('Entry' 'Type')
0227.00       A            JOTSTP          Z         COLHDG('Time' 'Stamp')
0228.00       A            JOJOB         10          COLHDG('Job' 'Name')
0229.00       A            JOUSER        10          COLHDG('User' 'Name')
0230.00       A            JONBR          6S 0       COLHDG('Job' 'Number')
0231.00       A            JOPGM         10          COLHDG('Pgm' 'Name')
0232.00 A JOPGMLIB 10 COLHDG('Pgm' 'Library' 'Name')
0233.00       A            JOOBJ         10          COLHDG('Object' 'Name')
0234.00 A JOLIB 10 COLHDG('Object' 'Library' 'Name') 0235.00 A JOMBR 10 COLHDG('Name of' 'Member')

(These JO* fields give you information that allows you to determine what happened to which file and when)

For example:
JOESD  =  Journaled file record image (see usage in RPG program below)

JOENTT = 'PT' indicates a record was inserted into the journaled file
JOENTT = 'UB' is a before-update image of the record in the journaled file
JOENTT = UP' is an after-updated image of the record in the journaled file

JOOBJ = 'F4102' tells me that it is a journal entry from F4102
--------


2) Use DSPJRN to create an outfile of the journal entries for the file(s) (example below).

(This is necessary for compiling the rpg program the first time)

DSPJRN     JRN(*LIBL/JOURNAL) FILE((F4102)) +
             RCVRNG(*CURCHAIN)  +
            OUTPUT(*OUTFILE) +
             OUTFILFMT(*TYPE5) +
             OUTFILE(AUSLMPLIB/F4102JRN) ENTDTALEN(*CALC)


3) Create an RPG program that reads this outfile and writes the data to the workfile(s).

0001.00 ************************************************************************* 0002.00 * Program Name; P4102X * 0003.00 * Author: S. Landess * 0004.00 * Date: 27-May-2005 * 0005.00 * * 0006.00 * Purpose: Copy the data from the entry-specific data * 0007.00 * in the outfile created by the DSPJRN command * 0008.00 * to the F4102X work file. * 0009.00 * * 0010.00 ************************************************************************* 0011.00 *
0012.00  FF4102JRN  IF   E             DISK
0013.00  FF4102X    O    E             DISK
0014.00   *
0015.00 * This data structure is used to field the data from the journaled file record image (JOESD)...
0016.00   *
0017.00  D DS4102        E DS                  EXTNAME(F4102   )
0018.00   *
0019.00   *    Possible values for JOENTT:
0020.00   *      UB = Update, Before-Image
0021.00   *      UP = Update, After-Image
0022.00   *      PT = Record Written
0023.00   *
0024.00 C READ QJORDJE5 LR
0025.00  C     *INLR         DOWEQ     *OFF
0026.00   *
0027.00  C                   SELECT
0028.00  C     JOOBJ         WHENEQ    'F4102'
0029.00  C     JOENTT        IFEQ      'UB'
0030.00  C     JOENTT        OREQ      'UP'
0031.00  C     JOENTT        OREQ      'PT'
0032.00  C                   EXSR      S010
0033.00  C                   ENDIF
0034.00  C                   ENDSL
0035.00   *
0035.00   *
0036.00 C READ QJORDJE5 LR
0037.00  C                   ENDDO
0038.00   *
0039.00  C     S010          BEGSR
0040.00  C                   CLEAR                   DS4102
0041.00  C                   MOVEL     JOESD         DS4102
0042.00  C                   WRITE     I4102X
0043.00  C                   ENDSR
0044.00   *
0045.00  C     *INZSR        BEGSR
0046.00  C                   CLEAR                   DS4102
0047.00   *  For debugging purposes...
0048.00  C                   MOVE      JOENTT        JOENTT
0049.00  C                   MOVE      JOTSTP        JOTSTP
0050.00  C                   MOVE      JOJOB         JOJOB
0051.00  C                   MOVE      JOUSER        JOUSER
0052.00  C                   MOVE      JONBR         JONBR
0053.00  C                   MOVE      JOPGM         JOPGM
0054.00  C                   MOVE      JOPGMLIB      JOPGMLIB
0055.00  C                   MOVE      JOOBJ         JOOBJ
0056.00  C                   MOVE      JOLIB         JOLIB
0057.00  C                   MOVE      JOMBR         JOMBR
0058.00  C
0059.00  C                   ENDSR


4) Here is a CL program that I wrote to automate the running of the whole process:

           PGM        PARM(&JRN &JRNLIB &FROMDATE &FROMTIME)

           DCL        VAR(&JRN) TYPE(*CHAR) LEN(10)
           DCL        VAR(&JRNLIB) TYPE(*CHAR) LEN(10)
           DCL        VAR(&FROMDATE) TYPE(*CHAR) LEN(6)
           DCL        VAR(&FROMtime) TYPE(*CHAR) LEN(6)

           DSPJRN     JRN(&JRNLIB/&JRN) FILE((F4102)) +
                        RCVRNG(*CURCHAIN) FROMTIME(&FROMDATE +
                        &FROMTIME) OUTPUT(*OUTFILE) +
                        OUTFILFMT(*TYPE5) +
                        OUTFILE(AUSLMPLIB/F4102JRN) ENTDTALEN(*CALC)

           CALL       PGM(AUSLMPLIB/P4102X)

           ENDPGM

Hope this helps,
Steve Landess

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.