sponsored links

Collapse

Announcement

Collapse
No announcement yet.

How to cpy Spool file frm one out Q to other out Q

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to cpy Spool file frm one out Q to other out Q

    Hi

    Anyone having idea How to copy spool file frm one outQ to another outQ

    Thanx & Regds
    Sudhir

  • #2
    Re: How to cpy Spool file frm one out Q to other out Q

    cant u use CPYSPLF

    "It's like a koala pooped a rainbow on my head and I can taste the colors."

    Comment


    • #3
      Re: How to cpy Spool file frm one out Q to other out Q

      Try send network spool file command SNDNETSPLF. You can send a copy to yourself and then move it to the correct OUTQ

      Comment


      • #4
        Re: How to cpy Spool file frm one out Q to other out Q

        You could download and use this tool...

        http://www.code400.com/cpyfrmsplf.php
        All my answers were extracted from the "Big Dummy's Guide to the As400"
        and I take no responsibility for any of them.

        www.code400.com

        Comment


        • #5
          Re: How to cpy Spool file frm one out Q to other out Q

          Hi

          Try this solution. It works OK for me. DUPCHGSPLF was posted by Herman.

          http://www.iseriesnetwork.com/artarc...top&topicid=51



          Code:
          via DUPCHGSPLF 
          
          Have you also noticed that the CHGSPLFA (Change Spooled File
          Attributes) command allows only a limited set of attributes
          to be changed ?
          F.e. you can't change the LPI (Lines per inch),
          CPI (Characters per inch), PAGRRT (Page rotation), Font and Output bin.
          
          All these attributes may be needed when you want to print 
          your spooled file to a PC printer via Host Print Transform,
          like a HP LaserJet.
          
          If you know it before, you can use an override command, like :
          
             OVRPRTF  FILE(QSYSPRT) LPI(8) CPI(12) FONT(*CPI) +
                       PAGRTT(90) OUTQ(HPLASERJET)
          
          to print the spooled file in landscape mode.
          
          But if the spooled file is already created, you can't use
          CHGSPLFA.
          
          That's why I've created the DUPCHGSPLF (Duplicate and Change
          Spooled File) command. A flexible command to duplicate a spooled
          file and change some of the attributes.
          
          Example :
          
            DUPCHGSPLF JOB(123456/QSYSOPR/BACKUP) SPLFILE(QPJOBLOG) SPLNBR(*LAST) +
              LPI(8) CPI(12) FONT(*CPI) PAGRTT(90) OUTQ(MYLIB/MYOUTQ) DRAWER(2) +
              OUTBIN(3) NEWUSER(JOE) NEWSPLNAME(BACKUPLOG) 
                                                           
          You don't need to specify all parameters, because the default value is *SAME.
          
          Note that you can change the USER and the NAME of the spooled file.
          In the example, user JOE will become the owner of the new spooled file,
          which will ressort under a QPRTJOB jobname.
          
          
           /*                                                                  */
           /*                             \\\\\\\                              */
           /*                            ( o   o )                             */
           /*------------------------oOO----(_)----OOo-------------------------*/
           /*                                                                  */
           /*   Command : DUPCHGSPLF                                           */
           /*   Version : 2.01                                                 */
           /*   System :  iSeries                                              */
           /*   Author :  Herman Van der Staey                                 */
           /*                                                                  */
           /*   Description :   Duplicate and Change Spooled file              */
           /*                                                                  */
           /*                     ooooO              Ooooo                     */
           /*                     (    )             (    )                    */
           /*----------------------(   )-------------(   )---------------------*/
           /*                       (_)               (_)                      */
           /*                                                                  */
           /*   To compile :                                                   */
           /*                                                                  */
           /*     CRTCMD   CMD(XXX/DUPCHGSPLF) PGM(XXX/DUPCHGSPLF) +           */
           /*                      SRCFILE(XXX/QCMDSRC)                        */
           /*                                                                  */
          
           DUPCHGSPLF: CMD        PROMPT('Duplicate and change SPLF')
          
                       PARM       KWD(JOB) TYPE(JOBNAME) DFT(*) SNGVAL((*)) +
                                    PROMPT('Job name')
          
                       PARM       KWD(SPLFILE) TYPE(*NAME) LEN(10) DFT(QPRINT) +
                                    PROMPT('Spooled file name')
          
                       PARM       KWD(SPLNBR) TYPE(*INT4) DFT(*LAST) RANGE(1 +
                                    9999) SPCVAL((*ONLY 0) (*LAST -1)) MIN(0) +
                                    PROMPT('Spooled file number')
          
                       PARM       KWD(LPI) TYPE(*INT4) RSTD(*YES) DFT(*SAME) +
                                    SPCVAL((*SAME 0) (6 60) (8 80) (3 30) (4 +
                                    40) (7.5 75) (7,5 75) (9 90) (12 120)) +
                                    MIN(0) PROMPT('Lines per inch')
          
                       PARM       KWD(CPI) TYPE(*INT4) RSTD(*YES) DFT(*SAME) +
                                    SPCVAL((*SAME 0) (10 100) (5 50) (12 120) +
                                    (13.3 133) (13,3 133) (15 150) (16.7 167) +
                                    (16,7 167) (18 180) (20 200)) MIN(0) +
                                    PROMPT('Characters per inch')
          
                       PARM       KWD(FONT) TYPE(*CHAR) LEN(5) RSTD(*YES) +
                                    DFT(*SAME) VALUES(*SAME *CPI) PROMPT('Font')
          
                       PARM       KWD(PAGRTT) TYPE(*INT4) RSTD(*YES) +
                                    DFT(*SAME) VALUES(0 90 180 270) +
                                    SPCVAL((*AUTO -1) (*DEVD -2) (*COR -3) +
                                    (*SAME -4)) PROMPT('Degree of page rotation')
          
                       PARM       KWD(OUTQ) TYPE(OUTQ) DFT(*SAME) +
                                    SNGVAL((*SAME)) MIN(0) PROMPT('Output queue')
          
                       PARM       KWD(DRAWER) TYPE(*INT4) DFT(*SAME) RANGE(1 +
                                    255) SPCVAL((*SAME 0) (*E1 -1)) +
                                    PROMPT('Source drawer')
          
                       PARM       KWD(FORMTYPE) TYPE(*CHAR) LEN(10) DFT(*SAME) +
                                    SPCVAL((*SAME) (*STD)) PROMPT('Formtype')
          
                       PARM       KWD(USRDTA) TYPE(*CHAR) LEN(10) DFT(*SAME) +
                                    SPCVAL((*SAME)) PROMPT('User specified data')
          
                       PARM       KWD(HOLD) TYPE(*CHAR) LEN(10) RSTD(*YES) +
                                    DFT(*SAME) VALUES(*YES *NO) +
                                    SPCVAL((*SAME)) PROMPT('Hold file before +
                                    written')
          
                       PARM       KWD(SAVE) TYPE(*CHAR) LEN(10) RSTD(*YES) +
                                    DFT(*SAME) VALUES(*YES *NO) +
                                    SPCVAL((*SAME)) PROMPT('Save file after +
                                    written')
          
                       PARM       KWD(DUPLEX) TYPE(*CHAR) LEN(10) RSTD(*YES) +
                                    DFT(*SAME) VALUES(*YES *NO *TUMBLE +
                                    *FORMDF) SPCVAL((*SAME)) PROMPT('Print on +
                                    both sides (Duplex)')
          
                       PARM       KWD(OUTBIN) TYPE(*INT4) DFT(*SAME) RANGE(1 +
                                    65535) SPCVAL((*SAME -1) (*DEVD 0)) +
                                    PROMPT('Output bin')
          
                       PARM       KWD(NEWUSER) TYPE(*NAME) LEN(10) DFT(*SAME) +
                                    SPCVAL((*SAME)) PROMPT('New User')
          
                       PARM       KWD(NEWSPLNAME) TYPE(*NAME) LEN(10) +
                                    DFT(*SAME) SPCVAL((*SAME) (*JOBNAME) +
                                    (*USER)) PROMPT('New Spool file name')
          
                       PARM       KWD(DLTSPLF) TYPE(*CHAR) LEN(10) RSTD(*YES) +
                                    DFT(*NO) VALUES(*YES *NO) PROMPT('Delete +
                                    file after duplication')
          
           OUTQ:       QUAL       TYPE(*NAME) LEN(10) MIN(1)
                       QUAL       TYPE(*NAME) LEN(10) DFT(*LIBL) +
                                    SPCVAL((*CURLIB) (*LIBL)) PROMPT('Library')
          
           JOBNAME:    QUAL       TYPE(*NAME) LEN(10) MIN(1)
                       QUAL       TYPE(*NAME) LEN(10) DFT(' ') SPCVAL((' ')) +
                                    CHOICE('Name') PROMPT('User')
                       QUAL       TYPE(*CHAR) LEN(6) DFT(' ') RANGE(000000 +
                                    999999) SPCVAL((' ')) FULL(*YES) +
                                    CHOICE('000000-999999') PROMPT('Number')
          
          
            /*   Program : DUPCHGSPLF                                          */
            /*   Version : 2.01                                                */
            /*   System  : iSeries                                             */
            /*   Author :  Herman Van der Staey                                */
            /*                                                                 */
            /*   Description :  Duplicate and Change Spooled File              */
            /*                                                                 */
            /*   To compile :                                                  */
            /*                                                                 */
            /*         CRTCLPGM   PGM(XXX/DUPCHGSPLF) SRCFILE(XXX/QCLSRC)      */
            /*                                                                 */
           DUPCHGSPLF: PGM        PARM(&JOB &SPLFILE &SPLNBRBIN &LPI &CPI +
                                    &FONT &PAGRTT &OUTQ &DRAWER &FORMTYPE +
                                    &USRDTA &HOLD &SAVE &DUPLEX &OUTBIN +
                                    &NEWUSER &NEWSPLNAME &DLTSPLF)
          
                       /*   Parameters  */
          
                       DCL        VAR(&JOB)        TYPE(*CHAR) LEN(26)
                       DCL        VAR(&SPLFILE)    TYPE(*CHAR) LEN(10)
                       DCL        VAR(&SPLNBRBIN)  TYPE(*CHAR) LEN(4)
                       DCL        VAR(&LPI)        TYPE(*CHAR) LEN(4)
                       DCL        VAR(&CPI)        TYPE(*CHAR) LEN(4)
                       DCL        VAR(&PAGRTT)     TYPE(*CHAR) LEN(4)
                       DCL        VAR(&DRAWER)     TYPE(*CHAR) LEN(4)
                       DCL        VAR(&FONT)       TYPE(*CHAR) LEN(5)
                       DCL        VAR(&OUTQ)       TYPE(*CHAR) LEN(20)
                       DCL        VAR(&FORMTYPE)   TYPE(*CHAR) LEN(10)
                       DCL        VAR(&USRDTA)     TYPE(*CHAR) LEN(10)
                       DCL        VAR(&HOLD)       TYPE(*CHAR) LEN(10)
                       DCL        VAR(&SAVE)       TYPE(*CHAR) LEN(10)
                       DCL        VAR(&DUPLEX)     TYPE(*CHAR) LEN(10)
                       DCL        VAR(&OUTBIN)     TYPE(*CHAR) LEN(4)
                       DCL        VAR(&NEWUSER)    TYPE(*CHAR) LEN(10)
                       DCL        VAR(&NEWSPLNAME) TYPE(*CHAR) LEN(10)
                       DCL        VAR(&DLTSPLF)    TYPE(*CHAR) LEN(10)
          
                       /*  Variables   */
          
                       DCL        VAR(&SPLNBRDEC)  TYPE(*DEC)  LEN(8 0)
                       DCL        VAR(&SPLNBRCHR)  TYPE(*CHAR) LEN(8)
          
                       DCL        VAR(&JOBNAME)    TYPE(*CHAR) LEN(10)
                       DCL        VAR(&JOBUSER)    TYPE(*CHAR) LEN(10)
                       DCL        VAR(&JOBNBR)     TYPE(*CHAR) LEN(6)
                       DCL        VAR(&HANDLE) TYPE(*CHAR) LEN(4) /* Spooled +
                                    file handle  */
                       DCL        VAR(&BUFFER) TYPE(*CHAR) LEN(4) /* number of +
                                    buffers to get */
          
                       DCL        VAR(&SPLATTR)  TYPE(*CHAR) LEN(5000)
                       DCL        VAR(&ATTRLEN)  TYPE(*CHAR) LEN(4)
                       DCL        VAR(&INDIC)    TYPE(*CHAR) LEN(1)
          
                       /*  Parameters for the QUSCRTUS  API    */
          
                       DCL        VAR(&USPNAME) TYPE(*CHAR) LEN(10) /* user +
                                    space name */
                       DCL        VAR(&USPLIB) TYPE(*CHAR) LEN(10) /* user +
                                    space library */
                       DCL        VAR(&USPQUAL) TYPE(*CHAR) LEN(20) /* user +
                                    space qualified name */
                       DCL        VAR(&USPTYPE) TYPE(*CHAR) LEN(10) /* user +
                                    space type */
                       DCL        VAR(&USPSIZE) TYPE(*CHAR) LEN(4) /* user +
                                    space size */
                       DCL        VAR(&USPFILL) TYPE(*CHAR) LEN(1) /* user +
                                    space fill character */
                       DCL        VAR(&USPAUT) TYPE(*CHAR) LEN(10) /* user +
                                    space authority */
                       DCL        VAR(&USPTEXT) TYPE(*CHAR) LEN(50) /* user +
                                    space text */
          
                       /*  Parameters for the QUSRTVUS  API    */
          
                       DCL        VAR(&STARTPOS) TYPE(*CHAR) LEN(4)
                       DCL        VAR(&DATALEN ) TYPE(*CHAR) LEN(4)
                       DCL        VAR(&HEADER)   TYPE(*CHAR) LEN(150)
          
                       CHGVAR     VAR(%BIN(&ATTRLEN)) VALUE(5000)
          
                       /*  Create User space                    */
          
                       CHGVAR     VAR(&USPNAME) VALUE('DUPCHGSPLF') /* set +
                                    user space name */
                       CHGVAR     VAR(&USPLIB) VALUE('QTEMP') /* set user +
                                    space library */
                       CHGVAR     VAR(&USPQUAL) VALUE(&USPNAME *CAT &USPLIB) +
                                    /* set user space qualified name */
                       CHGVAR     VAR(&USPTYPE) VALUE('MYTYPE') /* set user +
                                    space type */
                       CHGVAR     VAR(%BIN(&USPSIZE)) VALUE(64000) /* set +
                                    user space size */
                       CHGVAR     VAR(&USPFILL) VALUE(' ') /* set user space +
                                    fill character */
                       CHGVAR     VAR(&USPAUT) VALUE('*USE') /* set user +
                                    space authority */
                       CHGVAR     VAR(&USPTEXT) VALUE('my user space') +
                                    /* set user space text */
          
                       CALL       PGM(QUSCRTUS) PARM(&USPQUAL &USPTYPE +
                                    &USPSIZE &USPFILL &USPAUT &USPTEXT)
          
                       /*  Open spooled file    */
          
                       CHGVAR     VAR(&BUFFER) VALUE(X'FFFFFFFF')
          
                       CALL       PGM(QSPOPNSP) PARM(&HANDLE &JOB ' ' ' ' +
                                    &SPLFILE &SPLNBRBIN &BUFFER X'00000000')
          
                       /*  Get spooled file data   */
          
                       CALL       PGM(QSPGETSP) PARM(&HANDLE &USPQUAL +
                                    'SPFR0200' &BUFFER '*WAIT' X'00000000')
          
                       /*  Close spooled file      */
          
                       CALL       PGM(QSPCLOSP) PARM(&HANDLE X'00000000')
          
                       /*  Retrieve Spooled file attributes  */
          
                       CALL       PGM(QUSRSPLA) PARM(&SPLATTR &ATTRLEN +
                                    'SPLA0200' &JOB ' ' ' ' &SPLFILE &SPLNBRBIN)
          
                       IF         COND(%BIN(&LPI) *NE 0) THEN(CHGVAR +
                                    VAR(%SST(&SPLATTR 181 4)) VALUE(&LPI))
                       IF         COND(%BIN(&CPI) *NE 0) THEN(CHGVAR +
                                    VAR(%SST(&SPLATTR 185 4)) VALUE(&CPI))
                       IF         COND(&FONT *NE *SAME) THEN(CHGVAR +
                                    VAR(%SST(&SPLATTR 537 4)) VALUE(&FONT))
                       IF         COND(%BIN(&PAGRTT) *NE -4) THEN(CHGVAR +
                                    VAR(%SST(&SPLATTR 553 4)) VALUE(&PAGRTT))
                       IF         COND(&OUTQ *NE *SAME) THEN(CHGVAR +
                                    VAR(%SST(&SPLATTR 191 20)) VALUE(&OUTQ))
                       IF         COND(%BIN(&DRAWER) *NE 0) THEN(CHGVAR +
                                    VAR(%SST(&SPLATTR 533 4)) VALUE(&DRAWER))
                       IF         COND(%BIN(&OUTBIN) *NE -1) THEN(CHGVAR +
                                    VAR(%SST(&SPLATTR 3313 4)) VALUE(&OUTBIN))
                       IF         COND(&FORMTYPE *NE *SAME) THEN(CHGVAR +
                                    VAR(%SST(&SPLATTR 89 10)) VALUE(&FORMTYPE))
                       IF         COND(&USRDTA *NE *SAME) THEN(CHGVAR +
                                    VAR(%SST(&SPLATTR 99 10)) VALUE(&USRDTA))
                       IF         COND(&HOLD *NE *SAME) THEN(CHGVAR +
                                    VAR(%SST(&SPLATTR 129 10)) VALUE(&HOLD))
                       IF         COND(&SAVE *NE *SAME) THEN(CHGVAR +
                                    VAR(%SST(&SPLATTR 139 10)) VALUE(&SAVE))
                       IF         COND(&DUPLEX *NE *SAME) THEN(CHGVAR +
                                    VAR(%SST(&SPLATTR 561 10)) VALUE(&DUPLEX))
                       IF         COND(&NEWUSER *NE *SAME) THEN(CHGVAR +
                                    VAR(%SST(&SPLATTR 59 10)) VALUE(&NEWUSER))
          
                       CHGVAR     VAR(&JOBNAME) VALUE(%SST(&SPLATTR 49 10))
                       CHGVAR     VAR(&JOBUSER) VALUE(%SST(&SPLATTR 59 10))
          
                       IF         COND(&NEWSPLNAME *EQ *JOBNAME) THEN(CHGVAR +
                                    VAR(&NEWSPLNAME) VALUE(&JOBNAME))
                       IF         COND(&NEWSPLNAME *EQ *USER) THEN(CHGVAR +
                                    VAR(&NEWSPLNAME) VALUE(&JOBUSER))
          
                       IF         COND(&NEWSPLNAME *NE *SAME) THEN(CHGVAR +
                                    VAR(%SST(&SPLATTR 75 10)) VALUE(&NEWSPLNAME))
          
                       /*   Create Spooled file     */
          
                       CALL       PGM(QSPCRTSP) PARM(&HANDLE &SPLATTR +
                                    X'00000000')
          
                       /*   Put Spooled File data   */
          
                       CALL       PGM(QSPPUTSP) PARM(&HANDLE &USPQUAL +
                                    X'00000000')
          
                       /*   Close Spooled file      */
          
                       CALL       PGM(QSPCLOSP) PARM(&HANDLE X'00000000')
          
                       /*  Retrieve  User space HEADER  information   */
          
                       CHGVAR     VAR(%BIN(&STARTPOS)) VALUE(1) /* set start +
                                    position */
                       CHGVAR     VAR(%BIN(&DATALEN)) VALUE(140) /* set data +
                                    length    */
          
                       CALL       PGM(QUSRTVUS) PARM(&USPQUAL &STARTPOS +
                                    &DATALEN &HEADER)
          
                       DLTUSRSPC  USRSPC(&USPLIB/&USPNAME)
          
                       CHGVAR     VAR(&INDIC) VALUE(%SST(&HEADER 87 1))
                       IF         COND(&INDIC *EQ C) THEN(DO)
                       SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Spooled +
                                    file' *BCAT &SPLFILE *BCAT 'duplicated') +
                                    MSGTYPE(*COMP)
                       ENDDO
                       ELSE       CMD(DO)
                       SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Spooled +
                                    file' *BCAT &SPLFILE *BCAT 'not +
                                    completely duplicated') MSGTYPE(*ESCAPE)
                       ENDDO
          
                       /*  Delete Original Spooled File   */
          
                       IF         COND(&DLTSPLF *EQ *NO) THEN(RETURN)
          
                       IF         COND(&JOB *EQ '*') THEN(RTVJOBA +
                                     JOB(&JOBNAME) USER(&JOBUSER) NBR(&JOBNBR))
                       ELSE       CMD(DO)
                          CHGVAR     VAR(&JOBNAME)   VALUE(%SST(&JOB 1 10))
                          CHGVAR     VAR(&JOBUSER)   VALUE(%SST(&JOB 11 10))
                          CHGVAR     VAR(&JOBNBR)    VALUE(%SST(&JOB 21 6))
                       ENDDO
          
                       IF         COND(%BIN(&SPLNBRBIN) *EQ 0) THEN(CHGVAR +
                                    VAR(&SPLNBRCHR) VALUE(*ONLY))
                       IF         COND(%BIN(&SPLNBRBIN) *EQ -1) THEN(CHGVAR +
                                    VAR(&SPLNBRCHR) VALUE(*LAST))
                       IF         COND(%BIN(&SPLNBRBIN) *GT 0) THEN(DO)
                          CHGVAR     VAR(&SPLNBRDEC) VALUE(%BIN(&SPLNBRBIN))
                          CHGVAR     VAR(&SPLNBRCHR) VALUE(&SPLNBRDEC)
                       ENDDO
                       DLTSPLF    FILE(&SPLFILE) +
                                    JOB(&JOBNBR/&JOBUSER/&JOBNAME) +
                                    SPLNBR(&SPLNBRCHR)
                       MONMSG     MSGID(CPF0000)
          
           END:        ENDPGM
          LP Zdenko
          LP Zdenko

          Comment

          sponsored links

          Collapse

          Working...
          X