ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Dynamic Report Generation

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

  • Dynamic Report Generation

    Hi All,

    I have an requirement to generate the dynamic reports.

    I have to show the report of how many parts are sold on particular day. If i run the report on 19-Jun, then i need to show from Jun 1- to Jun 19 sold information date wise.


    The same report run on 25-jun then i need to show from Jun 1 to Jun 25.


    The sample report
    ~~~~~~~~~~~
    Code:
    [U]6/1        6/2        6/3        6/4/        6/5          Total [/U]
         10         3            5            7            7               26

    Is there any way to do like this?
    Regards,
    Vinothkumar S.

  • #2
    Re: Dynamic Report Generation

    1 question:
    What do you have in yourt file? Date obviously. Do you also have a period number?
    Regards

    Kit
    http://www.ecofitonline.com
    DeskfIT - ChangefIT - XrefIT
    ___________________________________
    There are only 3 kinds of people -
    Those that can count and those that can't.

    Comment


    • #3
      Re: Dynamic Report Generation

      Hi Kit,

      YEs, I have date field with no of sold parts.

      My probelm is Depending up on the date, I need to show only that much record with the Row total.


      For example if i run the report on 30 then i will get get the whole month data. No issues in printing.

      But if i run the report on 15, i will get 15 days data then in the 16th position i have to show the total value.
      Regards,
      Vinothkumar S.

      Comment


      • #4
        Re: Dynamic Report Generation

        Hi, vinomails

        If you do SQL, take a look at this PDF, not your answer, but it gives you a direction to go !

        Code:
        http://www.dugs.org.au/Presentations/Solving%20Business%20Problems%20with%20SQL.pdf
        
        http://mysite.verizon.net/Graeme_Birchall/cookbook/DB2V95CK.PDF
        Download:

        DB2 Solving Business Problems


        And the Bible (as good as) DB2 SQL Cookbook
        Last edited by Marc_d; June 19, 2008, 02:38 AM.

        Comment


        • #5
          Re: Dynamic Report Generation

          Calculate your start date.
          Code:
          select tstdte 
           
          from mylib.myfile  
           
          where tstdte between :start_date and :end_date
          order by whatever
          Regards

          Kit
          http://www.ecofitonline.com
          DeskfIT - ChangefIT - XrefIT
          ___________________________________
          There are only 3 kinds of people -
          Those that can count and those that can't.

          Comment


          • #6
            Re: Dynamic Report Generation

            Hi Kit,

            Thanks for the sample query. The problem with writing the report not with the data.

            If i run the report on 15th i need to show 15 columns in my report. As well if i run the report on 20th then i need to show 20 columns in my report. How can i achieve this.
            Regards,
            Vinothkumar S.

            Comment


            • #7
              Re: Dynamic Report Generation

              Hello,
              i am not really see your problem.
              It looks like a simple RPG/RPGLE for me.
              Lets say every-day-standard-crap-report.

              Here some Pseudocode for what i mean.
              PHP Code:
              RPG/RPGLE
              =========
              Assume that more than one record per day is found in file
              Program has defined 
              array for 31 days
              Program has defined 31 O
              -Specs one for each day
              Program has defined 1 O
              -Spec for "total"
              Program has defined 1 O-Spec for total-sum

              1. Input Fromdate 
              and Todate

              2. Take last day from Todate 
              (lets say 15)

                  
              Loop
              3. Read Inputfile 
              and seek what day

                  
              If beetween Fromdate and Todate 
              4. Add value of this record to 
              array and also add to summ field
                  
              Endif

                  
              Endloop

              5. 
              For 1 to Lastday (lets say 15
                 Print 
              report header [via O-Specs (cmd"except" for every day)]
                 
              End
                 
              6. 
              Print report header [via O-Specs (cmd"except")] for Total
                 
              Position is just +nn 
                 
              7. 
              For 1 to Lastday (lets say 15count as X
                 
              Print report values of days from array(X) [via O-Specs (cmd"except" for every day)] 
                 
              End
                 
              8. 
              Print report value of Total [via O-Specs (cmd"except")] for Total
                 
              Position is just +nn 

              Finished 
              Or did i understand not the problem?

              k.

              Comment


              • #8
                Re: Dynamic Report Generation

                It would seem that if this needs to be a "report", that the easiest way would be to setup 31 columns. Print the headings (dates) and the data (counts) from arrays. In the program populate the arrays only up to "today". So the right side of the report would be blank early in the month, and each day another column would "appear".

                Comment


                • #9
                  Re: Dynamic Report Generation

                  How many rows of data will be under each column? If you only have 1 row or two or three maybe, you could just reformat the report to be top-down instead of left-right. Then you could treat each day as a row of data and just have a total footer at the bottom. That's quite easy to set up and will look just as good if not better. You will have a lot less wasted white space so a lot less wasted paper, plus it will still be very readable.
                  Your future President
                  Bryce

                  ---------------------------------------------
                  http://www.bravobryce.com

                  Comment


                  • #10
                    Re: Dynamic Report Generation

                    Just use EDTCDE(Z) on all the fields
                    Regards

                    Kit
                    http://www.ecofitonline.com
                    DeskfIT - ChangefIT - XrefIT
                    ___________________________________
                    There are only 3 kinds of people -
                    Those that can count and those that can't.

                    Comment


                    • #11
                      Re: Dynamic Report Generation

                      Hi All,

                      Some how i fight with indicators and achieved my goal. I have attached the code. Please install in your box and test the same.

                      The inpur parameter would be number of columns. Just its a sample code. I am going to implement the same for my requirement.

                      Code:
                           FQSYSPRT   O    F  182        Printer
                           DSerrow           DS                  INZ
                           DWkday0                          4  0
                           DWkday1                          4  0
                           DWkday2                          4  0
                           DWkday3                          4  0
                           DWkday4                          4  0
                           DWkday5                          4  0
                           DWkday6                          4  0
                           DWkday7                          4  0
                           DWkday8                          4  0
                           DWkday9                          4  0
                           DWkday10                         4  0
                           DWktotal          S              4  0
                           C     *ENtry        Plist
                           C                   Parm                    R                 2
                           C                   Eval      wkday1 = 11
                           C                   Eval      wkday2 = 22
                           C                   Eval      wkday3 = 33
                           C                   Eval      wkday4 = 44
                           C                   Eval      wkday5 = 55
                           C                   Eval      wkday6 = 66
                           C                   Eval      wkday7 = 77
                           C                   Eval      wkday8 = 78
                           C                   Eval      wkday9 = 79
                           C                   Eval      wkday10 = 80
                           C                   Eval      wktotal = 80
                      
                           C                   Except    Hdrec
                           C                   Except    Detrec1
                           C                   Seton                                        Lr
                           C*
                           C     *Inzsr        Begsr
                           C                   Movea     '00'          *IN(01)
                           C                   Select
                           C                   When      R = '1'
                           C                   Movea     '1'           *IN(01)
                           C                   Seton                                        51
                           C                   When      R = '2'
                           C                   Movea     '11'          *IN(01)
                           C                   Movea     '00'          *IN(03)
                           C                   Seton                                        52
                           C                   When      R = '3'
                           C                   Movea     '111'         *IN(01)
                           C                   Movea     '00'          *IN(04)
                           C                   Seton                                        53
                           C                   When      R = '4'
                           C                   Movea     '1111'        *IN(01)
                           C                   Movea     '00'          *IN(05)
                           C                   Seton                                        54
                           C                   When      R = '5'
                           C                   Movea     '11111'       *IN(01)
                           C                   Movea     '00'          *IN(06)
                           C                   Seton                                        55
                           C                   When      R = '6'
                           C                   Movea     '111111'      *IN(01)
                           C                   Movea     '00'          *IN(07)
                           C                   Seton                                        56
                           C                   When      R = '7'
                           C                   Movea     '111111'      *IN(01)
                           C                   Movea     '00'          *IN(08)
                           C                   Seton                                        57
                           C                   When      R = '8'
                           C                   Movea     '11111111'    *IN(01)
                           C                   Movea     '00'          *IN(09)
                           C                   Seton                                        58
                           C                   When      R = '9'
                           C                   Movea     '111111111'   *IN(01)
                           C                   Movea     '00'          *IN(10)
                           C                   Seton                                        59
                           C                   When      R = '10'
                           C                   Movea     '1111111111'  *IN(01)
                           C                   Endsl
                           C
                           C                   Endsr
                           C*
                           OQSYSPRt   E            HDREC
                           O               01                          23 'day1'
                           O               51                          28 'Wktotal'
                           O               02                          28 'day2'
                           O               52                          33 'Wktotal'
                           O               03                          33 'day3'
                           O               53                          38 'Wktotal'
                           O               04                          38 'day4'
                           O               54                          43 'Wktotal'
                           O               05                          43 'day5'
                           O               55                          48 'Wktotal'
                           O               06                          48 'day6'
                           O               56                          53 'Wktotal'
                           O               07                          53 'day7'
                           O               57                          58 'Wktotal'
                           O               08                          58 'day8'
                           O               58                          63 'Wktotal'
                           O               09                          63 'day9'
                           O               59                          68 'Wktotal'
                           O               10                          68 'day10'
                           OQSYSPRt   E            Detrec1
                           O               01      Wkday1        Z     23
                           O               51      Wktotal       Z     28
                           O               02      Wkday2        Z     28
                           O               52      Wktotal       Z     33
                           O               03      Wkday3        Z     33
                           O               53      Wktotal       Z     38
                           O               04      Wkday4        Z     38
                           O               54      Wktotal       Z     43
                           O               05      Wkday5        Z     43
                           O               55      Wktotal       Z     48
                           O               06      Wkday6        Z     48
                           O               56      Wktotal       Z     53
                           O               07      Wkday7        Z     53
                           O               57      Wktotal       Z     58
                           O               08      Wkday8        Z     58
                           O               58      Wktotal       Z     63
                           O               09      Wkday9        Z     63
                           O               59      Wktotal       Z     68
                           O               10      Wkday10       Z     68
                      Regards,
                      Vinothkumar S.

                      Comment


                      • #12
                        Re: Dynamic Report Generation

                        Here's another quick way to do it, without indicators and MOVEA.

                        Code:
                             FQSYSPRT   O    F  182        Printer
                             F
                             D Head            S              6A   DIM(11)
                             D Data            S              4S 0 DIM(11)
                             D R               S              2S 0
                             D X               S              2S 0
                             D First           S              1A
                             D Wktotal         S              4  0
                             D
                             DSerrow           DS
                             D Wkday1                         4  0
                             D Wkday2                         4  0
                             D Wkday3                         4  0
                             D Wkday4                         4  0
                             D Wkday5                         4  0
                             D Wkday6                         4  0
                             D Wkday7                         4  0
                             D Wkday8                         4  0
                             D Wkday9                         4  0
                             D Wkday10                        4  0
                             D
                             D WkData                              Overlay(Serrow)
                             D                                     Like(Wkday1) Dim(10)
                             D*******
                             D
                             C     *ENtry        Plist
                             C                   Parm                    RA                2
                             C                   Eval      wkday1 = 11
                             C                   Eval      wkday2 = 22
                             C                   Eval      wkday3 = 33
                             C                   Eval      wkday4 = 44
                             C                   Eval      wkday5 = 55
                             C                   Eval      wkday6 = 66
                             C                   Eval      wkday7 = 77
                             C                   Eval      wkday8 = 78
                             C                   Eval      wkday9 = 79
                             C                   Eval      wkday10 = 80
                             C
                             C*************************************************************
                             C*  populate heading
                             C                   If        First = *blank
                             C                   Eval      X = 1
                             C                   Eval      R = %dec(RA:2:0)
                             C     1             Do        R
                             C                   Eval      Head(x) = 'day' + %char(X)
                             C                   Eval      X += 1
                             C                   EndDO
                             C                   Eval      Head(x) = 'WTotal'
                             C                   Except    HDREC
                             C                   Eval      First = 'X'
                             C                   EndIf
                             C*************************************************************
                             C*  populate data
                             C                   Eval      X = 1
                             C                   Eval      WkTotal = %xfoot(WkData)
                             C     1             Do        R
                             C                   Eval      Data(x) = WkData(X)
                             C                   Eval      X += 1
                             C                   EndDO
                             C                   Eval      Data(X) = WKtotal
                             C                   Except    Detrec1
                             C
                             C*   end program
                             C                   Eval      *INLR = *on
                             C
                             OQSYSPRt   E            HDREC
                             O                       Head
                             O
                             OQSYSPRt   E            Detrec1
                             O                       Data          Z

                        Comment


                        • #13
                          Re: Dynamic Report Generation

                          but that's too easy arrow
                          I'm not anti-social, I just don't like people -Tommy Holden

                          Comment

                          Working...
                          X