ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Cycle Control Level and RPG-Free

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

  • Cycle Control Level and RPG-Free

    I am fairly new to RPG and primarily write in RPG-Free. The RPG Cycle with the Primary file is something I've dealt with slightly in older programs still using the fixed format. I'm trying to utilize this in a program I'm writing (in Free) and have it working for the most part. The problem I'm running into is printing the Grand Totals when I reach the last record.
    if I check If *INLR = *ON;
    it doesn't print but if I check the control level in fixed it will work.
    Code:
            IF *INLR = *ON;
              WRITE GRDTOT;
               //nothing prints
            ENDIF;
          /END-FREE
         CLR                 WRITE     GRDTOT 
           *Prints fine
    So I guess the question is, how do you check the Control level in RPG-Free? Am I stuck with using the fixed format for the *INLR?

    Thanks

  • #2
    Re: Cycle Control Level and RPG-Free

    Question 1: Why are you using the "control cycle"?
    Question 2: Why check for *INLR = *ON?

    Try something like ... this way you don't have to check for the Cycle. Create your own!
    PHP Code:
    Print Header
    Line 
    10
    DoW NOT 
    %EOF()

       
    Sum Detail;
       
    Sum Total;
       Print 
    Detail;
       
    Line += 1;

       if 
    Line 55;
          
    Skip to TOF
          
    Print Header
          Line 
    10
       
    EndIF;

    EndDO

    Print Totals;
    *
    InLR = *On

    Comment


    • #3
      Re: Cycle Control Level and RPG-Free

      Your "IF *INLR" is a detail calculation whereas CLR ... is a total time calculation. So in the "cycle" it will not work as detail calcs are not executed when the cycle turns on LR.

      You could code CLR EXSR LR
      and then code your LR subroutine in /free. Of course if you only have a few LR statements it is not worth the effort.
      Denny

      If authority was mass, stupidity would be gravity.

      Comment


      • #4
        Re: Cycle Control Level and RPG-Free

        Originally posted by FaStOnE View Post
        Question 1: Why are you using the "control cycle"?
        Question 2: Why check for *INLR = *ON?
        Well besides that my bosses think its a waste of time to code all of the breaks personally. I left a lot of code out for simplicity sake, but you would have to check after every read if the new record had a different vendor/part etc print the subtotals for that, update your hold fields etc - that the Control Cycle handles automatically.

        I agree its an old way to do things, but whatever keeps the boss happy.

        Comment


        • #5
          Re: Cycle Control Level and RPG-Free

          Denny - would you post a sample of what you are describing please???


          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


          • #6
            Re: Cycle Control Level and RPG-Free

            Example of /free with total time rpg cycle

            Code:
                 // ... blah blah blah                                
                  else;                                               
                    except err01;                                     
                  endif;                                              
                 /END-FREE                                            
                CL1                 exsr      l1                      
                CLR                 exsr      qident                  
                C/SPACE 2                                             
                 //**********************************                 
                 // L1 BREAK - LIBRARY              *                 
                 //**********************************                 
                 /FREE                                                
                  begsr l1;                                           
                        if f(x) <> *blank  and                        
                              f(1) <> *blank;                         
                 // ... blah blah blah                                 
                  endsr;                                              
                  //**********************************                
                  // REPORT IDENTIFICATION SUBROUTINE *               
                  //**********************************                
                  begsr qident;                                       
                  // do stuff here...                                 
                  endsr;
            Denny

            If authority was mass, stupidity would be gravity.

            Comment


            • #7
              Re: Cycle Control Level and RPG-Free

              In any cycle programs, I pretty much use fixed format simply to call subrs to do the actual "meat" of the pgm. As an aside, I use gaps (L2, L4, L6) so I can "insert" an extra break if necessary. Once I get past the subrs in the mainline, it's free form. That's my approach -- but I know everyone has their own preferences, including cycle vs non-cycle.

              Code:
              C   L4              Exsr      L4Init                                                           
              C   L2              Exsr      L2Init                                                           
              C                   Exsr      ProcRcd                                                          
              CL2                 Exsr      L2Tots                                                           
              CL4                 Exsr      L4Tots                                                           
              CLR                 Exsr      LRTots                                                           
               **********************************************************************************************
               /FREE                                                                                         
                //*******************************************************************************************
                BegSR L2Init;                                                                                
                //-------------------------------------------------------------------------------------------
                                                                                                             
                ETC
              http://www.linkedin.com/in/chippermiller

              Comment

              Working...
              X