ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

moving spool files

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

  • moving spool files

    fellows,

    I am trying to move spool files but a little differently then using something like a movsplf tool(because that wont work for what I need to do) I am trying to figure out how to whip up a CL and I need a push.

    In short, each day we have a job that creates a outq that corresponds to today date in julian, so today would be outq 168

    what I would like to do is move all the spool files from all the different outq's we use during a given work day into that julian date outq. (ex. prt01 files would go to 168 prt02 files would go to 168 and tommorrow prt01 files would go to 169 and so on you get the idea

    the thing I am having trouble with is how do i tell the program to id the current day ?

    I tried popping out sysval vals dsping the objd reading fields for creation dates trying to use the rvtjoba I just don't know how to get it to find today outq to tell it to move spool files from all these different outqs

    any ideas?
    Piper with the Camden County Emerald Society Pipes and Drums
    Check us out
    http://www.ccespd.org

    The Dodge Coronet Registry
    http://www.dodgecoronet.com

  • #2
    Re: moving spool files

    Hey Piper:

    Jamie has this on the main page under ReRoute spool files:


    I beleive SPLF0300 contains the create date.

    That should be a start for you
    Best of Luck
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

    Comment


    • #3
      Re: moving spool files

      I did see that link, thanks for posting it. I just don't know enough about it to pop in on my box and make it work or tweek it down the line
      Piper with the Camden County Emerald Society Pipes and Drums
      Check us out
      http://www.ccespd.org

      The Dodge Coronet Registry
      http://www.dodgecoronet.com

      Comment


      • #4
        Re: moving spool files

        I know its not CL but you could wrap it in one


        give this a try just create two outq's in your library
        copy some spooled files into one and give it a test



        program name is MOVEOUTQ
        call looks like this

        Code:
        call moveoutq parm('JAMIELIB' 'JAMIEOUT' 'JAMIELIB' 'JJFOUTQ')
        look to variables for date & time spool created
        d OpenDate 7A
        d OpenTime 6A


        Code:
        À     *=======================================================================                     Ä
        À     * Program Name: MOVEOUTQ                                                                     Ä
        À     * Description : Read thru outqueue move spooled files if ITSTATUS in                         Ä
        &#192;     *               ITOUTQP <> *Blanks                                                           &#196;
        &#192;     * Written On  :                                                                              &#196;
        &#192;     *                                                                                            &#196;
        &#192;     *                                                                                            &#196;
        &#192;     * Modification                                                                               &#196;
        &#192;     * ~~~~~~~~~~~~                                                                               &#196;
        &#192;     * Date             Project Pgmr Description                                                  &#196;
        &#192;     * ~~~~~~~~         ~~~~~~~ ~~~~ ~~~~~~~~~~~                                                  &#196;
        &#192;     *June 22,2004                                                                                &#196;
        &#192;     *                                                                                            &#196;
        &#192;     *========================================================================                    &#196;
             h option(*srcstmt: *nodebugio)  dftactgrp(*no)
        
               //
               //  entry plist
               //
        
             d MOVEOUTQ        pr
             d  inFlibrary                   10
             d  inFoutq                      10
             d  inTlibrary                   10
             d  inToutq                      10
        
             d MOVEOUTQ        pi
             d  inFlibrary                   10
             d  inFoutq                      10
             d  inTlibrary                   10
             d  inToutq                      10
        
        &#192;     *                                                                                            &#196;
        &#192;     * Program Info                                                                               &#196;
        &#192;     *                                                                                            &#196;
             d PgmInfo        SDS
             d  @PgmName               1     10
             d  @Parms                37     39  0
             d  @MsgID                40     46
             d  @JobName             244    253
             d  @UserId              254    263
             d  @JobNbr              264    269  0
        &#192;     *                                                                                            &#196;
        &#192;     * API - List spooled files                                                                   &#196;
        &#192;     *                                                                                            &#196;
             d QUSLSPL         PR                  extpgm('QUSLSPL')
        &#192;     * required parameters                                                                        &#196;
             d   UsrSpc                      20A   const
             d   Format                       8A   const
             d   UserName                    10A   const
             d   QualOutQ                    20A   const
             d   FormType                    10A   const
             d   UserData                    10A   const
        &#192;     * optional group 1:                                                                          &#196;
             d   ErrorCode                32766A   options(*nopass: *varsize)
        &#192;     * optional group 2:                                                                          &#196;
             d   QualJob                     26A   options(*nopass) const
             d   FieldKeys                   10I 0 options(*nopass: *varsize)
             d                                     dim(9999)
             d   NumFields                   10I 0 options(*nopass) const
        &#192;     * optional group 3:                                                                          &#196;
             d   AuxStgPool                  10I 0 options(*nopass) const
        &#192;     * optional group 4:                                                                          &#196;
             d   JobSysName                   8A   options(*nopass) const
             d   StartCrtDate                 7A   options(*nopass) const
             d   StartCrtTime                 6A   options(*nopass) const
             d   EndCrtDate                   7A   options(*nopass) const
             d   EndCrtTime                   6A   options(*nopass) const
        &#192;     *                                                                                            &#196;
             d QUSCRTUS        PR                  extpgm('QUSCRTUS')
             d   UsrSpc                      20A   const
             d   ExtAttr                     10A   const
             d   InitialSize                 10I 0 const
             d   InitialVal                   1A   const
             d   PublicAuth                  10A   const
             d   Text                        50A   const
             d   Replace                     10A   const
             d   ErrorCode                32766A   options(*nopass: *varsize)
        &#192;     *                                                                                            &#196;
             d QUSPTRUS        PR                  extpgm('QUSPTRUS')
             d   UsrSpc                      20A   const
             d   Pointer                       *
        &#192;     *                                                                                            &#196;
             d QUSDLTUS        PR                  extpgm('QUSDLTUS')
             d   UsrSpc                      20A   const
             d   ErrorCode                32766A   options(*varsize)
        &#192;     *                                                                                            &#196;
             d p_UsrSpc        s               *
             d dsLH            DS                   based(p_UsrSpc)
             d                                      qualified
             d   Filler1                    103A
             d   Status                       1A
             d   Filler2                     12A
             d   HdrOffset                   10I 0
             d   HdrSize                     10I 0
             d   ListOffset                  10I 0
             d   ListSize                    10I 0
             d   NumEntries                  10I 0
             d   EntrySize                   10I 0
        &#192;     *                                                                                            &#196;
             d p_Entry         s               *
             d dsSF            DS                   based(p_Entry)
             d                                      qualified
             d   JobName                     10A
             d   UserName                    10A
             d   JobNumber                    6A
             d   SplfName                    10A
             d   SplfNbr                     10I 0
             d   SplfStatus                  10I 0
             d   OpenDate                     7A
             d   OpenTime                     6A
             d   Schedule                     1A
             d   SysName                     10A
             d   UserData                    10A
             d   FormType                    10A
             d   OutQueue                    10A
             d   OutQueueLib                 10A
             d   AuxPool                     10I 0
             d   SplfSize                    10I 0
             d   SizeMult                    10I 0
        &#192;     *                                                                                            &#196;
             d   TotalPages                  10I 0
             d   CopiesLeft                  10I 0
             d   Priority                     1A
             d   Reserved                     3A
        &#192;     *                                                                                            &#196;
             d dsEC            DS                  qualified
             d  BytesProvided                10I 0 inz(&#37;size(dsEC))
             d  BytesAvail                   10I 0 inz(0)
             d  MessageID                     7A
             d  Reserved                      1A
             d  MessageData                 240A
        &#192;     *                                                                                            &#196;
        &#192;     * constants                                                                                  &#196;
        &#192;     *                                                                                            &#196;
             d MYSPACE         c                   const('SPLFLIST  QTEMP     ')
             d Low             c                   const('abcdefghijklmnopqrstuvwxyz')
             d Up              c                   const('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
        &#192;     *                                                                                            &#196;
        &#192;     *  Field Definitions.                                                                        &#196;
        &#192;     *                                                                                            &#196;
             d OutQName        ds
             d   OutQ                        10A   inz(*blanks)
             d   OutQLib                     10A   inz(*blanks)
        &#192;     *                                                                                            &#196;
             d size            s             10I 0
             d sf              s             10I 0 inz(1)
             d pos             s              4  0
             d pos1            s              4  0
             d Len             s              4  0
             d Loop            s              1    inz('Y')
        &#192;     *                                                                                            &#196;
             d CmdString       s            256    inz(*blanks)
             d CmdLength       s             15  5 inz(0)
        &#192;     *                                                                                            &#196;
             d IFSPDFName      s           2500    inz(*blanks)
             d IFSHTMName      s           2500    inz(*blanks)
             d JobInfo         s            256    inz(*blanks)
             d IFSFName        s            256    inz(*blanks)
             d FTPFName        s            256    inz(*blanks)
             d wSPLFName       s             10    inz(*blanks)
             d wJobName        s             10    inz(*blanks)
             d wUserData       s             10    inz(*blanks)
             d EMLSubject      s            256    inz(*blanks)
             d EMLMessage      s          15000    inz(*blanks)
             d EMLAddress      s            256    inz(*blanks)
        &#192;     *                                                                                            &#196;
        &#192;     *========================================================================                    &#196;
        &#192;     * MAIN LINE                                                                                  &#196;
        &#192;     *========================================================================                    &#196;
        &#192;     *                                                                                            &#196;
        &#192;     *  Read thru the ITOUTQ table and look for ITSTATUS <> *Blanks                               &#196;
        &#192;     * If found then use the To-OutQueue and Library to move the spooled Files                    &#196;
        &#192;     *                                                                                            &#196;
             c                   eval      OutQ    = infoutq
             c                   eval      OutQLib = inflibrary
             c                   exsr      $GetSPLFList
        &#192;     *                                                                                            &#196;
             c                   eval      *inlr = *on
             c                   return
        &#192;     *========================================================================                    &#196;
        &#192;     * $GetSPLFList - Get Spooled File List                                                       &#196;
        &#192;     *========================================================================                    &#196;
             c     $GetSPLFList  begsr
        &#192;     *                                                                                            &#196;
        &#192;     * set this to zero to let OS/400 handle errors                                               &#196;
        &#192;     *                                                                                            &#196;
             c                   eval      dsEC.BytesProvided = 0
        &#192;     *                                                                                            &#196;
        &#192;     * Make space for (approx) 1000 spooled files to be listed                                    &#196;
        &#192;     *                                                                                            &#196;
             c                   eval      size = %size(dsLH) + 512 +
             c                                    (%size(dsSF) * 1000)
        &#192;     *                                                                                            &#196;
        &#192;     * Create a user space                                                                        &#196;
        &#192;     * List spooled files to the user space                                                       &#196;
        &#192;     * Get a pointer to the returned user space                                                   &#196;
        &#192;     *                                                                                            &#196;
              /free
                 // Create a user space
                 QUSCRTUS(MYSPACE: 'USRSPC': size: x'00': '*ALL':
                  'Temp User Space for QUSLSPL API':  '*YES': dsEC);
        
                 // List spooled files to the user space
                 QUSLSPL(MYSPACE: 'SPLF0300': '*ALL': OutQName:
                    '*ALL': '*ALL': dsEC);
        
                 // Get a pointer to the returned user space
                 QUSPTRUS(MYSPACE: p_UsrSpc);
              /end-free
        &#192;     *                                                                                            &#196;
        &#192;     * Loop through list, for each spooled file, display the                                      &#196;
        &#192;     * Status: 1=RDY , 2=OPN, 3=CLO, 4=SAV, 5=WRT, 6=HLD,                                         &#196;
        &#192;     *         7=MSGW, 8=PND, 9=PRT,10=FIN,11=SND,12=DFR                                          &#196;
        &#192;     *                                                                                            &#196;
             c                   eval      p_Entry = p_UsrSpc + dsLH.ListOffset
             c                   eval      sf = 1
             c                   dow       sf <= dsLH.NumEntries
        &#192;     *                                                                                            &#196;
        &#192;     * currently only move status = 1 ready                                                       &#196;
        &#192;     *                                                                                            &#196;
             c                   if        dsSF.SplfStatus = 1
             c                   exsr      $MoveSplf
             c                   endif
        &#192;     *                                                                                            &#196;
             c                   eval      p_Entry = p_Entry + dsLH.EntrySize
             c                   eval      sf = (sf + 1)
             c                   enddo
        &#192;     *                                                                                            &#196;
        &#192;     * delete user space                                                                          &#196;
        &#192;     *                                                                                            &#196;
              /free
                  QUSDLTUS(MYSPACE: dsEC);
              /end-free
        &#192;     *                                                                                            &#196;
        &#192;     *                                                                                            &#196;
             c                   endsr
        &#192;     *========================================================================                    &#196;
        &#192;     * $MoveSplF  - Move the spooled file                                                         &#196;
        &#192;     *========================================================================                    &#196;
             c     $MoveSPlf     begsr
        &#192;     *                                                                                            &#196;
             c                   eval      JobInfo =
             c                             %trim(dsSF.JobNumber) +
             c                             %trim('/') + %trim(dsSF.UserName) +
             c                             %trim('/') + %trim(dsSF.JobName)
        &#192;     *                                                                                            &#196;
             c                   eval      wSPLFName = dsSF.SplfName
             c                   eval      wJobName  = dsSF.JobName
             c                   eval      wUserData = dsSF.UserData
        &#192;     *                                                                                            &#196;
        &#192;     * Move the spool file                                                                        &#196;
        &#192;     * CHGSPLFA FILE(QPSUPRTF) JOB(546777/FLANARY/QPADEV0041)                                     &#196;
        &#192;     * SPLNBR(*LAST) CRTDATE(*LAST)  OUTQ(JAMIELIB/JAMIEOUT)                                      &#196;
        &#192;     *                                                                                            &#196;
             c                   eval      CmdString =  'CHGSPLFA' +
             c                             ' FILE(' + %trim(wSPLFName)+ ')'+
             c                             ' JOB('  + %trim(JobInfo) + ')'+
             c                             ' SPLNBR(' +
             c                             %trim(%char(dsSF.SplfNbr)) + ')'   +
             c                             ' OUTQ(' + %Trim(intlibrary)  + '/' +
             c                             %trim(intoutq)  + ')'
        
             c                   eval      CmdString = %xlate('~' : ' ' : CmdString)
             c                   eval      CmdLength = %len(%trim(CmdString))
        &#192;     *                                                                                            &#196;
        &#192;     * Move the spooled file ...                                                                  &#196;
        &#192;     *                                                                                            &#196;
             c                   call(e)   'QCMDEXC'
             c                   parm                    CmdString
             c                   parm                    CmdLength
        &#192;     *                                                                                            &#196;
             c                   endsr
        &#192;     *========================================================================                    &#196;
        &#192;     * Initialization                                                                             &#196;
        &#192;     *========================================================================                    &#196;
             c     *inzsr        begsr
        &#192;     *                                                                                            &#196;
        &#192;     *                                                                                            &#196;
             c                   endsr
        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: moving spool files

          ok, I will pop it up on my test box and knock it around


          thanks!
          Piper with the Camden County Emerald Society Pipes and Drums
          Check us out
          http://www.ccespd.org

          The Dodge Coronet Registry
          http://www.dodgecoronet.com

          Comment


          • #6
            Re: moving spool files

            I am getting sev 30 errs on the compile

            Code:
            *RNF3751 30      1 External procedure on prototype for main procedure is not         
                               same as actual external name.

            there are a bunch of other comments and errors, I just don't know enough about it to troubleshoot it and make it work


            thanks anyway fellows
            Piper with the Camden County Emerald Society Pipes and Drums
            Check us out
            http://www.ccespd.org

            The Dodge Coronet Registry
            http://www.dodgecoronet.com

            Comment


            • #7
              Re: moving spool files

              just name the program MOVEOUTQ

              and compile (thats all the error is telling ya)
              what version of os are you on?


              or change the name here
              Code:
                     //
                     //  entry plist
                     //
              
                   d MOVEOUTQ        pr
                   d  inFlibrary                   10
                   d  inFoutq                      10
                   d  inTlibrary                   10
                   d  inToutq                      10
              
                   d MOVEOUTQ        pi
                   d  inFlibrary                   10
                   d  inFoutq                      10
                   d  inTlibrary                   10
                   d  inToutq                      10
              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


              • #8
                Re: moving spool files

                v5r4. OK maybe I will learn something here, when I compile it with "RPG" the code looks like what you posted, when I compile it with "RPGLE" I loose the &#192; all the way down in the left hand column, the program name is the same now (i add a C to all the end off mine...)

                here are the errors now if I complie it as "RPG"



                Code:
                * QRG2001 Severity:  30   Number:  183                                                                                            
                          Message . . . . :   Form-Type entry invalid or out of sequence.                                                         
                            Specification ignored.                                                                                                
                * QRG7023 Severity:  40   Number:    1                                                                                            
                          Message . . . . :   The Compiler cannot determine how program can                                                       
                            terminate. Program will loop.                                                                                         
                      * * * * *   E N D   O F   M E S S A G E   S U M M A R Y   * * * * *                                                         
                 5722WDS V5R4M0  060210                IBM RPG/400                       PIPER/MOVOUTQ       06/17/08  10:54:17      Page      17
                                           F i n a l   S u m m a r y                                                                              
                 Message Count:  (by Severity Number)                                                                                             
                            TOTAL    00     10     20     30     40     50                                                                        
                            184       0      0      0    183      1      0                                                                        
                 Program Source Totals:                                                                                                           
                    Records . . . . . . . . . . :   280                                                                                           
                    Specifications  . . . . . . :   183                                                                                           
                    Table Records . . . . . . . :   0                                                                                             
                    Comments  . . . . . . . . . :   97                                                                                            
                 Compile stopped. Severity level 40 errors found in file.                                                                         
                          * * * * *   E N D   O F   C O M P I L A T I O N   * * * * *
                Piper with the Camden County Emerald Society Pipes and Drums
                Check us out
                http://www.ccespd.org

                The Dodge Coronet Registry
                http://www.dodgecoronet.com

                Comment


                • #9
                  Re: moving spool files

                  Hi Piper:

                  I'll give it a shot but it's flying blind.

                  1. The source type should be RPGLE
                  2. The source member name should be MOVEOUTQ
                  3. edit the source using option 2 in pdm If you do NOT see the following then the source was not down loaded properly:

                  *************** Beginning of data *************************************
                  0001.00 *==============================================
                  0002.00 * Program Name: MOVEOUTQ
                  0003.00 * Description : Read thru outqueue move spooled files if ITSTATUS in
                  0004.00 * ITOUTQP <> *Blanks
                  0005.00 * Written On :
                  0006.00 *
                  0007.00 *
                  0008.00 * Modification
                  0009.00 * ~~~~~~~~~~~~
                  0010.00 * Date Project Pgmr Description
                  0011.00 * ~~~~~~~~ ~~~~~~~ ~~~~ ~~~~~~~~~~~
                  0012.00 *June 22,2004
                  0013.00 *
                  0014.00 *==============================================
                  0015.00 h option(*srcstmt: *nodebugio) dftactgrp(*no)
                  Use option 14 to compile and let us know where you stand

                  Thanks
                  GLS
                  The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

                  Comment


                  • #10
                    Re: moving spool files

                    that worked, I kept trying to compile it as RPG and the "E" was missing from my pgm name. Good catch..ok..time to knock it around a bit!
                    Piper with the Camden County Emerald Society Pipes and Drums
                    Check us out
                    http://www.ccespd.org

                    The Dodge Coronet Registry
                    http://www.dodgecoronet.com

                    Comment


                    • #11
                      Re: moving spool files

                      very cool, it works! ok now I need ta figure out how ta wrap a CL around the whole thing and make it operator friendly
                      Piper with the Camden County Emerald Society Pipes and Drums
                      Check us out
                      http://www.ccespd.org

                      The Dodge Coronet Registry
                      http://www.dodgecoronet.com

                      Comment


                      • #12
                        Re: moving spool files

                        I couldn't figure out why it wouldnt work...until I passed the parms in all caps ...lol

                        ok now I got that to work...how do I tell it to always use the current day outq to pass the spool files to? I bet its in them

                        d OpenDate 7A
                        d OpenTime 6A

                        varibles just wouldn't know how to manipulate them and put that in the parm to capture the current date somehow...
                        Last edited by Piper; June 17, 2008, 12:45 PM.
                        Piper with the Camden County Emerald Society Pipes and Drums
                        Check us out
                        http://www.ccespd.org

                        The Dodge Coronet Registry
                        http://www.dodgecoronet.com

                        Comment


                        • #13
                          Re: moving spool files

                          I think I figure it out, Tommy had helped me with a CL a while back

                          I should be able to use some flavor of this to find that date and pass it to the movespool pgm


                          this puppy finds the outq/date........

                          Code:
                          PGM PARM(&INDATE)                                         
                                                                                    
                            DCL VAR(&INDATE) TYPE(*CHAR) LEN(7)                     
                            DCL VAR(&DATE  ) TYPE(*CHAR) LEN(6)                     
                            DCL VAR(&JUL   ) TYPE(*CHAR) LEN(5)                     
                            DCL VAR(&JULDAY) TYPE(*CHAR) LEN(4)                     
                            DCL VAR(&OUTQ  ) TYPE(*CHAR) LEN(10)                    
                                                                                    
                            /* 1010101 = SPECIAL VALUE THAT MEANS "TODAY" */        
                                                                                    
                            IF (&INDATE *EQ '1010101') DO                           
                                RTVSYSVAL SYSVAL(QDATE) RTNVAR(&DATE)               
                                CVTDAT DATE(&DATE) TOVAR(&JUL) FROMFMT(*SYSVAL) +   
                                       TOFMT(*JUL) TOSEP(*NONE)                     
                            ENDDO                                                   
                            ELSE DO                                                 
                                CVTDAT DATE(&INDATE) TOVAR(&JUL) FROMFMT(*CYMD) +   
                                       TOFMT(*JUL) TOSEP(*NONE)                     
                            ENDDO                                                   
                              CHGVAR VAR(&JULDAY) VALUE(%SST(&JUL 3 3))             
                              CHGVAR VAR(&OUTQ) VALUE('WD' *CAT &JULDAY)            
                              WRKOUTQ OUTQ(&OUTQ)                  
                          
                          ENDPGM
                          Piper with the Camden County Emerald Society Pipes and Drums
                          Check us out
                          http://www.ccespd.org

                          The Dodge Coronet Registry
                          http://www.dodgecoronet.com

                          Comment


                          • #14
                            Re: moving spool files

                            i hate to be nit-picky but...why &#37;trim('/') just use '/' the %trim() just adds extra overhead to something that doesn't (and will never) have blanks to trim???
                            I'm not anti-social, I just don't like people -Tommy Holden

                            Comment


                            • #15
                              Re: moving spool files

                              You must be talking about the RPG piece. The only trim I am missing is on my '67 Coronet lol

                              so you can't really pass a CL varible to a RPG huh?

                              I tried adding this line to the above CL pgm makes sense in theory

                              CALL MOVEOUTQ PARM('PIPER' 'PIPEROUTQ' 'PROD' '(&OUTQ))'

                              &outq being the current days outq.
                              Piper with the Camden County Emerald Society Pipes and Drums
                              Check us out
                              http://www.ccespd.org

                              The Dodge Coronet Registry
                              http://www.dodgecoronet.com

                              Comment

                              Working...
                              X