ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Total Number of Pages

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

  • #16
    Re: Total Number of Pages

    You guys........ like killing a Mosquito with a cannon!
    check out the attached PDF for output....

    Print File
    PHP Code:
         A*%%***********************************************************************
         
    A*%%TS  RD  20101222  081636  FLANARY     REL-V5R4M0  5722-WDS
         A
    *%%FI+10660100000000000000000000000000000000000000000000000000
         A
    *%%FI       0000000000000000000000000000000000000000000000000
         A
    *%%***********************************************************************
          **************************************************************************
         
    A          R HEADER
         A
    *%%***********************************************************************
         
    A*%%RI 00000
         A
    *%%***********************************************************************
         
    A                                      SKIPB(001)
         
    A            PAGES         15A  O    65
         A                                      SPACEB
    (001)
         
    A                                     2
         A                                      DATE
         A                                      EDTWRD
    ('0  /  /  ')
         
    A                                   +21
         A                                      
    'My Company'
         
    A            P1PROGRAM     10A  O    65
         A                                      SPACEB
    (001)
         
    A                                     2
         A                                      TIME
         A                                      EDTWRD
    ('0  :  :  ')
         
    A                                   +16
         A                                      
    'List System Outqueues'
         
    A                                     5
         A                                      
    'Outq'
         
    A                                      SPACEB(003)
         
    A                                      HIGHLIGHT
         A                                      UNDERLINE
         A                                   
    +10
         A                                      
    'Description'
         
    A                                      HIGHLIGHT
         A                                      UNDERLINE
         A
    *%%***********************************************************************
         
    A*%%SS
         A
    *%%CL 001
         A
    *%%SN PAGES      xxxxxxxxxxxxxxx
         A
    *%%CL 001
         A
    *%%CL 003
         A
    *%%***********************************************************************
         
    A          R DETAIL
         A
    *%%***********************************************************************
         
    A*%%RI 00000 
         A
    *%%***********************************************************************
         
    A                                      SPACEB(001)
         
    A            P1OUTQ        10A  O     5
         A            P1DESC        29A  O    
    +4
         A
    *%%***********************************************************************
         
    A*%%SS
         A
    *%%CL 001
         A
    *%%SN P1OUTQ     xxxxxxxxxx
         A
    *%%SN P1DESC     xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
         A
    *%%CL 001
         A
    *%%***********************************************************************
          **************************************************************************
         
    A          R ENDRPT
         A
    *%%***********************************************************************
         
    A*%%RI 00000
         A
    *%%***********************************************************************
         
    A                                      SPACEB(001)
         
    A                                    30
         A                                      
    '****End Of Report****'
         
    A*%%***********************************************************************
         
    A*%%SS
         A
    *%%CP+999CRTPRTF
         A
    *%%CP+    FILE(LBISRC/LOP06AP)
         
    A*%%CP+    DEVTYPE(*SCS)
         
    A*%%CP     PAGESIZE(*N       080      *N     )
         
    A*%%*********************************************************************** 
    RPG
    PHP Code:
         H Option(*SrcStmt: *NoDebugIODftActGRP(*No)
          *=======================================================================
          * 
    PROGRAM -
          * 
    PURPOSE - print list of outqueues
          
    WRITTEN -
          * 
    AUTHOR  AS400Pro
          
    *
          * 
    PROGRAM DESCRIPTION
          
    *   This program will print list of system outq's
          *
          *
          * INPUT PARAMETERS
          *   Description        Type  Size    How Used
          *   -----------        ----  ----    --------

          * AUTHORITY PARAMETERS
          *   Description                      How Used
          *   -----------                      --------
          *
          * INDICATOR USAGE
          *
          *========================================================================
         FPAGESAP   o    e             printer usropn   oflind(*in75)
         F                                              infds(PrintFDS)
          *
          * Program Info
          *
         d                SDS
         d  @PGM                 001    010
         d  @PARMS               037    039  0
         d  @MSGDTA               91    170
         d  @MSGID               171    174
         d  @JOB                 244    253
         d  @USER                254    263
         d  @JOB#                264    269  0

         d PrintFDS        ds
         d RecordFmt         *RECORD
         d LineNumber            367    368I 0
         d PageNumber            369    372I 0
         À*
         À*  Field Definitions.
         À* ~~~~~~~~~~~~~~~~~~~~~~~~
         d cmdstring       s            512
         d cmdlength       s             15  5
         d AllText         s             10    Inz('
    *ALL')
         d Count           s              4  0
         d Format          s              8
         d GenLen          s              8
         d InLibrary       s             10
         d InType          s             10
         d ObjectLib       s             20
         d SpaceVal        s              1    inz(*BLANKS)
         d SpaceAuth       s             10    inz('
    *CHANGE')
         d SpaceText       s             50    inz(*BLANKS)
         d SpaceRepl       s             10    inz('
    *YES')
         d SpaceAttr       s             10    inz(*BLANKS)
         d TotalPages      s              4  0 inz
         d UserSpaceOut    s             20
         d Worktype        s             10    inz('
    *OUTQ')
         D ObjNam          s             10a
         D ObjLib          s             10a
         D ObjTyp          s             10a
    À     *                                                                                            Ä
    À     * GenHdr                                                                                     Ä
    À     *                                                                                            Ä
         d GenHdr          ds                  inz
         d  OffSet                 1      4B 0
         d  NumEnt                 9     12B 0
         d  Lstsiz                13     16B 0
    À     *                                                                                            Ä
    À     *  Data structures                                                                           Ä
    À     *                                                                                            Ä
         d GENDS           ds
         d  OffsetHdr              1      4B 0
         d  NbrInList              9     12B 0
         d  SizeEntry             13     16B 0
          *
         d HeaderDs        ds
         d  OutFileNam             1     10
         d  OutLibName            11     20
         d  OutType               21     25
         d  OutFormat             31     40
         d  RecordLen             41     44B 0
          *
          * API Error Data Structure
          *
         d ErrorDs         DS                  INZ
         d  BytesPrv               1      4B 0
         d  BytesAvl               5      8B 0
         d  MessageId              9     15
         d  ERR###                16     16
         d  MessageDta            17    116
          *
         d                 DS
         d  StartPosit             1      4B 0
         d  StartLen               5      8B 0
         d  SpaceLen               9     12B 0
         d  ReceiveLen            13     16B 0
         d  MessageKey            17     20B 0
         d  MsgDtaLen             21     24B 0
         d  MsgQueNbr             25     28B 0
          *
          * Date structure for retriving userspace info
          *
         d InputDs         DS
         d  UserSpace              1     20
         d  SpaceName              1     10
         d  SpaceLib              11     20
         d  InpFileLib            29     48
         d  InpFFilNam            29     38
         d  InpFFilLib            39     48
         d  InpRcdFmt             49     58
          *
         d ObjectDs        ds                  Qualified
         d  Object                       10
         d  Library                      10
         d  ObjectType                   10
         d  InfoStatus                    1
         d  ExtObjAttrib                 10
         d  Description                  50

         **-- Retrieve object description:  -------------------------------
         d RtvObjD         Pr                  ExtPgm( '
    QUSROBJD' )
         d  RoRcvVar                  32767a         Options( *VarSize )
         d  RoRcvVarLen                  10i 0 Const
         d  RoFmtNam                      8a   Const
         d  RoObjNamQ                    20a   Const
         d  RoObjTyp                     10a   Const
         d  RoError                   32767a         Options( *VarSize )
         **-- List objects:   ---------------------------------------------
         d $ListObjects    Pr                  ExtPgm( '
    QUSLOBJ' )
         d  userspace                    20a   Const
         d  format                        8a   Const
         d  objectlib                    20a   Const
         d  type                         10a   Const
         **-- Userspace pointer: ------------------------------------------
         d $Userspace      Pr                  ExtPgm( '
    QUSRTVUS' )
         d  userspace                    20a   Const
         d  start                        10i 0 Const
         d  Length                       10i 0 Const
         d  Returned                  32767a         Options( *VarSize )
         **-- Create Space:   ---------------------------------------------
         d $CreateSpace    Pr                  ExtPgm( '
    QUSCRTUS' )
         d  UserSpaceOut                 20a   Const
         d  SpaceAttr                    10    Const
         d  SpaceLen                     10i 0 Const
         d  SpaceVal                      1a   Const
         d  SpaceAuth                    10a   Const
         d  SpaceText                    50a   Const
         d  SpaceRepl                    10a   Const
         d  ErrorDs                   32767a         Options( *VarSize )

          //
          //  external called programs
          //

         d $command        pr                  extpgm('
    QCMDEXC')
         d   command                    512
         d   Length                      15  5

          /free

                  p1program = @pgm;
                 // hold the printfile prior to opening
                  cmdstring = '
    OVRPRTF FILE(PAGESAPHOLD(*YES)';
                  cmdlength = %len(%trim(cmdstring));
                  $command(cmdstring:cmdlength);
                  open PAGESAP;
                  exsr $QUSCRTUS;

                  exsr $PrintOutQs;

                  TotalPages = PageNumber;
                  close PAGESAP;

                 // delete the "FAKE" printfile
                  cmdstring = '
    DLTSPLF FILE(PAGESAPSPLNBR(*LAST)';
                  cmdlength = %len(%trim(cmdstring));
                  $command(cmdstring:cmdlength);

                 // release the printfile prior to opening
                  cmdstring = '
    OVRPRTF FILE(PAGESAPHOLD(*YES)';
                  cmdlength = %len(%trim(cmdstring));
                  $command(cmdstring:cmdlength);
                  // print it for real now ;)
                  open PAGESAP;
                  pages = '
    1 of ' + %char(TotalPages);
                  exsr $PrintOutQs;

                  *inlr = *on;

            //--------------------------------------------------------
            // $PrintOutQs - print the outq'
    s
            
    //--------------------------------------------------------
                    
    begsr $PrintOutQs;

                     
    ObjectLib =  '*ALL      ' '*LIBL';
             
    //
             // List all the outqueues to the user space
             //
                     
    Format 'OBJL0200';
                     
    $ListObjectsUserspace Format ObjectLib WorkType);
             
    //
             // Retrive header entry and process the user space
             //
                     
    StartPosit 125;
                     
    StartLen   16;
                     
    $UserSpaceUserspace StartPosit StartLen GENDS);

                     
    StartPosit OffsetHdr 1;
                     
    StartLen = %size(ObjectDS);
             
    //
    À        // Do for number of outqueues in the userspace                            Ä
             //

                     
    write header;
    B1               for count 1 to  NbrInList;
                      
    $UserSpaceUserspace StartPosit StartLen ObjectDs);

                      
    p1outq objectds.object;
                      
    p1desc objectds.description;
                      
    // check overflow;

                      
    if *in75;
                       
    pages =  %char(PageNumber+1) + ' of '  + %char(TotalPages);
                       
    write header;
                       *
    in75 = *off;
                      endif;

                      
    write detail;

                      
    StartPosit += SizeEntry;
                     endfor;
                     
    write endrpt;
                    
    endsr;

            
    //--------------------------------------------------------
            // $QUSCRTUS - create userspace
            //--------------------------------------------------------
                     
    begsr $QUSCRTUS;

                      
    BytesPrv 116;
                      
    Spacename 'LISTOUTQS';
                      
    SpaceLib 'QTEMP';

                   
    //
                   // Create the user space
                   //
                      
    $CreateSpaceUserspace SpaceAttr 4096 :
                                    
    SpaceVal SpaceAuth SpaceText SpaceRepl:
                                    
    ErrorDs);
                     
    endsr;

          /
    end-free 
    Attached Files
    Last edited by jamief; December 22, 2010, 09:39 AM. Reason: change descriptions on printers ;)
    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


    • #17
      Re: Total Number of Pages

      Jamie,

      As you said you run the program twice so you're using the heavy artillery

      Did you notice what Scott said about ?

      Originally posted by SK
      Some people have suggested running the program twice, once to get the page count and once to do the actual printing. This isn't always practical, for a few reasons: some programs update files and can't be re-run; some programs take a very long time to run, and re-running them is not efficient. Sometimes the data you're reporting on will change, which can also cause the page count to change.
      Philippe

      Comment


      • #18
        Re: Total Number of Pages

        Philippe,

        You know I don't read
        You have to know when to use the right tool.

        jamie
        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


        • #19
          Re: Total Number of Pages

          Uh oh! I think Jamie used a little of that there "reindeer dust " on his Post Toaties this morning!

          Merry X-mas and a happy New Year to everyone,
          MdnghtPgmr
          "Tis better to be thought a fool then to open one's mouth and remove all doubt." - Benjamin Franklin

          Comment


          • #20
            Re: Total Number of Pages

            I use a bit of "reindeer dust" everyday....
            In old age i'm just enjoying it more.

            Merry Christmas back.

            jamie
            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


            • #21
              Re: Total Number of Pages

              Merry Xmas to everyone.

              God preserve your beauty and make your children have long necks !
              Philippe

              Comment


              • #22
                Re: Total Number of Pages

                Hi All

                I print it twice and close the issue as jamie said

                Once again Thanx a lot
                Magesh

                Comment

                Working...
                X