星期四, 11月 09, 2023

2014-10-22 如何將指定的 audit journal reveiver journal entry 轉換至於 PF(Command CVTJRNE with API QjoRetrieveJournalEntries)


如何將指定的 audit journal reveiver journal entry 轉換至於 PF(Command CVTJRNE with API QjoRetrieveJournalEntries)

File  : QDDSSRC

Member: JRNRCVRP

Type  : PF

Usage : CRTPF JRNRCVRP        


     A          R JRNRCVR
     A            SYSNAM         8
     A            JRNSEQ        20S 0
     A            JRNCDE         1
     A            JRNENTTYP      2
     A            JRNENTDTS     20
     A            JOBNAM        10
     A            USRNAM        10
     A            JOBNBR         6
     A            PGMNAM        10
     A            PGMLIB        10
     A            OBJECT        30
     A            USRPRF        10
     A            RCVNAM        10
     A            RCVLIB        10
     A            ADRFAM         1
     A            RMTADR        16
     A            RMTPORT        5S 0
     A            ARMNBR         5S 0
     A            PGMLIBASP      5S 0
     A            PGMLIBASPD    10
     A            OBJNAMID       1
     A            OBJTYPE       10
     A            ENTDTALEN      5S 0
     A            JRNENTDTA   8192



File  : QRPGLESRC

Member: CVTJRNER

Type  : RPGLE

Usage : CRTBNDRPG CVTJRNER        


     **
     **  Program . . : CBX1042
     **  Description : Retreive journal entries - format RJNE0200
     **  Author  . . : Carsten Flensburg
     **  Published . : Club Tech iSeries Programming Tips Newsletter
     **  Date  . . . : July 24, 2003
     **
     **  Modified by : Vengoal Chang
     **  Modified date October 15, 2014
     **  Description : Convert journal entries to PF
     **
     **  Program summary
     **  ---------------
     **
     **  Journal and commit APIs:
     **    QjoRetrieveJournalEntries           Retrieves journal entries based on
     **                                        a variety of selection criteria.
     **
     **                                        The API provides a flexible and
     **                                        comprehensive interface to journal
     **                                        entries similar to - and also
     **                                        extending - the functions provided
     **                                        provided by journal CL commands
     **                                        like RCVJRNE and RTVJRNE.
     **
     **    QjoDeletePointerHandle              Deletes the specified pointer
     **                                        handle previously generated by the
     **                                        QjoRetrieveJournalEntries API.
     **
     **  Miscellaneous APIs:
     **    QWCCVTDT      Convert date and      Converts date and time values from
     **                  time format           one format to another, including a
     **                                        system timestamp of type *DTS to
     **                                        character format.
     **  C library function:
     **    tstbts        Test bits             Tests the bit value of the bit
     **                                        located with the bit offset
     **                                        parameter, bit 0 being the
     **                                        leftmost and 64k the maximum.
     **
     **
     **  Sequence of events:
     **    1. Initialization of the journal entry type selection criteria.
     **       A table describing the possible entry types is available here:
     **
     **       http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/rzaki/
     **         finder/rzakijournalfinderall.htm
     **
     **       All the journal entry selection records are optional - for
     **       each record not provided the default value is assumed.
     **       See API manual for the specific details.
     **
     **    2. The QjoRetrieveJournalEntries API is called until there are no
     **       more journal entries available for retrieval.
     **
     **    3. Each retrieved entry is processed - in this case written to
     **       the internally defined printer file.
     **
     **    4. The entry's timestamp is converted from system timestamp to
     **       character format prior to printing.
     **
     **    5. Some entry information is provided in the form of bit fields
     **       retrieved using a C library function.
     **
     **    6. If a pointer handle was returned by the API it is eventually
     **       deleted for housekeeping purposes.
     **
     **    7. After each call the continuation information returned in the
     **       entry header data - including continuation journal sequence
     **       number and receiver name - is used to offset the next entry
     **       retrieval correctly.
     **
     **
     **  Programmer's notes:
     **    Earliest release program will run:  V5R2
     **
     **
     **  Compile options:
     **
     **    CrtRpgMod Module( CVTJRNER ) DbgView( *LIST )
     **
     **    CrtPgm    Pgm( CVTJRNER )
     **              Module( CVTJRNER )
     **
     **
     **-- Header specifications:  --------------------------------------------**
     H Option( *SrcStmt )  BndDir( 'QC2LE' )  DatEdit( *DMY/ )
     H DFTACTGRP(*NO) Debug
     **-- Printer file:  -----------------------------------------------------**
     FJRNRCVRP  O    E             Disk
     **-- Printer file information:  -----------------------------------------**
     D PrtLinInf       Ds
     D  PlOvfLin                      5i 0  Overlay( PrtLinInf: 188 )
     D  PlCurLin                      5i 0  Overlay( PrtLinInf: 367 )
     D  PlCurPag                      5i 0  Overlay( PrtLinInf: 369 )
     **-- System information:  -----------------------------------------------**
     D                SDs
     D  PsPgmNam         *Proc
     **-- API error data structure:  -----------------------------------------**
     D ApiError        Ds
     D  AeBytPrv                     10i 0 Inz( %Size( ApiError ))
     D  AeBytAvl                     10i 0
     **-- Global variables:  -------------------------------------------------**
     D Idx             s             10i 0
     D EntDta          s           8192a   Varying
     **
     D Time            s              6s 0
     D NbrRcds         s             10u 0
     D JrnEntDts       s             20a   Inz( *All'0' )
     D*JrnDta          s             24a
     D JrnDta          s             70a
     **-- Retrieve journal entry data:  --------------------------------------**
     D JeRcvVar        Ds                  Align
     D  JhJrnHdr
     D   JhBytRtn                    10i 0 Overlay( JhJrnHdr: 1 )
     D   JhOfsHdrJrnE                10i 0 Overlay( JhJrnHdr: *Next )
     D   JhNbrEntRtv                 10i 0 Overlay( JhJrnHdr: *Next )
     D   JhConInd                     1a   Overlay( JhJrnHdr: *Next )
     D   JhConRcvStr                 10a   Overlay( JhJrnHdr: *Next )
     D   JhConLibStr                 10a   Overlay( JhJrnHdr: *Next )
     D   JhConSeqNbr                 20s 0 Overlay( JhJrnHdr: *Next )
     D                               11a   Overlay( JhJrnHdr: *Next )
     D  JeData                    32754a
     **-- Entry header:
     D JeEntHdr        Ds                  Based( pEntHdr )
     D  JeOfsHdrJrnE                 10u 0
     D  JeOfsNulValI                 10u 0
     D  JeOfsEntDta                  10u 0
     D  JeOfsTrnId                   10u 0
     D  JeOfsLglUoW                  10u 0
     D  JeOfsRcvInf                  10u 0
     D  JeSeqNbr                     20u 0
     D  JeTimStp                     20u 0
     D  JeTimStpC                     8a   Overlay( JeTimStp )
     D  JeThrId                      20u 0
     D  JeSysSeqNbr                  20u 0
     D  JeCntRrn                     20u 0
     D  JeCmtCclId                   20u 0
     D  JePtrHdl                     10u 0
     D  JeRmtPort                     5u 0
     D  JeArmNbr                      5u 0
     D  JePgmLibAsp                   5u 0
     D  JeRmtAdr                     16a
     D  JeJrnCde                      1a
     D  JeEntTyp                      2a
     D  JeJobNam                     10a
     D  JeUsrNam                     10a
     D  JeJobNbr                      6a
     D  JePgmNam                     10a
     D  JePgmLib                     10a
     D  JePgmLibAspDv                10a
     D  JeObject                     30a
     D  JeUsrPrf                     10a
     D  JeJrnId                      10a
     D  JeAdrFam                      1a
     D  JeSysNam                      8a
     D  JeIndFlg                      1a
     D  JeObjNamInd                   1a
     D  JeBitFld                      1a
     D  JeObjTyp                     10a
     D  JeRsv                         3a
     **
     ** JeBitFld:
     D                 Ds
     D   JbRefCst                     1s 0
     D   JbTrg                        1s 0
     D   JbIncDta                     1s 0
     D   JbIgnApyRmvJ                 1s 0
     D   JbMinEntDta                  1s 0
     D   JbFilTypInd                  1s 0
     D   JbMinFldBnd                  1s 0
     D   JbRsv                        3a
     **-- Null values - *VARLEN:
     D JeNulValVar     Ds                  Based( pNulVal )
     D  JnNulValLen                  10i 0
     D  JnNulValIndV                512a
     **-- Null values - length:
     D JeNulValLen     Ds                  Based( pNulVal )
     D  JnNulValIndL                512a
     **-- Entry data:
     D JeEntDta        Ds                  Based( pEntDta )
     D  JdEntDtaLen                   5s 0
     D                               11a
     D  JdEntDta                   8192a
     **-- Logical unit of work:
     D JeLglUoW        Ds                  Based( pLglUow )
     D  JuLglUoW                     39a
     **-- Receiver information:
     D JeRcvInf        Ds                  Based( pRcvInf )
     D  JrRcvNam                     10a
     D  JrRcvLib                     10a
     D  JrRcvLibAspDv                10a
     D  JrRcvLibAspNb                 5i 0
     **
     **-- Retrieve journal entry selection records:  -------------------------**
     D JrnEntRtv       Ds
     D  JeNbrVarRcd                  10i 0
     **-- RCVRNG - *CURRENT, *CURCHAIN
     D JrnVarR01       Ds
     D  JvR01RcdLen                  10i 0 Inz( %Size( JrnVarR01 ))
     D  JvR01Key                     10i 0 Inz( 1 )
     D  JvR01DtaLen                  10i 0 Inz( %Size( JvR01Dta ))
     D  JvR01Dta                     40a   Inz( '*CURCHAIN' )
     D   JvR01RcvStr                 10a   Overlay( JvR01Dta: 1 )
     D   JvR01LibStr                 10a   Overlay( JvR01Dta: *Next )
     D   JvR01RcvEnd                 10a   Overlay( JvR01Dta: *Next )
     D   JvR01LibEnd                 10a   Overlay( JvR01Dta: *Next )
     **-- FROMENT - *FIRST
     D JrnVarR02       Ds
     D  JvR02RcdLen                  10i 0 Inz( %Size( JrnVarR02 ))
     D  JvR02Key                     10i 0 Inz( 2 )
     D  JvR02DtaLen                  10i 0 Inz( %Size( JvR02Dta ))
     D  JvR02Dta                     20a   Inz( '*FIRST' )
     D  JvR02SeqNbr                  20s 0 Overlay( JvR02Dta )
     **-- FROMTIME
     D JrnVarR03       Ds
     D  JvR03RcdLen                  10i 0 Inz( %Size( JrnVarR03 ))
     D  JvR03Key                     10i 0 Inz( 3 )
     D  JvR03DtaLen                  10i 0 Inz( %Size( JvR03Dta ))
     D  JvR03Dta                     26a
     **-- TOENT - *LAST
     D JrnVarR04       Ds
     D  JvR04RcdLen                  10i 0 Inz( %Size( JrnVarR04 ))
     D  JvR04Key                     10i 0 Inz( 4 )
     D  JvR04DtaLen                  10i 0 Inz( %Size( JvR04Dta ))
     D  JvR04Dta                     20a   Inz( '*LAST' )
     **-- TOTIME
     D JrnVarR05       Ds
     D  JvR05RcdLen                  10i 0 Inz( %Size( JrnVarR05 ))
     D  JvR05Key                     10i 0 Inz( 5 )
     D  JvR05DtaLen                  10i 0 Inz( %Size( JvR05Dta ))
     D  JvR05Dta                     26a
     **-- NBRENT
     D JrnVarR06       Ds
     D  JvR06RcdLen                  10i 0 Inz( %Size( JrnVarR06 ))
     D  JvR06Key                     10i 0 Inz( 6 )
     D  JvR06DtaLen                  10i 0 Inz( %Size( JvR06Dta ))
     D  JvR06Dta                     10i 0 Inz( 1000 )
     **-- JRNCDE - *ALL, *CTL / *ALLSLT, *IGNFILSLT
     D JrnVarR07       Ds
     D  JvR07RcdLen                  10i 0 Inz( %Size( JrnVarR07 ))
     D  JvR07Key                     10i 0 Inz( 7 )
     D  JvR07DtaLen                  10i 0 Inz( %Size( JvR07Dta ))
     D  JvR07Dta
     D   JcNbrCod                    10i 0 Overlay( JvR07Dta: 1 )
     D   JcJrnCod                    20a   Overlay( JvR07Dta: *Next )
     D                                     Dim( 16 )
     D    JcJrnCodVal                10a   Overlay( JcJrnCod: 1 )
     D    JcJrnCodSlt                10a   Overlay( JcJrnCod: *Next )
     **-- ENTTYP - *ALL, *RCD
     D JrnVarR08       Ds
     D  JvR08RcdLen                  10i 0 Inz( %Size( JrnVarR08 ))
     D  JvR08Key                     10i 0 Inz( 8 )
     D  JvR08DtaLen                  10i 0 Inz( %Size( JvR08Dta ))
     D  JvR08Dta
     D   JcNbrTyp                    10i 0 Overlay( JvR08Dta: 1 )
     D   JcEntTyp                    10a   Overlay( JvR08Dta: *Next )
     D                                     Dim( 16 )
     **-- JOB - *ALL
     D JrnVarR09       Ds
     D  JvR09RcdLen                  10i 0 Inz( %Size( JrnVarR09 ))
     D  JvR09Key                     10i 0 Inz( 9 )
     D  JvR09DtaLen                  10i 0 Inz( %Size( JvR09Dta ))
     D  JvR09Dta                     26a   Inz( '*ALL' )
     **-- PGM - *ALL
     D JrnVarR10       Ds
     D  JvR10RcdLen                  10i 0 Inz( %Size( JrnVarR10 ))
     D  JvR10Key                     10i 0 Inz( 10 )
     D  JvR10DtaLen                  10i 0 Inz( %Size( JvR10Dta ))
     D  JvR10Dta                     10a   Inz( '*ALL' )
     **-- USRPRF * *ALL
     D JrnVarR11       Ds
     D  JvR11RcdLen                  10i 0 Inz( %Size( JrnVarR11 ))
     D  JvR11Key                     10i 0 Inz( 11 )
     D  JvR11DtaLen                  10i 0 Inz( %Size( JvR11Dta ))
     D  JvR11Dta                     10a   Inz( '*ALL' )
     **-- CMTCYCID - *ALL
     D JrnVarR12       Ds
     D  JvR12RcdLen                  10i 0 Inz( %Size( JrnVarR12 ))
     D  JvR12Key                     10i 0 Inz( 12 )
     D  JvR12DtaLen                  10i 0 Inz( %Size( JvR12Dta ))
     D  JvR12Dta                     20a   Inz( '*ALL' )
     **-- DEPENT - *ALL, *NONE
     D JrnVarR13       Ds
     D  JvR13RcdLen                  10i 0 Inz( %Size( JrnVarR13 ))
     D  JvR13Key                     10i 0 Inz( 13 )
     D  JvR13DtaLen                  10i 0 Inz( %Size( JvR13Dta ))
     D  JvR13Dta                     10a   Inz( '*ALL' )
     **-- INCENT - *CONFIRMED, *ALL
     D JrnVarR14       Ds
     D  JvR14RcdLen                  10i 0 Inz( %Size( JrnVarR14 ))
     D  JvR14Key                     10i 0 Inz( 14 )
     D  JvR14DtaLen                  10i 0 Inz( %Size( JvR14Dta ))
     D  JvR14Dta                     10a   Inz( '*CONFIRMED' )
     **-- NULLINDLEN - *VARLEN
     D JrnVarR15       Ds
     D  JvR15RcdLen                  10i 0 Inz( %Size( JrnVarR15 ))
     D  JvR15Key                     10i 0 Inz( 15 )
     D  JvR15DtaLen                  10i 0 Inz( %Size( JvR15Dta ))
     D  JvR15Dta                     10a   Inz( '*VARLEN' )
     **-- FILE - *ALLFILE, *ALL
     D JrnVarR16       Ds
     D  JvR16RcdLen                  10i 0 Inz( %Size( JrnVarR16 ))
     D  JvR16Key                     10i 0 Inz( 16 )
     D  JvR16DtaLen                  10i 0 Inz( %Size( JvR01Dta ))
     D  JvR16Dta
     D   JcNbrFil                    10i 0 Overlay( JvR16Dta: 1 )
     D   JcFilNamQ                   30a   Overlay( JvR16Dta: *Next )
     D                                     Dim( 16 )
     D    JfFilNam                   10a   Overlay( JcFilNamQ: 1 )
     D    JfLibNam                   10a   Overlay( JcFilNamQ: *Next )
     D    JfMbrNam                   10a   Overlay( JcFilNamQ: *Next )
     **-- Retrieve journal entries:  -----------------------------------------**
     D RtvJrnE         Pr                  ExtProc( 'QjoRetrieveJournalEntries')
     D  RjRcvVar                  32767a          Options( *VarSize )
     D  RjRcvVarLen                  10i 0 Const
     D  RjJrnNamQ                    20a   Const
     D  RjRcvInfFmt                   8a   Const
     D  RjSltInf                  32767a   Const  Options( *NoPass: *VarSize )
     D  RjError                   32767a          Options( *NoPass: *VarSize )
     **-- Delete pointer handle:  --------------------------------------------**
     D DltPtrHdl       Pr                  ExtProc( 'QjoDeletePointerHandle' )
     D  DhPtrHdl                     10u 0 Const
     D  DhError                   32767a          Options( *NoPass: *VarSize )
     **-- Test bit in string:  -----------------------------------------------**
     D tstbts          Pr            10i 0 ExtProc( 'tstbts' )
     D  String                         *   Value
     D  BitOfs                       10u 0 Value
     **-- Convert date & time:  ----------------------------------------------**
     D CvtDtf          Pr                  ExtPgm( 'QWCCVTDT' )
     D  CdInpFmt                     10a   Const
     D  CdInpVar                     17a   Const  Options( *VarSize )
     D  CdOutFmt                     10a   Const
     D  CdOutVar                     17a          Options( *VarSize )
     D  CdError                      10i 0 Const
     **-- Convert IP address to xxx.xxx.xxx.xxx format -----------------------**
     D INET_NTOA       PR              *   EXTPROC('inet_ntoa')
     D  INTERNET_ADDR                10U 0 VALUE

     D IPADR           DS             4
     D  SIN_ADR                      10U 0

      *Array for contain EntTyp
     D EntTypAry       S              2    Dim(50)
     D EntTypAryDs     DS
     D  EntTypSiz                     4B 0
     D  EntTypAryTmp                  2    Dim(50)
     **--                                                                   --**
     D CVTJRNER        Pr
     D  RCVRNAME                     10a   Const
     D  RCVRLIB                      10a   Const
     D  ENTTYPDS                    102a   Const
     D CVTJRNER        Pi
     D  RCVRNAME                     10a   Const
     D  RCVRLIB                      10a   Const
     D  ENTTYPDS                    102a   Const
     **
     **-- Mainline:  ---------------------------------------------------------**
     **
     C                   Eval      *InLr       = *On
     **-- Setup entry type selection criteria - replace values and number
     **-- of values if applicable for your test purposes:
     C                   Eval      JvR01RcvStr = RCVRNAME
     C                   Eval      JvR01LibStr = RCVRLIB
     C                   Eval      JvR01RcvEnd = RCVRNAME
     C                   Eval      JvR01LibEnd = RCVRLIB

     C                   Eval      EntTypAryDs = ENTTYPDS
     C                   For       idx = 1 to EntTypSiz
     C                   Eval      EntTypAry(idx) =  EntTypAryTmp(idx)
     C                   EndFor

     **
     **-- Replace journal name and library if appropriate for your
     **-- environment.  Journal selection entries can be added and
     **-- removed as necessary - just set JeNbrVarRcd accordingly:
     C                   Eval      JeNbrVarRcd = 2
     **
     C                   DoU       JhConInd    = '0'           Or
     C                             AeBytAvl    > *Zero
     **
     C                   CallP     RtvJrnE( JeRcvVar
     C                                    : %Size( JeRcvVar )
     C                                    : 'QAUDJRN   *LIBL '
     C                                    : 'RJNE0200'
     C                                    : JrnEntRtv  +
     C                                      JrnVarR01  +
     C                                      JrnVarR02
     C                                    : ApiError
     C                                    )
     **
     C                   If        AeBytAvl    = *Zero
     C                   Eval      pEntHdr     = %Addr( JeRcvVar ) +
     C                                           JhOfsHdrJrnE
     **
     C                   For       Idx = 1  to JhNbrEntRtv
     **
     C                   ExSr      PrcLstEnt
     **
     C                   If        JePtrHdl    > *Zero
     C                   CallP(e)  DltPtrHdl( JePtrHdl )
     C                   EndIf
     **
     C                   If        Idx         < JhNbrEntRtv
     C                   Eval      pEntHdr     = pEntHdr + JeOfsHdrJrnE
     C                   EndIf
     **
     C                   EndFor
     **
     C                   If        JhConInd    = '1'
     C                   Eval      JvR01RcvStr = JhConRcvStr
     C                   Eval      JvR01LibStr = JhConLibStr
     C*                  Eval      JvR01RcvEnd = '*CURRENT'
     C                   Eval      JvR02SeqNbr = JhConSeqNbr
     C                   EndIf
     C                   EndIf
     **
     C                   EndDo
     **
     C                   Eval      *InLr       = *On
     C                   Return
     **
     **-- Process list entry:  -----------------------------------------------**
     C     PrcLstEnt     BegSr
     **
     C                   Eval      JbRefCst     = tstbts( %Addr( JeBitFld ): 0 )
     C                   Eval      JbTrg        = tstbts( %Addr( JeBitFld ): 1 )
     C                   Eval      JbIncDta     = tstbts( %Addr( JeBitFld ): 2 )
     C                   Eval      JbIgnApyRmvJ = tstbts( %Addr( JeBitFld ): 3 )
     C                   Eval      JbMinEntDta  = tstbts( %Addr( JeBitFld ): 4 )
     C                   Eval      JbFilTypInd  = tstbts( %Addr( JeBitFld ): 5 )
     C                   Eval      JbMinFldBnd  = tstbts( %Addr( JeBitFld ): 6 )
     **
     C                   Eval      pEntDta      = pEntHdr + JeOfsEntDta
     C                   Eval      EntDta       = %SubSt( JdEntDta
     C                                                  : 1
     C                                                  : JdEntDtaLen
     C                                                  )


     **
     C                   If        JeOfsNulValI > *Zero
     C                   Eval      pNulVal      = pEntHdr + JeOfsNulValI
     C                   EndIf
     **
     C                   If        JeOfsLglUoW  > *Zero
     C                   Eval      pLglUow      = pEntHdr + JeOfsLglUoW
     C                   EndIf
     **
     C                   If        JeOfsRcvInf  > *Zero
     C                   Eval      pRcvInf      = pEntHdr + JeOfsRcvInf
     C                   EndIf
     **
     C                   Eval      JrnDta     =  EntDta

     C
     C     JeEntTyp      lookup    EntTypAry(1)                           99
     C                   If        EntTypAry(1) = '*A'  or
     C                             *In99 = *On
     **
     C                   CallP     CvtDtf( '*DTS'
     C                                   : JeTimStpC
     C                                   : '*YYMD'
     C                                   : JrnEntDts
     C                                   : 0
     C                                   )
     **
     C                   eval      SYSNAM = JeSysNam
     C                   eval      JRNSEQ = JeSeqNbr
     C                   eval      JRNCDE = JeJrnCde
     C                   eval      JRNENTTYP = JeEntTyp
     C                   eval      JOBNAM = JeJobNam
     C                   eval      USRNAM = JeUsrNam
     C                   eval      JOBNBR = JeJobNbr
     C                   eval      PGMNAM = JePgmNam
     C                   eval      PGMLIB = JePgmLib
     C                   eval      OBJECT = JeObject
     C                   eval      USRPRF = JeUsrPrf
     C                   eval      RCVNAM = JrRcvNam
     C                   eval      RCVLIB = JrRcvLib
     C                   eval      ADRFAM = JeAdrFam
     C                   If        JeRmtAdr = *ALLX'00'
     C                   eval      RMTADR = ' '
     C                   Else
     C                   eval      IPADR = %SubSt(JeRmtAdr:13:4)
     C                   eval      RMTADR  = %STR(INET_NTOA(SIN_ADR))
     C                   EndIf
     C                   eval      RMTPORT= JeRmtPort
     C                   eval      ARMNBR = JeArmNbr
     C                   eval      PGMLIBASP =JePgmLibAsp
     C                   eval      PGMLIBASPD=JePgmLibAspDv
     C                   eval      OBJNAMID  =JeObjNamInd
     C                   eval      OBJTYPE   =JeObjTyp
     C                   eval      ENTDTALEN = JdEntDtaLen
     C                   eval      JRNENTDTA = ENTDTA
     C                   write     JRNRCVR
     **
     C                   EndIf
     C                   EndSr


File  : QCLSRC

Member: CVTJRNEC

Type  : CLP

Usage : CRTCLPGM CVTJRNEC        


/*-------------------------------------------------------------------*/
/*                                                                   */
/*  Program . . : CVTJRNEC                                           */
/*  Description : Convert journal entry to PF                        */
/*  Author  . . : Vengoal Chang                                      */
/*  Published . : AS400ePaper                                        */
/*  Date  . . . : June 26, 2014                                      */
/*                                                                   */
/*  Program function:  CVTJRNE command processing program            */
/*                                                                   */
/*                                                                   */
/*  Program summary                                                  */
/*  ---------------                                                  */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*  Compile options:                                                 */
/*    CrtClPgm   Pgm( CVTJRNEC )                                     */
/*               SrcFile( QCLSRC )                                   */
/*               SrcMbr( *PGM )                                      */
/*                                                                   */
/*-------------------------------------------------------------------*/
     Pgm      ( &QualRcvr +
                &ToFile   +
                &EntTypDs +
              )

/*-- Parameters:  ---------------------------------------------------*/
     Dcl        &QualRcvr    *Char    20
     Dcl        &ToFile      *Char    20
     Dcl        &RcvrName    *Char    10
     Dcl        &RcvrLib     *Char    10
     Dcl        &RtnLib      *Char    10
     Dcl        &ToFileName  *Char    10
     Dcl        &ToFileLib   *Char    10
     Dcl        &EntTypDs    *Char    102
     Dcl        &NbrOfTypsC  *Char    2
     Dcl        &NbrOfTyps   *Dec     (2 0)

/*-- Global error monitoring:  --------------------------------------*/
     MonMsg     CPF0000      *N        GoTo Error

     ChgVar     &RcvrName    %SST(&QualRcvr  1 10)
     ChgVar     &RcvrLib     %SST(&QualRcvr 11 10)

     ChgVar     &ToFileName  %SST(&ToFile    1 10)
     ChgVar     &ToFileLib   %SST(&ToFile   11 10)

     ChgVar     &NbrOfTypsC  %SST(&EntTypDs 1  2)
     ChgVar     &NbrOfTyps   %BIN(&NbrOfTypsC)

     RtvObjD    Obj(&RcvrLib/&RcvrName)                  +
                ObjType(*JRNRCV)                         +
                RtnLib(&RtnLib)

     ChgVar     &RcvrLib     &RtnLib

     DltF       &ToFileLib/&ToFileName
     MonMsg     CPF0000

     CrtDupObj  Obj(JRNRCVRP)                            +
                FromLib(*LIBL)                           +
                ObjType(*FILE)                           +
                ToLib(&ToFileLib)                        +
                NewObj(&ToFileName)                      +
                Cst(*NO)                                 +
                Trg(*NO)

     OvrDbf     File(JRNRCVRP)                           +
                ToFile(&ToFileLib/&ToFileName)           +
                OvrScope(*JOB)

     Call       CVTJRNER   ( &RcvrName &RcvrLib &EntTypDs)

     DltOvr     File(JRNRCVRP) Lvl(*JOB)
 Return:
     Return

/*-- Error handling:  -----------------------------------------------*/
 Error:
     Call      QMHMOVPM    ( '    '                                  +
                             '*DIAG'                                 +
                             x'00000001'                             +
                             '*PGMBDY'                               +
                             x'00000001'                             +
                             x'0000000800000000'                     +
                           )

     Call      QMHRSNEM    ( '    '                                  +
                             x'0000000800000000'                     +
                           )

 EndPgm:
     EndPgm


File  : QCMDSRC

Member: CVTJRNE

Type  : CMD

Usage : CRTCMD  CMD(CVTJRNE) PGM(CVTJRNEC)        


/*-------------------------------------------------------------------*/
/*                                                                   */
/*  Command . . : CVTJRNE                                            */
/*  Description : Convert journal entry to PF                        */
/*  Author  . . : Vrngoal Chang                                      */
/*  Published . : AS400ePaper                                        */
/*  Date  . . . : June 26, 2014                                      */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*  Programmer's notes:                                              */
/*                                                                   */
/*                                                                   */
/*  Compile options:                                                 */
/*                                                                   */
/*    CrtCmd Cmd( CVTJRNE )                                          */
/*           Pgm( CVTJRNEC )                                         */
/*                                                                   */
/*-------------------------------------------------------------------*/
             Cmd        Prompt( 'Convert journal entry to PF' )

             Parm       JRNRCVR       Q0001                          +
                        Min( 1 )                                     +
                        Choice( *NONE )                              +
                        Prompt( 'Journal receiver' 1 )

             Parm       TOFILE        Q0002                          +
                        Min( 1 )                                     +
                        Choice( *NONE )                              +
                        Prompt('To data base file' 2)

             Parm       KWD(ENTTYP)                                  +
                        TYPE(*CHAR)                                  +
                        LEN(2)                                       +
                        DFT(*ALL)                                    +
                        SPCVAL((*ALL '*A'))                          +
                        MAX(50)                                      +
                        PROMPT('Journal entry types' 3)

 Q0001:      Qual                     *Name     10                   +
                        Min( 1 )                                     +
                        Expr( *YES )

             Qual       Type(*Name)                                  +
                        Len(10)                                      +
                        Dft(*LIBL)                                   +
                        SpcVal((*LIBL) (*CURLIB))                    +
                        Expr(*YES) +
                        Prompt('Library')

Q0002:       QUAL       TYPE(*NAME) +
                        LEN(10) +
                        MIN(1) +
                        EXPR(*YES)
             QUAL       TYPE(*NAME) +
                        LEN(10) +
                        DFT(*LIBL) +
                        SPCVAL( +
                          (*LIBL ) +
                          (*CURLIB '*CURLIB   ')) +
                        EXPR(*YES) +
                        PROMPT('Library')





沒有留言: