如何將一份報表切割頁次列印(Command CPYSPLPAG Copy Spooled by Page Range)?
有時候同一份報表頁數可能長達數百數千頁,此時使用者若僅要部份頁次或者需要傳輸某幾頁
報表,為了減輕網路的負擔,最好的方式就是切割使用者所要求的頁次,再做處理。這個工具
可指定重新列印原報表頁次區間。
Copy Spool by Page Range (CPYSPLPAG)
Type choices, press Enter.
Spool file name . . . . . . . . Name
Job name . . . . . . . . . . . . * Name, *
User name . . . . . . . . . . Name
Job number . . . . . . . . . . 000000-999999
Spool file number . . . . . . . *LAST 000001-999999, *ONLY, *LAST
Bottom
F3=Exit F4=Prompt F5=Refresh F10=Additional parameters F12=Cancel
F13=How to use this display F24=More keys
按 F10 可指定重印頁次區間。
Copy Spool by Page Range (CPYSPLPAG)
Type choices, press Enter.
Spool file name . . . . . . . . Name
Job name . . . . . . . . . . . . * Name, *
User name . . . . . . . . . . Name
Job number . . . . . . . . . . 000000-999999
Spool file number . . . . . . . *LAST 000001-999999, *ONLY, *LAST
Additional Parameters
Range of pages to copy:
Starting page . . . . . . . . *FIRST 1-9999, *FIRST, *LAST
Ending page . . . . . . . . . *LAST 1-9999, *LAST, *FIRST
Bottom
F3=Exit F4=Prompt F5=Refresh F12=Cancel F13=How to use this display
F24=More keys
-------------------------------------------------------------------------------
CPYSPLPAG command
File : QCMDSRC
Member : CPYSPLPAG
Type : CMD
/******************************************************************************/
/* */
/* System....... Utilities */
/* Program...... CPYSPLPAG - Copy Spool File BY Page Range */
/* Written by... Vengoal Cahng */
/* Date......... 11/08/2001 */
/* */
/* */
/* Program Description */
/* */
/* */
/* It can perform operations on the entire spool file or a specified */
/* Page range. */
/* */
/* */
/* NOTE: This Command does not handle AFPDS Spool Files. */
/* */
/* * * * * * * * * Indicator Usage * * * * * * * * * * * * * * * * */
/* */
/* */
/* */
/* * * * * * * * * Externally Called Programs * * * * * * * * * */
/* */
/* From/To Program-Id Parameters */
/* */
/* */
/* */
/* */
/* * * * * * * * * * * Maintenance Log * * * * * * * * * * * * */
/* */
/* Req # Date Programmer Modification Reason */
/* */
/*********************************************************************/
CMD PROMPT('Copy Spool by Page Range')
PARM KWD(FILE) TYPE(*NAME) LEN(10) MIN(1) +
EXPR(*YES) PROMPT('Spool file name')
PARM KWD(JOB) TYPE(QUAL1) SNGVAL(*) DFT(*) +
PROMPT('Job name')
PARM KWD(SPLNBR) TYPE(*DEC) LEN(6 0) DFT(*LAST) +
RANGE(000001 999999) SPCVAL((*ONLY -1) +
(*LAST -2)) PROMPT('Spool file number')
PARM KWD(PAGERANGE) TYPE(PAGELIST) +
PMTCTL(*PMTRQS) PROMPT('Range of pages +
to copy')
QUAL1: QUAL TYPE(*NAME) LEN(10) MIN(1) EXPR(*YES)
QUAL TYPE(*NAME) LEN(10) MIN(0) EXPR(*YES) +
PROMPT('User name')
QUAL TYPE(*CHAR) LEN(6) RANGE(000000 999999) +
MIN(0) FULL(*YES) PROMPT('Job number')
QUAL2: QUAL TYPE(*NAME) LEN(10) MIN(1)
QUAL TYPE(*NAME) LEN(10) MIN(1) +
EXPR(*YES) PROMPT('Library name')
PAGELIST: ELEM TYPE(*INT2) DFT(*FIRST) RANGE(1 9999) +
SPCVAL((*FIRST -2) (*LAST -1)) +
PROMPT('Starting page')
ELEM TYPE(*INT2) DFT(*LAST) RANGE(1 9999) +
SPCVAL((*LAST -1) (*FIRST -2)) +
PROMPT('Ending page')
File : QCLSRC
Member : CPYSPLPAGC
Type : CLP
/*********************************************************************/
/* */
/* System ........... Utilities */
/* Program........... CPYSPLPAGC Program to copy spool file to text */
/* Written by........ Vengoal Cahng */
/* Date.............. Nov 8, 2001 */
/* */
/* */
/* Program Description */
/* */
/* It can perform operations on the entire spool file or a specified */
/* Page range. */
/* */
/* */
/* NOTE: This program does not handle AFPDS Spool Files. */
/* */
/* Parameters: */
/* NAME I/O DESCRIPTION COMMENTS */
/* &FILE Input Spool file Spool file to copy */
/* &FULLJOB Input Job name Spool file job */
/* &SPLNBR Input Spool nbr Spool file number */
/* &PAGRNG Input Page Range Page Range to Print */
/* * * * * * * * * * * * Maintenance Log * * * * * * * * * * * * * * */
/* */
/* Req#. Date Programmer Modification Reason */
/* */
/*********************************************************************/
PGM PARM(&FILE &FULLJOB &SPLNBR &PAGRNG)
DCL &FILE *CHAR LEN(10)
DCL &FULLJOB *CHAR LEN(26)
DCL &JOB *CHAR LEN(10)
DCL &USER *CHAR LEN(10)
DCL &JOBNBR *CHAR LEN(6)
DCL &SPLNBR *DEC LEN(6 0)
DCL &PAGRNG *CHAR LEN(6)
DCL &ERRORSW *LGL /* Standard error */
DCL &MSGID *CHAR LEN(7) /* Standard error */
DCL &MSG *CHAR LEN(512) /* Standard error */
DCL &MSGDTA *CHAR LEN(512) /* Standard error */
DCL &MSGF *CHAR LEN(10) /* Standard error */
DCL &MSGFLIB *CHAR LEN(10) /* Standard error */
DCL &KEYVAR *CHAR LEN(4) /* Standard error */
DCL &KEYVAR2 *CHAR LEN(4) /* Standard error */
DCL &RTNTYPE *CHAR LEN(2) /* Standard error */
DCL VAR(&FRPAGE) TYPE(*DEC) LEN(7 0)
DCL VAR(&TOPAGE) TYPE(*DEC) LEN(7 0)
DCL VAR(&SPLFDS) TYPE(*CHAR) LEN(1000)
DCL VAR(&DSLENB) TYPE(*CHAR) LEN(4)
DCL VAR(&INTJOB) TYPE(*CHAR) LEN(16)
DCL VAR(&INTSPLF) TYPE(*CHAR) LEN(16)
DCL VAR(&SPLNBRA) TYPE(*CHAR) LEN(6)
DCL VAR(&SPLNBRB) TYPE(*CHAR) LEN(4)
DCL VAR(&NBRPGSB) TYPE(*CHAR) LEN(4)
DCL VAR(&NBRPGS) TYPE(*DEC) LEN(9 0)
DCL VAR(&CPIB) TYPE(*CHAR) LEN(4)
DCL VAR(&CPI) TYPE(*DEC) LEN(9 1)
DCL VAR(&PAGWTHB) TYPE(*CHAR) LEN(4)
DCL VAR(&PAGWTH) TYPE(*DEC) LEN(9 0)
MONMSG MSGID(CPF0000) EXEC(GOTO STDERR1) /* Std err */
CHGVAR &JOB %SST(&FULLJOB 1 10)
CHGVAR &USER %SST(&FULLJOB 11 10)
CHGVAR &JOBNBR %SST(&FULLJOB 21 6)
CHGVAR VAR(&SPLNBRA) VALUE(&SPLNBR)
DLTOVR FILE(INPUT)
MONMSG CPF0000
DLTF FILE(QTEMP/SPLTEMP)
MONMSG MSGID(CPF2105) /* file not found */
CRTPF FILE(QTEMP/SPLTEMP) RCDLEN(220) IGCDTA(*YES)
IF COND(&SPLNBR *EQ -2) THEN(DO)
CHGVAR VAR(&SPLNBRA) VALUE('*LAST')
ENDDO
IF COND(&SPLNBR *EQ -1) THEN(DO)
CHGVAR VAR(&SPLNBRA) VALUE('*ONLY')
ENDDO
IF (&FULLJOB *EQ '*') DO /* Use current job */
CPYSPLF FILE(&FILE) TOFILE(QTEMP/SPLTEMP) +
SPLNBR(&SPLNBRA) MBROPT(*ADD) +
CTLCHAR(*PRTCTL)
ENDDO /* Use current job */
IF (&FULLJOB *NE '*') DO /* Specific job name */
IF (&USER *EQ ' ') CHGVAR &USER '*N'
IF (&JOBNBR *EQ ' ') CHGVAR &JOBNBR '*N'
CPYSPLF FILE(&FILE) TOFILE(QTEMP/SPLTEMP) +
JOB(&JOBNBR/&USER/&JOB) SPLNBR(&SPLNBRA) +
MBROPT(*ADD) +
CTLCHAR(*PRTCTL)
ENDDO /* Specific job name used */
IF COND(&SPLNBR *EQ -2) THEN(DO)
CHGVAR VAR(&SPLNBR) VALUE(-1) /* *LAST */
ENDDO
ELSE DO
IF COND(&SPLNBR *EQ -1) THEN(DO)
CHGVAR VAR(&SPLNBR) VALUE(0) /* *ONLY */
ENDDO
ENDDO
/* Build work variables used for parameters to attribute API. */
CHGVAR VAR(&DSLENB) VALUE(X'000003E8') /* Change +
length to the hex form of '1000' */
CHGVAR VAR(%BIN(&SPLNBRB 1 4)) VALUE(&SPLNBR)
/* Call API */
CALL PGM(QUSRSPLA) PARM(&SPLFDS &DSLENB +
'SPLA0100' &FULLJOB &INTJOB &INTSPLF &FILE +
&SPLNBRB)
/* Retrieve results: */
CHGVAR VAR(&NBRPGSB) VALUE(%SST(&SPLFDS 141 4))
CHGVAR VAR(&NBRPGS) VALUE(%BIN(&NBRPGSB 1 4))
CHGVAR VAR(&CPIB) VALUE(%SST(&SPLFDS 177 4))
CHGVAR VAR(&CPI) VALUE(%BIN(&CPIB 1 4))
CHGVAR VAR(&CPI) VALUE(&CPI / 10)
CHGVAR VAR(&PAGWTHB) VALUE(%SST(&SPLFDS 429 4))
CHGVAR VAR(&PAGWTH) VALUE(%BIN(&PAGWTHB 1 4))
CHGVAR VAR(&FRPAGE) VALUE(%BIN(&PAGRNG 3 2))
CHGVAR VAR(&TOPAGE) VALUE(%BIN(&PAGRNG 5 2))
IF COND(&TOPAGE *GT &NBRPGS) THEN(DO)
SNDPGMMSG MSG('To Page cannot be greater than Total +
number of Pages')
GOTO RETN
ENDDO
IF COND(&FRPAGE *EQ 0) THEN(DO)
SNDPGMMSG MSG('From Page cannot be Zeros.')
GOTO RETN
ENDDO
IF COND(&TOPAGE *EQ 0) THEN(DO)
SNDPGMMSG MSG('To Page cannot be Zeros.')
GOTO RETN
ENDDO
IF COND(&TOPAGE = -2) THEN(CHGVAR VAR(&TOPAGE) +
VALUE(1))
IF COND(&FRPAGE = -2) THEN(CHGVAR VAR(&FRPAGE) +
VALUE(1))
IF COND(&TOPAGE = -1) THEN(CHGVAR VAR(&TOPAGE) +
VALUE(&NBRPGS))
IF COND(&FRPAGE = -1) THEN(CHGVAR VAR(&FRPAGE) +
VALUE(&NBRPGS))
IF COND(&FRPAGE *GT &TOPAGE) THEN(DO)
SNDPGMMSG MSG('From Page cannot be greater than to +
Page.')
GOTO RETN
ENDDO
PRINT:
OVRDBF FILE(INPUT) TOFILE(QTEMP/SPLTEMP)
OVRPRTF FILE(QPRINT) PAGESIZE(*N &PAGWTH) CPI(&CPI) +
SPLFNAME(&FILE) IGCDTA(*YES)
CALL PGM(CPYSPLPAGR) PARM(&FRPAGE &TOPAGE )
DLTOVR INPUT
DLTOVR QPRINT
RMVMSG CLEAR(*ALL)
SNDPGMMSG MSG('Spooled file ' *CAT &FILE *TCAT ' has +
been reprinted.') MSGTYPE(*COMP)
RETN:
RETURN /* Normal end for MODIFY(*YES) */
STDERR1: /* Standard error handling routine */
IF &ERRORSW SNDPGMMSG MSGID(CPF9999) +
MSGF(QCPFMSG) MSGTYPE(*ESCAPE)
CHGVAR &ERRORSW '1' /* Set to fail on error */
RCVMSG MSGTYPE(*EXCP) RMV(*NO) KEYVAR(&KEYVAR)
STDERR2: RCVMSG MSGTYPE(*PRV) MSGKEY(&KEYVAR) RMV(*NO) +
KEYVAR(&KEYVAR2) MSG(&MSG) MSGDTA(&MSGDTA) +
MSGID(&MSGID) RTNTYPE(&RTNTYPE) +
MSGF(&MSGF) SNDMSGFLIB(&MSGFLIB)
IF (&RTNTYPE *NE '02') GOTO STDERR3
IF (&MSGID *NE ' ') SNDPGMMSG MSGID(&MSGID) +
MSGF(&MSGFLIB/&MSGF) MSGDTA(&MSGDTA) +
MSGTYPE(*DIAG)
IF (&MSGID *EQ ' ') SNDPGMMSG MSG(&MSG) +
MSGTYPE(*DIAG)
RMVMSG MSGKEY(&KEYVAR2)
STDERR3: RCVMSG MSGKEY(&KEYVAR) MSGDTA(&MSGDTA) +
MSGID(&MSGID) MSGF(&MSGF) +
SNDMSGFLIB(&MSGFLIB)
SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
MSGDTA(&MSGDTA) MSGTYPE(*ESCAPE)
ENDPGM
File : QRPGLESRC
Member : CPYSPLPAGR
Type : RPGLE
H DEBUG OPTION(*SRCSTMT:*NODEBUGIO)
* RSTSPLFR - Copy text to spool - Called by RSTSPLFC
*
* PRTCTL Keyword : Data structure A(12)+S(3)
* Position contents
* 1-3 A(3) space-before blank or 0-255
* 4-6 A(3) space-after blank or 0-255
* 7-9 A(3) skip-before blank or 0-255
* 10-12 A(3) skip-after blank or 0-255
* 13-15 S(3) line count 3 digit numeric
* (zoned decimal)
*
FINPUT IP F 220 DISK
FQPRINT O F 198 PRINTER PRTCTL(LINE)
F OFLIND(*INOF)
*
D LINE DS 15
D SPCBFR 3 3
D SKPBFR 7 9
*****************************************************************
* Parameters
*****************************************************************
D WrkNum7 S 7P 0
D FrPage S Like(WrkNum7)
D ToPage S Like(WrkNum7)
D CurPage S Like(WrkNum7)
*****************************************************************
IINPUT AA 01
I 1 3 SKPBFR
I 4 4 SPCBFR
I 6 203 DATA
*****************************************************************
*** Parameters:
*****************************************************************
C *ENTRY Plist
C Parm FrPage
C Parm ToPage
C If SpcBfr = *Blanks
C Eval CurPage = CurPage + 1
C If CurPage >= FrPage and
C CurPage <= ToPage
C Move '1' *In90
C Else
C If CurPage > ToPage
C Move '0' *In90
C Move '1' *INLR
C EndIf
C EndIf
C EndIf
C 90 EXCEPT PRINT Print
OQPRINT E PRINT
O DATA 198
使用方法
1. CRTBNDRPG CPYSPLPAGR
2. CRTCLPGM CPYSPLPAGC
3. CRTCMD CMD(CPYSPLPAG) PGM(CPYSPLPAGC)
4. 於 Command Line 輸入 CPTSPLPAG 按 F4
再輸入相關參數。
A blog about IBM i (AS/400), MQ and other things developers or Admins need to know.
星期三, 11月 01, 2023
2001-11-08 如何將一份報表切割頁次列印(Command CPYSPLPAG Copy Spooled by Page Range)?
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言