2007110516322007-11-05 如何將報表轉為 Text 或 Html 格式 ? (Command:CVTSPLSTMF)

如何將報表轉為 Text 或 Html 格式 ? (Command:CVTSPLSTMF)

此指令是將報表轉換為 Text 或 Html 格式,並可以轉換中文而且可將報表對齊,不過報表
中文控制碼(0E0F)要前後配對完整才可以,並將之存放在 IFS 目錄中,所以使用前須先建立
一個目錄,例如使用指令 MD '/spool' 建立一 spool 的目錄,使用 WRKLNK '/spool' ,並
選用 5 ,即可檢視該目錄內容:
===============================================================================
                            Work with Object Links                             
                                                                               
Directory  . . . . :   /                                                       
                                                                               
Type options, press Enter.                                                     
  2=Edit   3=Copy   4=Remove   5=Display   7=Rename   8=Display attributes     
  11=Change current directory ...                                              
                                                                               
Opt     Object link                                                            
 5      spool                                                                  
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                        Bottom 
Parameters or command                                                          
===>                                                                           
F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F12=Cancel   F17=Position to  
F22=Display entire field           F23=More options                            
===============================================================================
                            Work with Object Links                             
                                                                               
Directory  . . . . :   /spool                                                  
                                                                               
Type options, press Enter.                                                     
  2=Edit   3=Copy   4=Remove   5=Display   7=Rename   8=Display attributes     
  11=Change current directory ...                                              
                                                                               
Opt     Object link                                                            
        
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                        Bottom 
Parameters or command                                                          
===>                                                                           
F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F12=Cancel   F17=Position to  
F22=Display entire field           F23=More options                            
===============================================================================
使用CVTSPLSTMF 指令範例:

利用 AS/400 列印螢幕功能(HOST print),列印一份報表 QSYSPRT,在使用下列指令將
QSYSPRT 報表複製至目錄 /spool 中:

                    Convert Spool to Stream File (CVTSPLSTMF)                   
                                                                                
 Type choices, press Enter.                                                     
                                                                                
 From spooled file name . . . . . > QSYSPRT       Name                          
 To stream file name  . . . . . . > QSYSPRT.TXT                                 
                                                                                
 To directory . . . . . . . . . . > '/spool'                                    
                                                                                
 Job name . . . . . . . . . . . .   *             Name, *                       
   User . . . . . . . . . . . . .                 Name                          
   Number . . . . . . . . . . . .                 000000-999999                 
 Spooled file number  . . . . . . > *LAST         1-9999, *LAST, *ONLY          
 Stream file format . . . . . . .   *TEXT         *TEXT, *HTML                  
 Stream file option . . . . . . . > *REPLACE      *NONE, *REPLACE, *ADD         
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                         Bottom 
 F3=Exit   F4=Prompt   F5=Refresh   F10=Additional parameters   F12=Cancel      
 F13=How to use this display        F24=More keys                               
 ==============================================================================
此時使用 WRKLNK '/spool' ,按執行鍵,並使用選項 5,會得到下列畫面,使用選項 5,
可以檢視報表資料:
                             Work with Object Links                             
                                                                                
 Directory  . . . . :   /spool                                                  
                                                                                
 Type options, press Enter.                                                     
   2=Edit   3=Copy   4=Remove   5=Display   7=Rename   8=Display attributes     
   11=Change current directory ...                                              
                                                                                
 Opt     Object link                                                            
         QSYSPRT.TXT                                                            
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                         Bottom 
 Parameters or command                                                          
 ===>                                                                           
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F12=Cancel   F17=Position to  
 F22=Display entire field           F23=More options                            
 ==============================================================================
當轉換為一般文字檔後,可以使用 FTP 方式或 AS/400 NetServer 方式將目錄分享出來,
PC 端即可取得報表資料了。

有關 As/400(iSeries) NetServer 詳細資料請參照 
http://www-1.ibm.com/servers/eserver/iseries/netserver/



File  : QRPGLESRC
Member: CVTSPLSTMR
Type  : RPGLE
Usage : CRTBNDRPG CVTSPLSTMR     

      ******************************************************************
      *                                                                *
      * PROGRAM NAME: CVTSPLSTMR called by CVTSPLSTMC                  *
      *                                                                *
      * AUTHOR      : Vengoal Chang                                    *
      *                                                                *
      * DATE WRITTEN: March 2006                                       *
      *                                                                *
      * DESCRIPTION : Converts spooled file data in work file          *
      *               CvtSplWrk2 to HTML or TEXT format to work file   *
      *               CvtSplWrk1.                                      *
      *                                                                *
      * FUNCTIONS   : Adds basic HTML headings and footings and a      *
      *               title.                                           *
      *                                                                *
      * Copyright 2006 (c) Vengoal Chang.                              *
      * All rights reserved.                                           *
      *                                                                *
      ******************************************************************

     H  DFTACTGRP(*NO) Debug

     FCvtSplWrk2IF   F  382        DISK

     FCvtSplWrk1UF A F  378        DISK

      * Standard HTML header lines

     D aaHeader        S             80A   DIM(2) CTDATA PERRCD(1)

      * Standard HTML footer line

     D aaFooter        S             80A   DIM(1) CTDATA PERRCD(1)

      * Input spooled file data including control characters

     D InputData       DS
     D   saSkipLine                   3A
     D   ssSkipLine                   3S 0 OVERLAY(saSkipLine:1)
     D   saSpceLine                   1A
     D   ssSpceLine                   1S 0 OVERLAY(saSpceLine:1)
     D   saInput                    378A

      * Output HTML-format data

     D OutputData      DS
     D   saOutput                   378A

      * Program parameters - title and page length in lines

     D paToFmt         S              5A
     D paTitle         S             50A
     D piPageLen       S             10I 0

      * Line counter variable

     D wiLine          S             10I 0

      * Procedure prototypes

     D HTMLHeader      PR

     D HTMLFooter      PR

     D Convert         PR

     D Merge           PR                  LIKE(saOutput)
     D    iaOutput                         LIKE(saOutput)
     D    iaInput                          LIKE(saInput)

     D SpceLines       PR
     D    isSpceLine                       LIKE(ssSpceLine)

     D SkipLines       PR
     D    isSkipLine                       LIKE(ssSkipLine)

     D ParseInput      PR

      **********************************************************************
      * Program parameters

     C     *ENTRY        PLIST
     C                   PARM                    paToFmt
     C                   PARM                    paTitle
     C                   PARM                    piPageLen

      * Output HTML header lines

     C                   If        paToFmt = '*HTML'
     C                   CALLP     HTMLHeader
     C                   EndIf

      * Convert spool file lines to HTML or Text

     C                   EVAL      wiLine = 1
     C                   READ      CvtSplWrk2    InputData                LR
     C                   DOW       *INLR = *OFF
     C                   CALLP     ParseInput
     C                   CALLP     Convert
     C                   READ      CvtSplWrk2    InputData                LR
     C                   ENDDO

      * Output HTML footer lines

     C                   If        paToFmt = '*HTML'
     C                   CALLP     HTMLFooter
     C                   EndIf

     C                   RETURN

      **********************************************************************
      * Procedure to create HTML header lines                              *
      **********************************************************************

     P HTMLHeader      B

     D HTMLHeader      PI

     C                   EVAL      saOutput = aaHeader(1)
     C                   WRITE     CvtSplWrk1    OutputData

     C                   IF        paTitle <> '*NONE'
     C                   EVAL      saOutput   = '< TITLE>'
     C                                        + %trim(paTitle)
     C                                        + '</TITLE>'
     C                   WRITE     CvtSplWrk1    OutputData
     C                   ENDIF

     C                   EVAL      saOutput = aaHeader(2)
     C                   WRITE     CvtSplWrk1    OutputData

     P HTMLHeader      E

      **********************************************************************
      * Procedure to create HTML footer line                               *
      **********************************************************************

     P HTMLFooter      B

     D HTMLFooter      PI

     C                   EVAL      saOutput = aaFooter(1)
     C                   WRITE     CvtSplWrk1    OutputData

     P HTMLFooter      E

      **********************************************************************
      * Procedure to convert spooled file data to HTML text                *
      **********************************************************************

     P Convert         B

     D Convert         PI

      * If 'space' position is zero, 'overprint' previous line

     C                   IF        saSpceLine = '0'

     C     *HIVAL        SETGT     CvtSplWrk1
     C                   READP     CvtSplWrk1    OutputData               99
     C                   EVAL      saOutput = Merge(saOutput:saInput)
     C                   UPDATE    CvtSplWrk1    OutputData

     C                   ELSE

      * Skip to a line if specified

     C                   IF        saSkipLine <> *BLANKS
     C                   CALLP     SkipLines(ssSkipLine)
     C                   ENDIF

      * Space a number of lines if specified

     C                   IF        saSpceLine <> *BLANKS
     C                   CALLP     SpceLines(ssSpceLine)
     C                   ENDIF

      * 'Print' line

     C                   EVAL      saOutput   = saInput
     C                   WRITE     CvtSplWrk1    OutputData
     C                   EVAL      wiLine = wiLine + 1

     C                   ENDIF

     C                   RETURN

     P Convert         E

      **********************************************************************
      * Procedure to merge two overlaid lines of text                      *
      **********************************************************************

     P Merge           B

     D Merge           PI                  LIKE(saOutput)
     D    iaOutput                         LIKE(saOutput)
     D    iaInput                          LIKE(saInput)

     D laOutput        S                   LIKE(saOutput)

     D i               S              5I 0

     C                   EVAL      i = 1
     C                   DOW            i <= %size(iaInput )
     C                             and  i <= %size(iaOutput)
     C                             and  i <= %size(laOutput)
     C                   IF        %subst(iaInput:i:1) = *BLANK
     C                   EVAL      %subst(laOutput:i:1) = %subst(iaOutput:i:1)
     C                   ELSE
     C                   EVAL      %subst(laOutput:i:1) = %subst(iaInput :i:1)
     C                   ENDIF
     C                   EVAL      i = i + 1
     C                   ENDDO

     C                   RETURN    laOutput

     P Merge           E

      **********************************************************************
      * Procedure to skip to a given line number                           *
      **********************************************************************

     P SkipLines       B

     D SkipLines       PI
     D    isSkipLine                       LIKE(ssSkipLine)

     C                   EVAL      saOutput = *BLANKS

     C                   IF        wiLine > isSkipLine

     C                   DOW       wiLine <= piPageLen
     C                   WRITE     CvtSplWrk1    OutputData
     C                   EVAL      wiLine = wiLine + 1
     C                   ENDDO

     C                   If        paToFmt = '*HTML'
     C                   EVAL      saOutput   = '< hr>'
     C                   WRITE     CvtSplWrk1    OutputData
     C                   EndIf
     C                   EVAL      saOutput = *BLANKS
     C                   EVAL      wiLine = 1

     C                   EndIf

     C                   DOW       wiLine < isSkipLine
     C                   WRITE     CvtSplWrk1    OutputData
     C                   EVAL      wiLine = wiLine + 1
     C                   ENDDO

     C                   RETURN

     P SkipLines       E

      **********************************************************************
      * Procedure to space a number of lines                               *
      **********************************************************************

     P SpceLines       B

     D SpceLines       PI
     D    isSpceLine                       LIKE(ssSpceLine)

     D liCount         S              5I 0

     C*                  EVAL      wiLine  = wiLine  + 1
     C                   EVAL      saOutput = *BLANKS
     C                   DOW       liCount < isSpceLine - 1
     C                   WRITE     CvtSplWrk1    OutputData
     C                   EVAL      wiLine  = wiLine  + 1
     C                   EVAL      liCount = liCount + 1
     C                   ENDDO

     C                   RETURN

     P SpceLines       E
      **********************************************************************
     P ParseInput      B
     D ParseInput      PI

     D Input           S           2048
     D InpLen          S              5I 0
     D DATA            S           2048
     D X0E             C                   X'0E'
     D X0F             C                   X'0F'
     C                   z-add     1             i                 5 0
     C                   z-add     1             J                 5 0
     C                   Clear                   Data
     C                   Eval      Input = InputData
     C                   Eval      InpLen= %len(%trimr(InputData))

     C     1             Do        InpLen
     C                   If        %SUBST(Input : i : 1) = X0E
     C                   Eval      %SubSt(Data : j : 1) = ' '
     C                   Eval      J = J + 1
     C                   Eval      %SubSt(Data : j : 1)
     C                             = %SubSt(Input : i : 1)
     C                   Else
     C                   If        %SUBST(Input  : i : 1) = X0F
     C                   Eval      %SubSt(Data : j : 1)
     C                             = %SubSt(Input  : i : 1)
     C                   Eval      J = J + 1
     C                   Eval      %SubSt(Data : j : 1) = ' '
     C                   Else
     C                   Eval      %SubSt(Data : j : 1)
     C                             = %SubSt(Input : i : 1)
     C                   EndIf
     C                   EndIf
     C                   Eval      i = i + 1
     C                   Eval      j = j + 1
     C                   If        i > InpLen
     C                   Leave
     C                   EndIf
     C                   EndDo

     C                   Eval      InputData = Data
     C                   Eval      InpLen = j -1
     C
     C                   RETURN

     P ParseInput      E
**
< html>< head>
</head>< body>< pre>
**
< hr></pre></body></html>


File  : QCLSRC
Member: CVTSPLSTMC
Type  : CLP
Usage : CRTCLPGM CVTSPLSTMC     

/*****************************************************************/
/*                                                               */
/* COMMAND: CVTSPLSTM CPP                                        */
/*                                                               */
/* PROGRAM NAME: CVTSPLSTMC                                      */
/*                                                               */
/* VERSION     : 1.1                                             */
/*                                                               */
/* AUTHOR      : Vengoal Chang                                   */
/*                                                               */
/* DATE WRITTEN: March 2006                                      */
/*                                                               */
/* DESCRIPTION : Convert Spooled File to Stream File             */
/*               command processing program.                     */
/*                                                               */
/* FUNCTIONS   : Converts an AS/400 spooled file to a stream     */
/*               file in one of two formats:                     */
/*                                                               */
/*               1. Plain ASCII text                             */
/*               2. HTML                                         */
/*                                                               */
/* Copyright 2006 (c) Vengoal Chang.                             */
/* All rights reserved.                                          */
/*                                                               */
/*****************************************************************/
             PGM       (&FromFile                                   +
                        &ToStmf                                     +
                        &ToDir                                      +
                        &QualJob                                    +
                        &SplId                                      +
                        &ToFmt                                      +
                        &StmfOpt                                    +
                        &StmfCodPag                                 +
                        &Title                                      )

             DCL        &FromFile    *CHAR   10
             DCL        &ToFile      *CHAR   10
             DCL        &ToStmf      *CHAR   64
             DCL        &ToDir       *CHAR  256
             DCL        &QualJob     *CHAR   26
             DCL        &IntJob      *CHAR   16
             DCL        &IntSplID    *CHAR   16
             DCL        &Job         *CHAR   10
             DCL        &User        *CHAR   10
             DCL        &JobNbr      *CHAR    6
             DCL        &SplID       *DEC    (4 0)
             DCL        &HexSplID    *CHAR    4
             DCL        &ToFmt       *CHAR    5
             DCL        &StmfOpt     *CHAR    8
             DCL        &StmfCodPag  *DEC    (5 0)
             DCL        &CodePage    *CHAR    8
             DCL        &Title       *CHAR   50
             DCL        &SplInfo     *CHAR 2000
             DCL        &InfoLen     *CHAR    4
             DCL        &PageLen     *CHAR    4
             DCL        &SplNbr      *CHAR    5
             DCL        &Path        *CHAR 1024
             DCL        &Rpyle       *LGL
             DCL        &RpyleSeq    *DEC    (4 0)
             DCL        &InqMsgRpy   *CHAR   10
             DCL        &CtlChar     *CHAR    7    '*NONE'
             DCL        &MsgID       *CHAR    7
             DCL        &Msgf        *CHAR   10
             DCL        &MsgfLib     *CHAR   10
             DCL        &MsgDta      *CHAR  100
             DCL        &MsgKey      *CHAR    4
             DCL        &Msg         *CHAR  100
             DCL        &Sev         *DEC    (2 0)
             DCL        &ErrorFlag   *LGL     1

/* Global message monitor to trap any unmonitored errors             */

             MONMSG     (CPF9999 CPF0000 MCH0000) EXEC(GOTO ERROR)


/* (A) Extract job name from qualified Job name                      */

             CHGVAR     &Job     %sst(&QualJob  1 10)
             CHGVAR     &User    %sst(&QualJob 11 10)
             CHGVAR     &JobNbr  %sst(&QualJob 21  6)

/* (B) Convert special value * to current job details                */

             IF         (&Job *eq '*') DO
                 RTVJOBA    JOB(&Job) USER(&User) NBR(&JobNbr)
             ENDDO

/* (C) Set up spooled file number from special values                */

             CHGVAR     &SplNbr &SplID
             IF         (&SplID *EQ -2) DO
                 CHGVAR     &SplNbr '*LAST'
             ENDDO
             IF         (&SplID *EQ -3) DO
                 CHGVAR     &SplNbr '*ONLY'
             ENDDO

/* (D) Create first work file                                        */

             DLTF       QTEMP/CVTSPLWRK1
             MONMSG     CPF2105
             CRTPF      FILE(QTEMP/CVTSPLWRK1) RCDLEN(378) +
                          IGCDTA(*YES) SIZE(1000000 10000 10)
             CHGVAR     &ToFile 'CVTSPLWRK1'

/* (E) Create second work file if not converting to plain text       */

             DLTF       QTEMP/CVTSPLWRK2
             MONMSG     CPF2105
             CRTPF      FILE(QTEMP/CVTSPLWRK2) RCDLEN(382) +
                        IGCDTA(*YES) SIZE(1000000 10000 10)
             CHGVAR     &ToFile 'CVTSPLWRK2'


/* (F) Set Job to use reply list entries                             */

             RTVJOBA    InqMsgRpy(&InqMsgRpy)
             CHGJOB     InqMsgRpy(*SYSRPYL)

/* (G) Add reply list entry for CPYSPLF message                      */

             CHGVAR     &RpyleSeq 9999
 ADDRPYLE:   ADDRPYLE   &RpyleSeq MSGID(CPA3311) RPY('G')
             MONMSG     CPF2555 EXEC(DO)
                 CHGVAR     &RpyleSeq (&RpyleSeq -1)
                 IF         (&RpyleSeq *GT 0) (GOTO ADDRPYLE)
             ENDDO
             MONMSG     CPF0000 EXEC(GOTO START)
             CHGVAR     &Rpyle '1'


 START:      IF         (&ToFmt *NE '*TEXT') DO

/* (I) Set up Title if a special value                               */

                 IF         (&Title *EQ '*STMFILE') DO
                     CHGVAR     &Title &ToStmf
                 ENDDO
                 IF         (&Title *EQ '*NONE') DO
                     CHGVAR     &Title ' '
                 ENDDO

             ENDDO

/* (H) We need control characters for TEXT or HTML conversion     */
             CHGVAR     &CtlChar  '*PRTCTL'

/* (J) Copy spooled file into work file                               */

             CPYSPLF    &FromFile                                     +
                        QTEMP/&ToFile                                 +
                        JOB(&JobNbr/&User/&Job)                       +
                        SPLNBR(&SplNbr)                               +
                        MBROPT(*REPLACE)                              +
                        CTLCHAR(&CtlChar)

/* (K) Call API to get spooled file info */

             CHGVAR     %bin(&HexSplID) &SplID
             IF         (&SplNbr *EQ '*ONLY') (CHGVAR %bin(&HexSplID) 0)
             IF         (&SplNbr *EQ '*LAST') (CHGVAR %bin(&HexSplID) -1)
             CHGVAR     %bin(&InfoLen) 2000
             CALL       PGM(QUSRSPLA) PARM(&SplInfo                   +
                                           &InfoLen                   +
                                           'SPLA0100'                 +
                                           &QualJob                   +
                                           &IntJob                    +
                                           &IntSplID                  +
                                           &FromFile                  +
                                           &HexSplID                  )
             CHGVAR     &PageLen %sst(&SplInfo 425 4)

/* (L) Convert spooled file data to HTML OR TEXT format                  */

             OVRDBF     CvtSplWrk1 QTEMP/CVTSPLWRK1 OVRSCOPE(*JOB)
             OVRDBF     CvtSplWrk2 QTEMP/CVTSPLWRK2 OVRSCOPE(*JOB)

             CALL       CVTSPLSTMR PARM(&ToFmt &Title &PageLen)

/* (N) Set codepage of stream file to be created                         */

             CHGVAR     &CodePage &StmfCodPag
             IF         (&StmfCodPag *EQ -1) (CHGVAR &CodePage *PCASCII)
             IF         (&StmfCodPag *EQ -2) (CHGVAR &CodePage *STMF)

/* (O) Convert spooled file data in work file to stream file             */

             CHGVAR     &Path (&ToDir *TCAT '/' *CAT &ToStmf)
             CPYTOSTMF    FROMMBR('/qsys.lib/qtemp.lib/CVTSPLWRK1.fil+
                          e/CVTSPLWRK1.mbr')                         +
                          TOSTMF(&Path)                              +
                          STMFOPT(&StmfOpt)                          +
                          STMFCODPAG(&CodePage)

/* (P) Send completion message                                           */

             SNDPGMMSG  MSGID(CPF9898)                               +
                        MSGF(QCPFMSG)                                +
                        MSGDTA('Spooled file' *BCAT &FromFile *BCAT  +
                        'copied to stream file' *BCAT &ToStmf)       +
                        MSGTYPE(*COMP)

/* (Q) Delete work file(s)                                               */

             DLTOVR     CvtSplWrk1  LVL(*JOB)
             MONMSG     CPF0000
             DLTOVR     CvtSplWrk2  LVL(*JOB)
             MONMSG     CPF0000
             DLTF       QTEMP/CVTSPLWRK1
             MONMSG     CPF2105
             DLTF       QTEMP/CVTSPLWRK2
             MONMSG     CPF2105

/* (R) Remove reply list entry and reset job attribute if changed        */

             IF         (&Rpyle *EQ '1') DO
                 RMVRPYLE   &RpyleSeq
             ENDDO
             CHGJOB     INQMSGRPY(&InqMsgRpy)

/* Finish                                                            */

             RETURN

/*                                                                   */
/* Error Handling logic                                              */
/*                                                                   */
 ERROR:
/*                                                                   */
/* If looping in the error handling routine, end in error            */
/*                                                                   */
             IF         (&ErrorFlag) DO
                 SNDPGMMSG  MSGID(CPF9999) MSGF(QCPFMSG) MSGTYPE(*ESCAPE)
                 MONMSG     CPF0000
                 GOTO       ENDPGM
             ENDDO
/*                                                                   */
/* Set flag to prevent looping                                       */
/*                                                                   */
             CHGVAR     &ErrorFlag '1'

/* Re-send any diagnostic messages sent to this program              */

 ERROR1:     RCVMSG     MSGTYPE(*DIAG)                               +
                        RMV(*NO)                                     +
                        KEYVAR(&MsgKey)                              +
                        MSG(&Msg)                                    +
                        MSGDTA(&MsgDta)                              +
                        MSGID(&MsgID)                                +
                        MSGF(&Msgf)                                  +
                        SNDMSGFLIB(&MsgFLib)
             IF         (&MsgKey *EQ ' ') (GOTO ERROR2)
             RMVMSG     MSGKEY(&MsgKey)
             SNDPGMMSG  MSGID(&MsgID)                            +
                        MSGF(&MsgfLib/&Msgf)                     +
                        MSGDTA(&MsgDta)                          +
                        MSGTYPE(*DIAG)
             GOTO       CMDLBL(ERROR1)

/* Re-send any escape messages sent to this program                 */
 ERROR2:     IF         (&Rpyle *EQ '1') DO
                 RMVRPYLE   &RpyleSeq
                 MONMSG     CPF0000
             ENDDO
             CHGJOB     INQMSGRPY(&InqMsgRpy)
             MONMSG     CPF0000

             RCVMSG     MSGTYPE(*EXCP)                               +
                        RMV(*NO)                                     +
                        MSG(&Msg)                                    +
                        MSGDTA(&MsgDta)                              +
                        MSGID(&MsgID)                                +
                        SEV(&Sev)                                    +
                        MSGF(&Msgf)                                  +
                        SNDMSGFLIB(&MsgFLib)
             IF         (&Sev *gt 00) THEN(DO)
                 SNDPGMMSG  MSGID(&MsgID)                            +
                            MSGF(&MsgfLib/&Msgf)                     +
                            MSGDTA(&MsgDta)                          +
                            MSGTYPE(*ESCAPE)
             ENDDO
             ELSE       DO
                 SNDPGMMSG  MSGID(CPF9897)                           +
                            MSGF(QCPFMSG)                            +
                            MSGDTA(&Msg)                             +
                            MSGTYPE(*ESCAPE)
             ENDDO

 ENDPGM:     ENDPGM


File  : QCMDSRC
Member: CVTSPLSTMF
Type  : CMD
Usage : CRTCMD CMD(lib/CVTSPLSTMF) PGM(lib/CVTSPLSTMC)     

/*****************************************************************/
/*                                                               */
/* COMMAND NAME: CVTSPLSTMF                                      */
/*                                                               */
/* AUTHOR      : Vengoal Chang                                   */
/*                                                               */
/* DATE WRITTEN: March   2006                                    */
/*                                                               */
/* DESCRIPTION : Convert Spooled File to Stream File command     */
/*                                                               */
/* FUNCTIONS   : Converts an AS/400 spooled file to a stream     */
/*               file in one of three formats:                   */
/*                                                               */
/*               1. Plain ASCII text                             */
/*               2. HTML                                         */
/*                                                               */
/*****************************************************************/
             CMD        PROMPT('Convert Spool to Stream File')

             PARM       KWD(FROMFILE) TYPE(*NAME) LEN(10) MIN(1) +
                          PROMPT('From spooled file name')

             PARM       KWD(TOSTMF) TYPE(*NAME) LEN(64) MIN(1) +
                          PROMPT('To stream file name')

             PARM       KWD(TODIR) TYPE(*PNAME) LEN(256) MIN(1) +
                          PROMPT('To directory')

             PARM       KWD(JOB) TYPE(JOB) DFT(*) SNGVAL((*)) +
                          PROMPT('Job name')
 JOB:        QUAL       TYPE(*NAME) LEN(10) MIN(1)
             QUAL       TYPE(*NAME) LEN(10) MIN(1) PROMPT('User')
             QUAL       TYPE(*CHAR) LEN(6) RANGE(000000 999999) +
                          MIN(1) PROMPT('Number')

             PARM       KWD(SPLNBR) TYPE(*DEC) LEN(4) DFT(*ONLY) +
                          RANGE(1 9999) SPCVAL((*LAST -2) (*ONLY +
                          -3)) PROMPT('Spooled file number')

             PARM       KWD(TOFMT) TYPE(*CHAR) LEN(5) RSTD(*YES) +
                          DFT(*TEXT) VALUES(*TEXT *HTML) +
                          PROMPT('Stream file format')

             PARM       KWD(STMFOPT) TYPE(*CHAR) LEN(8) RSTD(*YES) +
                          DFT(*NONE) VALUES(*NONE *REPLACE *ADD) +
                          PROMPT('Stream file option')

             PARM       KWD(STMFCODPAG) TYPE(*DEC) LEN(5 0) +
                          DFT(*PCASCII) RANGE(1 32767) +
                          SPCVAL((*PCASCII -1) (*STMF -2)) +
                          PMTCTL(*PMTRQS) PROMPT('Stream file code +
                          page')

             PARM       KWD(TITLE) TYPE(*CHAR) LEN(50) RSTD(*NO) +
                          DFT(*NONE) SPCVAL((*NONE) (*STMFILE)) +
                          PMTCTL(HTML) PROMPT('Title for HTML')
 HTML:       PMTCTL     CTL(TOFMT) COND((*EQ *HTML)) +
                          NBRTRUE(*EQ 1)


回應
AS/400 系統應用電子報





Powered by Xuite
    沒有新回應!
平均分數:0 顆星
投票人數:0
我要評分:
關鍵字
IBM 最佳夥伴
AS/400 非官方網站