星期三, 11月 08, 2023

2011-01-04 如何將 WRKOUTQ 輸出至 data base file 中(CVTOUTQ)


如何將 WRKOUTQ 輸出至 data base file 中(CVTOUTQ) 

File  : QDDSSRC
Member: CVTOUTQP
Type  : PF
Usage : CRTPF CVTOUTQP

     A* Out file used by CVTOUTQ command - OUTQP file
     A          R SPLREC
     A            SPOUTQ        10          COLHDG('Output' 'queue' +
     A                                      'name')
     A            SPOQLB        10          COLHDG('Output' 'queue' +
     A                                      'library')
     A            SPCVTD         6          COLHDG('WRKOUTQ' +
     A                                      'convert' 'date')
     A            SPCVTT         6          COLHDG('WRKOUTQ' +
     A                                      'convert' 'time')
     A            SPFILE        10          COLHDG('Spool' 'file' +
     A                                      'name')
     A            SPUSER        10          COLHDG('User name')
     A            SPUDTA        10          COLHDG('User data')
     A            SPSTS          3          COLHDG('Spool' 'file' +
     A                                      'status')
     A            SPNREC         6  0       COLHDG('Nbr of' +
     A                                      'diskette' 'records')
     A            SPNPAG         9  0       COLHDG('Nbr of' 'pages')
     A            SPWRTP         9  0       COLHDG('Page' 'being' +
     A                                      'written')
     A            SPSTRP         9  0       COLHDG('Start' 'page')
     A            SPENDP         9  0       COLHDG('End' 'page')
     A            SPLSTP         9  0       COLHDG('Last' 'page')
     A            SPRESP         9  0       COLHDG('Restart' 'page')
     A            SPCPY          9  0       COLHDG('Nbr' 'of' 'copies')
     A            SPCPYL         9  0       COLHDG('Copies' 'left to' +
     A                                      'print')
     A            SPFTYP        10          COLHDG('Form type')
     A            SPPTY          1          COLHDG('Spool' 'file' +
     A                                      'pty')
     A            SPFNBR         6          COLHDG('Spool' 'file' +
     A                                      'number')
     A            SPJNAM        10          COLHDG('Job name')
     A            SPJNBR         6          COLHDG('Job' 'number')
     A            SPCEN          1          COLHDG('Spool' 'file' +
     A                                      'century')
     A                                      TEXT('Spool file open +
     A                                      century')
     A            SPDAT          6          COLHDG('Spool' 'file' +
     A                                      'date')
     A                                      TEXT('Spool file open +
     A                                      date YYMMDD')
     A            SPTIM          6          COLHDG('Spool' 'file' +
     A                                      'time')
     A                                      TEXT('Spool file open +
     A                                      time')
     A            SPSCHD        10          COLHDG('Schedule')
     A            SPHOLD        10          COLHDG('Hold')
     A            SPSAVF        10          COLHDG('Save' 'file')
     A            SPLPI          9  1       COLHDG('LPI')
     A            SPCPI          9  1       COLHDG('CPI')
     A            SPACGC        15          COLHDG('Accounting' +
     A                                      'code')
     A            SPDEV         10          COLHDG('Device' 'file' +
     A                                      'name')
     A            SPDEVL        10          COLHDG('Device' 'file' +
     A                                      'library')
     A            SPPGM         10          COLHDG('Program' 'that' +
     A                                      'opened')
     A            SPPGML        10          COLHDG('Pgm lib' 'that' +
     A                                      'opened')
     A            SPPRTX        30          COLHDG('Print' 'text')
     A            SPPAGL         9  0       COLHDG('Page' 'length')
     A            SPPAGW         9  0       COLHDG('Page' 'width')
     A            SPNSEP         9  0       COLHDG('Nbr or' +
     A                                      'separators')
     A            SPOFLN         9  0       COLHDG('Overflow' 'line')
     A            SPFONT        10          COLHDG('Font')
     A            SPPGRT         9  0       COLHDG('Page' 'rotation')
     A            SPJUST         9  0       COLHDG('Page' +
     A                                      'justification')
     A            SPBOTH        10          COLHDG('Print' 'on both' +
     A                                      'sides')
     A            SPFOLD        10          COLHDG('Fold')
     A            SPALGN        10          COLHDG('Alignment')
     A            SPPQTY        10          COLHDG('Print' 'quality')
     A            SPPFID        10          COLHDG('Print' 'fidelity')
     A            SPRLEN         9  0       COLHDG('Record' +
     A                                      'length')
     A            SPMAXR         9  0       COLHDG('Maximum' +
     A                                      'record')
     A            SPSRCD         9  0       COLHDG('Source' 'drawer')
     A            SPDEVT        10          COLHDG('Device' 'type')
     A            SPPRTT        10          COLHDG('Printer' 'type')
     A            SPDOC         12          COLHDG('Document' 'name')
     A            SPFLDR        64          COLHDG('Folder' 'name')
     A            SPCDEP        10          COLHDG('Code' 'page')
     A            SPGRST        10          COLHDG('Graphic' 'set')
     A            SPDUPX        10          COLHDG('Duplex')
     A            SPCTLC        10          COLHDG('Control' 'char')
     A          K SPFILE



File  : QRPGLESRC
Member: CVTOUTQR
Type  : RPGLE
Usage : CRTBNDRPG PGM(CVTOUTQR) TGTRLS(V5R1M0)
        Target release must be V5R1 later for free format.        

     H**************************************************************
     H*
     H*   FUNTION: THIS APPLICATION WILL DELETE OLD SPOOLED FILES
     H*            FROM THE SYSTEM, BASED ON THE INPUT PARAMETERS.
     H*
     H*   API USED: QUSCRTUS  CREATE USER SPACE
     H*             QUSLSPL   GENERATE SPOOLED FILE LIST
     H*             QUSRTVUS  RETRIEVE USER SPACE INFORMATION
     H*             QUSRSPLA  RETRIEVE SPOOLED FILE ATR INFORMATION
     H*

     H DEBUG  OPTION(*SRCSTMT:*NODEBUGIO)
     FCVTOUTQP  UF A E           K Disk

     D CvtOutqR        PR                  ExtPgm('CVTOUTQR')
     D  sOutq                        20A   CONST

     D CvtOutqR        PI
     D  sOutq                        20A   CONST

     D RunCLCmd        PR                  EXTPGM('QCMDEXC')
     D  CmdStr                      512    CONST OPTIONS(*VARSIZE)
     D  CmdLen                       15  5 CONST

     D SndPgmMsg       PR                  ExtPgm( 'QMHSNDPM' )
     D  MsgID                         7
     D  QualMsgF                     20
     D  MsgDta                      256
     D  MsgDtaLen                    10I 0
     D  EscMsgType                   10
     D  CallStkEnt                   10
     D  CallStkCnt                   10I 0
     D  MsgKey                        4
     D  Error                         8

     D RcvPgmMsg       PR                  ExtPgm( 'QMHRCVPM' )
     D  MsgDta                      256
     D  MsgDtaLen                    10I 0
     D  MsgFormat                     8
     D  CallStkEnt                   10
     D  CallStkCnt                   10I 0
     D  MsgType                      10
     D  MsgKey                        4
     D  MsgWait                      10I 0
     D  MsgAction                    10
     D  Error                         8

      * SndMsg Parameter declare
     D QualMsgF        DS
     D  MsgFName                     10    Inz( 'QCPFMSG' )
     D  MsgFLib                      10    Inz( 'QSYS' )

     D MsgID           s              7    inz('CPF9898')
     D MsgDta          S            256
     D MsgType         S             10    Inz( '*COMP')
     D MsgDtaLen       S             10I 0 Inz(512)
     D CallStkEnt      S             10    Inz( '*' )
     D CallStkCnt      S             10I 0 Inz( 2 )
     D MsgKey          S              4    Inz(*blanks)
     D MsgError        S              8    Inz( *AllX'00' )
      * MSGTYPE  ENT  CallStkcnt      Joblog  End(line 24) X:message N: No Message
      * INFO      *    2                 XX    X
      * COMP      *    2                 XX    X
      * INFO      *    1                 X     N
      * COMP      *    1                 X     N
      * INFO      *    0                 X     N
      * COMP      *    0                 X     N
      * STATUS    *    2                 Error Error
      * STATUS    *    1                 N     N
      * STATUS    *    0                 N     N

      * RcvMsg Parameter declare
     D  MsgFormat      s              8    inz('RCVM0100')
     D  RMsgType       S             10    Inz( '*LAST')
     D  MsgWait        s             10I 0 inz( 0 )
     D  MsgAction      s             10    inz('*OLD')
     D  CurrMsgStk     S             10I 0 inz( 0 )

      * API Error data structure
     DQUSEC            DS
     D QUSBPRV                       10I 0 Inz(%size(QUSEC))
     D QUSBAVL                       10I 0
     D QUSEI                          7
     D QUSERVED                       1
     D*MSGDTA                       256
     D*
      *
      * Parameter for Create User Space Begin
     D USRSPC          DS
     D  USNAME                 1     10    INZ('USRSPC    ')
     D  USLIB                 11     20    INZ('QTEMP     ')
      *
     D                 DS
     D  EXTATR                 1     10    INZ('QUSLSPL   ')
     D  USINIT                11     11    INZ(X'00')
     D  FMTNME                12     21    INZ('SPLF0100')
     D  FMTNM1                22     31    INZ('SPLA0100')
      *
     D                 DS
     D  USSIZE                       10I 0 INZ(640000)
      * Parameter for Create User Space End

      * Retrive User Space Entry data
     D RCVVAR          DS
     D  OFFSET                 1      4B 0
     D  NOENTR                 9     12B 0
     D  LSTSIZ                13     16B 0

      * Retrive User Space Spooled data
     D RCVAR1          DS
     D  USRNM1                 1     10
     D  OUTQNA                11     30
     D   OUTQ                 11     20
     D   OUTQL                21     30
     D  USRDT1                31     40
     D  FRMTY1                41     50
     D  IJOBID                51     66
     D  ISPLID                67     82

      * Spooled file Attributes parameter Begin
     D RCVAR2          DS
     D  BYTRTN                 1      4B 0
     D  BYTVAL                 5      8B 0
     D  JOBID                  9     24
     D  SPLFID                25     40
     D  JOBNAM                41     50
     D  USRNAM                51     60
     D  JOBNUM                61     66
     D  FILNAM                67     76
     D  FILNUM                77     80B 0
     D  FRMTYP                81     90
     D  USRDTA                91    100
     D  STATUS               101    110
     D  FILVAL               111    120
     D  HLDF                 121    130
     D  SAVF                 131    140
     D  TOTPAG               141    144B 0
     D  PAGWRT               145    148B 0
     D  STRPAG               149    152B 0
     D  ENDPAG               153    156B 0
     D  LASPAG               157    160B 0
     D  RESPRT               161    164B 0
     D  TOTCPY               165    168B 0
     D  CPYLFT               169    172B 0
     D  LPI                  173    176B 0
     D  CPI                  177    180B 0
     D  OUTPRI               181    182
     D  OUTQNM               183    192
     D  OUTQLB               193    202
     D  DATFOP               203    209
     D  DATCEN               203    203
     D  DATYR                204    205
     D  DATMTH               206    207
     D  DATDAY               208    209
     D  TIMFOP               210    215
     D  DEVFNA               216    225
     D  DEVFLB               226    235
     D  PGMOPF               236    245
     D  PGMOPL               246    255
     D  ACCCOD               256    270
     D  PRTTXT               271    300
     D  RCDLEN               301    304B 0
     D  MAXRCD               305    308B 0
     D  DEVCLS               309    318
     D  PRTTYP               319    328
     D  DOCNAM               329    340
     D  FLDNAM               341    404
     D  S36PRC               405    412
     D  PRTFID               413    422
     D  RPLUN                423    423
     D  RPLCHR               424    424
     D  PAGLEN               425    428B 0
     D  PAGWID               429    432B 0
     D  NUMSEP               433    436B 0
     D  OVRLIN               437    440B 0
     D  DBCSDA               441    450
     D  DBCSEC               451    460
     D  DBCSSO               461    470
     D  DBCSCR               471    480
     D  DBCSCI               481    484B 0
     D  GRAPHI               485    494
     D  CODPAG               495    504
     D  FORNAM               505    514
     D  FORLIB               515    524
     D  SRCDRW               525    528B 0
     D  PRTFON               529    538
     D  S36SPL               539    544
     D  PAGROT               545    548B 0
     D  JUSTIF               549    552B 0
     D  PRTBOT               553    562
     D  FLDRCD               563    572
     D  CTLCHR               573    582
     D  ALGFRM               583    592
     D  PRTQUA               593    602
     D  FRMFED               603    612
     D  VOLUME               613    683
     D  FLABID               684    700
     D  EXCTYP               701    710
     D  CHRCOD               711    720
     D  TOTRCD               721    724B 0
     D  PGPSID               725    728B 0
     D  FOVNAM               729    738
     D  FOVLIB               739    748
     D  FOVOFD               749    756P 5
     D  FOVOFA               757    764P 5
     D  BOVNAM               765    774
     D  BOVLIB               775    784
     D  BOVOFD               785    792P 5
     D  BOVOFA               793    800P 5
     D  UOM                  801    810
     D  PAGNAM               811    820
     D  PAGLIB               821    830
     D  LINSPC               831    840
     D  PNTSIZ               841    848P 5
      * Spooled file Attributes parameter End

      * Retrive User Space Parameter Begin
     D                 DS
     D  LENDTA                 1      4B 0
     D  STRPOS                 5      8B 0
     D  SPLF#                  9     12B 0
     D  RCVLE1                13     16B 0
     D  FIL#                  17     22
     D  RCVLE2                23     26B 0
      * Retrive User Space Parameter End

      * Work area variable
     D  WRKSTR         S            100
     D  RcvMsgId       S              7
      *
      *
     C*********************************************************
     C*
     C*       OPERABLE CODE STARTS HERE
     C*
     C*********************************************************
     C*
     C                   Eval      *InLR     = *On

     C*
     C*  CREATE USER SPACE USING TE PARAMETERS FROM THE CL COMMAND
     C*
     C                   Z-ADD     16            QUSBPRV
      *
     C                   CALL      'QUSCRTUS'
     C                   PARM                    USRSPC
     C                   PARM                    EXTATR
     C                   PARM                    USSIZE
     C                   PARM                    USINIT
     C                   PARM      '*ALL'        USAUTH           10            AUTHORITY
     C                   PARM      *BLANKS       USTEXT           50
     C                   PARM      '*YES'        USRPLC           10            REPLACE
     C                   PARM                    QUSEC
      *
     C*
     C*  FILL THE USER SPACE JUST CREATED WITH SPOOLED FILES AS
     C*  DEFINED IN THE CL COMMAND
     C*
     C                   CALL      'QUSLSPL'
     C                   PARM                    USRSPC
     C                   PARM                    FMTNME
     C                   PARM      '*ALL'        USRNME           10
     C                   PARM      sOUTQ         FULLOUTQ         20
     C                   PARM      '*ALL'        FRMTYP           10
     C                   PARM      '*ALL'        USRDTA           10
     C******************************************************
     C*
     C*          BEGINNING OF LOOP
     C*
     C******************************************************
     C*
     C*   YOU CAN USE QUSRTVUS API RETRIEVE USER SPACE ENTRY DATA
     C*
     C*****************************************************
     C*
     C                   Z-ADD     16            LENDTA
     C                   Z-ADD     125           STRPOS
     C*
     C                   CALL      'QUSRTVUS'
     C                   PARM                    USRSPC
     C                   PARM                    STRPOS
     C                   PARM                    LENDTA
     C                   PARM                    RCVVAR
     C*
     C* CHECK RCVVAR DATA STRUCTURE FOR NUMBER OF LIST ENTRIES,OFFSET
     C* TO LIST ENTRIES, AND SIZE OF EAC LIST ENTRY.
     C* INFORMATION NEEDED FOR TE QUSLSPL API IS CONTAINED WITHIN
     C* THE 164 BYTES OF FORMAT SPLF0100 LIST DATA SECTION
     C*
     C                   Z-ADD     OFFSET        STRPOS
     C                   ADD       1             STRPOS
     C                   Z-ADD     LSTSIZ        LENDTA
     C                   Z-ADD     164           RCVLE1
     C*                  Z-ADD     209           RCVLE2
     C                   Z-ADD     750           RCVLE2
     C                   Z-ADD     1             COUNT            15 0

     C                   eval      MsgDta = 'Total processing spooled files:' +
     C                             %char(NOENTR)
     C                   eval      MsgType = '*INFO'
     C                   ExSr      SndMsg

     C     COUNT         DOWLE     NOENTR
     C*
     C* RETRIEVE THE INFORMATION FROM THE USER SPACE ABOUT THE SPOOLED
     C* FILE.
     C*
     C                   CALL      'QUSRTVUS'
     C                   PARM                    USRSPC
     C                   PARM                    STRPOS
     C                   PARM                    LENDTA
     C                   PARM                    RCVAR1

     C                   TIME                    FULTIM           12 0
     C                   MOVEL     FULTIM        SPCVTT
     C                   MOVE      FULTIM        SPCVTD
     C                   MOVE      OUTQ          SPOUTQ
     C                   MOVE      OUTQL         SPOQLB

     C*
     C* NOW RETRIVE SPOOLED ATR USING THE INFORMATION IN THE
     C* USER SPACE , WHICH WAS RETRIVED BEFORE THIS COMMENT.
     C*
     C                   MOVE      IJOBID        JOBID
     C                   MOVE      ISPLID        SPLFID
     C                   MOVE      *BLANKS       JOBINF
     C                   MOVEL     '*INT'        SPLFNM           10
     C                   MOVE      *BLANKS       SPLF#
     C                   MOVEL     '*INT'        JOBINF           26
     C*
     C                   Reset                   QUSEC
     C                   CALL      'QUSRSPLA'
     C                   PARM                    RCVAR2
     C                   PARM                    RCVLE2
     C                   PARM                    FMTNM1
     C                   PARM                    JOBINF
     C                   PARM                    JOBID
     C                   PARM                    SPLFID
     C                   PARM                    SPLFNM
     C                   PARM                    SPLF#
     C                   PARM                    QUSEC

      * Call API No Error
     C                   If        QUSBAVL =  0

     C* CHECK RCVAR1 DATA STRUCTURE FOR DATA FILE OPENED.
     C*
     C     *CYMD0        TEST(DE)                DATFOP
     C                   If        NOT %ERROR
     C                   MOVE      JOBNAM        SPJNAM
     C                   MOVE      USRNAM        SPUSER
     C                   MOVE      JOBNUM        SPJNBR
     C                   MOVE      USRDTA        SPUDTA
     C                   MOVE      FRMTYP        SPFTYP
     C                   MOVE      FILNAM        SPFILE
     C                   Z-ADD     FILNUM        DEC6              6 0
     C                   MOVE      DEC6          SPFNBR
     C                   Z-ADD     TOTCPY        SPCPY
     C                   MOVE      CPYLFT        SPCPYL
     C                   MOVE      OUTPRI        SPPTY
     C                   MOVEL     FILVAL        SPSCHD
     C                   MOVEL     HLDF          SPHOLD
     C                   MOVEL     FLDRCD        SPFOLD
     C                   MOVE      DATFOP        SPDAT
     C                   MOVEL     DATFOP        SPCEN
     C                   MOVE      TIMFOP        SPTIM
     C                   MOVE      ACCCOD        SPACGC
     C                   MOVE      PRTTXT        SPPRTX
     C                   MOVE      DEVFNA        SPDEV
     C                   MOVE      DEVFLB        SPDEVL
     C                   MOVE      PGMOPF        SPPGM
     C                   MOVE      PGMOPL        SPPGML
     C                   Z-ADD     PAGLEN        SPPAGL
     C                   Z-ADD     PAGWID        SPPAGW
     C                   Z-ADD     TOTPAG        SPNPAG
     C                   Z-ADD     PAGWRT        SPWRTP
     C                   Z-ADD     STRPAG        SPSTRP
     C                   Z-ADD     ENDPAG        SPENDP
     C                   Z-ADD     LASPAG        SPLSTP
     C                   Z-ADD     RESPRT        SPRESP
     C                   Z-ADD     LPI           DEC9              9 0
     C                   MOVE      DEC9          SPLPI
     C                   Z-ADD     CPI           DEC9
     C                   MOVE      DEC9          SPCPI
     C                   Z-ADD     NUMSEP        SPNSEP
     C                   Z-ADD     OVRLIN        SPOFLN
     C                   MOVE      PRTFON        SPFONT
     C                   Z-ADD     PAGROT        SPPGRT
     C                   MOVE      PRTBOT        SPBOTH
     C                   Z-ADD     JUSTIF        SPJUST
     C                   MOVE      ALGFRM        SPALGN
     C                   MOVE      PRTQUA        SPPQTY
     C                   MOVE      PRTFID        SPPFID
     C                   Z-ADD     TOTRCD        SPNREC
     C                   Z-ADD     RCDLEN        SPRLEN
     C                   Z-ADD     MAXRCD        SPMAXR
     C                   Z-ADD     SRCDRW        SPSRCD
     C                   MOVE      DEVCLS        SPDEVT
     C                   MOVE      PRTTYP        SPPRTT
     C                   MOVE      DOCNAM        SPDOC
     C                   MOVE      FLDNAM        SPFLDR
     C                   MOVE      CODPAG        SPCDEP
     C                   MOVE      GRAPHI        SPGRST
     C                   MOVE      CTLCHR        SPCTLC
     C                   MOVE      FLDRCD        SPDUPX
     C* Special handling cases
     C*    Status in DS contains values like *READY. Change to 3 char
     C                   Select
     C                   when      STATUS = '*READY  '
     C                   move      'RDY'         SPSTS
     C                   when      STATUS = '*OPEN   '
     C                   MOVE      'OPN'         SPSTS
     C                   when      STATUS = '*CLOSED '
     C                   MOVE      'CLO'         SPSTS
     C                   when      STATUS = '*HELD   '
     C                   MOVE      'HLD'         SPSTS
     C                   when      STATUS = '*SAVED  '
     C                   MOVE      'SAV'         SPSTS
     C                   when      STATUS = '*WRITING'
     C                   MOVE      'WTR'         SPSTS
     C                   when      STATUS = '*PENDING'
     C                   MOVE      'PNS'         SPSTS
     C                   when      STATUS = '*PRINTER'
     C                   MOVE      'PRT'         SPSTS
     C                   EndSl
     C                   Write     SPLREC
     C                   EndIf

     C                   EndIf

     C*
     C* GO BACK AND PROCESS THE REST OF ENTRIES IN THE USER SPACE
     C*
     C                   ADD       LSTSIZ        STRPOS
     C                   ADD       1             COUNT
     C                   ENDDO
     C******************************************
     C*        END LOOP
     C******************************************
     C*

     C                   Eval      MsgDta = %Char(NoEntr)     +
     C                                      ' spooled files process ' +
     C                                      'completely'
     C                   eval      MsgType = '*COMP'

     C                   Exsr      SndMsg
      *  -------------------------------------------------------------
      *  - Subroutine.... SndMsg                                     -
      *  - Description... Send escape message when error is found    -
      *  -------------------------------------------------------------

     C     SndMsg        BegSr

     C                   Eval      MsgDtaLen = %Size( MsgDta )

     C                   CallP     SndPgmMsg( MsgID      :
     C                                        QualMsgF   :
     C                                        MsgDta     :
     C                                        MsgDtaLen  :
     C                                        MsgType    :
     C                                        CallStkEnt :
     C                                        CallStkCnt :
     C                                        MsgKey     :
     C                                        MsgError   )

     C                   EndSr



File  : QCLSRC
Member: CVTOUTQC
Type  : CLP
Usage : CRTCLPGM PGM(CVTOUTQC)

/*  ===============================================================  */
/*  = Command CvtOutq CPP                                         =  */
/*  = Description : Convert WRKOUTQ to a data base file           =  */
/*  ===============================================================  */
/*  = Date  : 2011/01/04                                          =  */
/*  = Author: Vengoal Chang                                       =  */
/*  ===============================================================  */
     Pgm        Parm(&FullOutQ &OutLib &OutMbr &Replace)

     Dcl        &FullOutq   *Char     20
     Dcl        &OutLib     *Char     10
     Dcl        &OutMbr     *Char     10
     Dcl        &Replace    *Char     4
     Dcl        &Outq       *Char     10
     Dcl        &OutqLib    *Char     10
     Dcl        &RtnObjLib  *Char     10

     MonMsg     CPF0000      *N        GoTo Error

     ChkObj     &OUTLIB/OUTQP OBJTYPE(*FILE)
     MonMsg     MsgId(CPF9801) exec(DO) /* No file */
           IF         (&OUTLIB *EQ '*LIBL') DO /* *LIBL was used */
             SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) +
                          MSGDTA('The OUTLIB cannot be *LIBL if no +
                          file exists') MSGTYPE(*ESCAPE)
           ENDDO      /* *LIBL was used */
           RtvObjD    OBJ(CVTOUTQ) OBJTYPE(*CMD) RTNLIB(&RtnObjLib)
           Cpyf       FromFile(&RtnObjLib/CVTOUTQP) +
                         ToFile(&OutLib/OUTQP) CrtFile(*YES)
           RNMM       File(&OutLib/OUTQP) Mbr(CVTOUTQP) +
                         NewMbr(OUTQP)
     EndDo      /* No file */

     ChkObj     &OutLib/OUTQP ObjType(*File) Mbr(&OutMbr)
     MonMsg     MsgId(CPF9815) EXEC(DO) /* No member */
           AddPfm     File(&OutLib/OUTQP) Mbr(&OutMbr)
     ENDDO      /* No member */

     ChgVar     &Outq %SST(&FullOutQ 1 10) /* Extract OUTQ */
     ChgVar     &OutQLib %SST(&FullOutQ 11 10) /* Extract */
     ChkObj     &OutQLib/&OutQ ObjType(*OUTQ)
     IF         (&OutQLib *EQ '*LIBL') DO /* *LIBL used */
           RtvObjD    Obj(&OutQLib/&OUTQ) ObjType(*OUTQ) +
                          RtnLib(&OutQLib)
     ENDDO      /* *LIBL used */

     IF         (&OutLib *EQ '*LIBL') DO /* *LIBL was used */
           RtvObjD    Obj(OUTQP) ObjType(*FILE) RtnLib(&OutLib)
     ENDDO      /* *LIBL was used */
     IF         (&Replace *EQ '*YES') DO /* Replace mbr */
           ClrPfM     File(&OutLib/OUTQP) MBR(&OutMbr)
     ENDDO      /* Replace mbr */

     SndPgmMsg  MsgId(CPF9898) Msgf(QCPFMSG) ToPgmQ(*EXT) +
                          MsgDta('Converting output queue ' *CAT +
                          &OutQ *TCAT ' in ' *CAT &OutQLib) +
                          MsgType(*STATUS)
     OvrDbf     CVTOUTQP ToFile(&OutLib/OUTQP) MBR(&OUTMBR)

     Call       CVTOUTQR (&FullOutQ)

     DltOvr     File(CVTOUTQP)

 Return:
     Return

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

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

 EndPgm:
     EndPgm



File  : QCMDSRC
Member: CVTOUTQ
Type  : CMD
Usage : CRTCMD CMD( CVTOUTQ )                                    
               PGM( CVTOUTQC )                                    
               SRCMBR( CVTOUTQ )

/*****************************************************************/
/*                                                               */
/* COMMAND NAME: CVTOUTQ                                         */
/*                                                               */
/* AUTHOR      : Vengoal Chang                                   */
/*                                                               */
/* DATE WRITTEN: 2011/01/04                                      */
/*                                                               */
/* DESCRIPTION : Convert WRKOUTQ to data base file               */
/*                                                               */
/* CVTOUTQC   *PGM    CLP      Command processing program        */
/* CVTOUTQR   *PGM    RPGLE    List spooled file entry to DB     */
/* CVTOUTQP   *FILE   PF       CVTOUTQ Outfile                   */
/*                                                               */
/*     CRTCMD CMD( CVTOUTQ )                                     */
/*            PGM( CVTOUTQC )                                    */
/*            SRCMBR( CVTOUTQ )                                  */
/*                                                               */
/*****************************************************************/
             CMD        PROMPT('Convert Output Queue to DB')
             PARM       KWD(OUTQ) TYPE(QUAL1) SNGVAL((*NONE)) MIN(1) +
                          PROMPT('Output queue')
             PARM       KWD(OUTLIB) TYPE(*NAME) DFT(*LIBL) +
                          SPCVAL((*LIBL)) EXPR(*YES) +
                          PROMPT('Library for OUTQP file')
             PARM       KWD(OUTMBR) TYPE(*NAME) LEN(10) DFT(OUTQP) +
                          EXPR(*YES) PROMPT('Member to receive output')
             PARM       KWD(REPLACE) TYPE(*CHAR) LEN(4) RSTD(*YES) +
                          DFT(*YES) VALUES(*YES *NO) +
                          PROMPT('Replace data in member')
 QUAL1:      QUAL       TYPE(*NAME) LEN(10) MIN(1) EXPR(*YES)
             QUAL       TYPE(*NAME) LEN(10) DFT(*LIBL) +
                          SPCVAL((*LIBL)) EXPR(*YES) +
                          PROMPT('Library name')





沒有留言: