ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

AS400 Report Generation

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

  • AS400 Report Generation

    Can any one help me to solve my problem in report generation?
    i have one printer file defined in F spec. there are 7 record formats in that file. In RPGLE , is it possible to 'WRITE' one same record format of Printer file in 2 modules?

    Please help me!!!!
    Thanks

  • #2
    anything is possible

    Would you explain in a bit more detail what you are doing. If possible post some of your code.


    Thanks
    Jimmy


    __________________
    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


    • #3
      I am writing a RPGLE program where i am using a Printer File.
      This printer file have 7 record formats. in RPGLE i am coind 7 modules which will be bound at complie time.
      my question is, is it possible to 'Write Printer Record format Name' in all the modules as per the need?
      can one single record format be used in more than 1 Module !

      it is not possible for me to attach any code!!!! sorry
      Thanks

      Comment


      • #4
        I can do it but it prints multiple reports

        I have attached a simple example



        I think if you play around with CLLE program to do
        Override with Printer File (OVRPRTF)

        and look at field/value
        Share open data path . . . . . . *NO, *YES

        change to *YES this may allow to write to one spooled file instead of creating a new one.

        Yep this only creates one printfile

        Code:
        pgm                                                                       
                                                                                  
                                                                                  
                     OVRPRTF    FILE(TESTP) USRDTA(SHARED) SHARE(*YES)            
                     call testr
        thanks
        Jamie
        Attached Files
        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
          i'm not able to download the printfile.
          can u copy the code and send !!
          also can u tell, if the same record format is used in different modules, which is bound at complie time, will it print multiple reports????
          Thanks

          Comment


          • #6
            You cant download Y?

            Why cant you download its just a text file?

            Let me know


            thanks
            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


            • #7
              when i click the downloadable file, it opens a new empty browser!!!!

              Thanks
              Revthy

              Comment


              • #8
                okay - Basically you just have to....

                Include the print file in each module.

                Then just write to it as normal


                wrap the entire mess in a CLLE program that does the OVRPRTF command I posted earlier.


                Then all will work.

                module (center field)
                Code:
                     fTESTP     O    e             printer OFLIND(*IN66)
                      * Parameters
                      *       Centered Data         Char 80    Output
                      *       Data to be Centered   Char 80    Input
                      *       Length of fld in
                      *        which to center      Num  3,0   Input
                
                      * Indicator Usage
                      *   None
                
                      *   The CENTFLD_CP copy member should be used by programs that call this subprocedure
                      *   to obtain the procedure prototype fields.
                
                      /copy source,CENTFLD_CP
                
                     d Data            s             80
                     d NameLen         s              3p 0
                     d PmCData         s             80
                     d StrPos          s              3p 0
                
                      * Begin Procedure
                     P CentFldO        B                   export
                
                      * Procedure Interface
                     d CentFldO        pi            80
                     d PmData                        80    value
                     d PmFldLen                       3p 0 value
                
                
                     c                   clear                   PmCData
                
                     c                   eval      Data = %trim(PmData)
                     c                   eval      NameLen = %len(%trim(Data))
                     c                   eval      StrPos = %div((PmFldLen-NameLen):2)
                     c                   eval      PmCData = %replace(Data:PmCData:StrPos+1:
                     c                             PmFldLen)
                
                     c                   eval      field = 'This written from CENTFLD'
                     c                   write     Detail
                     c                   if        1 = 2
                     c                   eval      *INlr = *On
                     c                   endif
                
                     c                   return    PmCData
                
                     p CentFldo        E
                This is the copy book
                Code:
                * CentFld  - copy member for centering data passed into fld length passed
                      *          - contains procedure prototypes
                
                     d CentFldo        pr            80
                     d PmData                        80    value
                     d PmFldLen                       3p 0 value

                This is RPGLE program
                Code:
                fTESTP     O    e             printer OFLIND(*IN66)
                     d Title           s             50
                     d WorkData        s             45    inz('some data')
                
                      /copy source,CENTFLD_CP
                
                      * =====================================
                      * M A I N   L I N E
                      * =====================================
                      *
                     c                   eval      Field = 'Jamie was here'
                     c                   write     detail
                
                     c                   eval      Title = CentFldo(%trim(WorkData):
                     c                              %len(Title))
                
                
                      *
                     c                   eval      *INLR = *On
                The print file ......
                Code:
                     A          R HEADER
                    
                     A                                     2
                     A                                      DATE
                     A                                      EDTWRD('0  /  /  ')
                     A                                      SKIPB(001)
                     A                                    +1
                     A                                      TIME
                     A                                      EDTWRD('0  :  :  ')
                     A                                   +12
                     A                                      'some report'
                     A                                    70
                     A                                      'PAGE:'
                     A                                    +1
                     A                                      PAGNBR
                     A                                      EDTCDE(Z)
                     A            @PGM          10A  O    70
                     A                                      SPACEB(001)
                 
                     A          R DETAIL
                     A                                      SPACEB(001)
                     A            FIELD         38A  O     7
                And the code for the CLLE program is posted up above (to allow for use of only one spooled file)


                Thanks
                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


                • #9
                  How can i create a CLLE program to hard code the values for 26 variables and to call a pgm from the CLLE pgm!

                  if possible Provide with some examples..

                  Thanks
                  Revthy

                  Comment


                  • #10
                    I posted all the source

                    Not sure what you are asking....I posted example of one module, one rpgle program and a print file......

                    The CLLE is just used to call the RPGLE program that includes all of the modules.

                    I only included one module for time sake..

                    I also posted the CLLE program if you bring all these down to your system and create you will see that both the RPGLE program and the module (CENTFLD) both write to the same printer file.


                    Please take the time and copy the source down to your system and run through a couple of tests...


                    If you dont want to wrap in CLLE program then just look for an example on the site of QCMDEXC You can use this inside the RPGLE program to run the ovrprtf command (you must define the pritfile as usropn in the F spec.) and that will give you what you want.


                    good luck
                    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


                    • #11
                      i am very much impressed with the responses.
                      but my last question was something not related to all my previous doubts.

                      i have to debug a program for which i have to pass 26 parameters at command line, instead i am planning to create a CLLE program where i can hard code the values and can call the PGM. how can define those in CLLE pgm, since i have no prior exp, please help..

                      Thanks
                      Revthy

                      Comment


                      • #12
                        Sorry its better to start a new thread

                        Code:
                        
                                   PGM        PARM(&PARM1 &PARM2 &PARM3 &PARM4)                          
                                                                                                         
                                                                                                         
                                   DCL        VAR(&PARM1) TYPE(*CHAR) LEN(12)                            
                                   DCL        VAR(&PARM2) TYPE(*CHAR) LEN(2)                             
                                   DCL        VAR(&PARM3) TYPE(*CHAR) LEN(10)                            
                                   DCL        VAR(&PARM4) TYPE(*DEC) LEN(15 5)                           
                                    
                                   CHGVAR &PARM1 'JAMIE'
                                   CHGVAR &PARM2 'PIZZA'
                                   CHGVAR &PARM3 'GOOD'
                                   CHGVAR &PARM4 123 
                                                                                             
                                   CALL       PGM(RPGPGM) PARM(&PARM1 &PARM2 &PARM3 &PARM4)              
                                                                                                         
                                   ENDPGM
                        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

                        Working...
                        X