ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to use more than 99 indicators in RPGLE............

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

  • How to use more than 99 indicators in RPGLE............

    Hi All,

    Please let me know how we can use more than 99 indicators in RPGLE.
    I'm working on a program where all the 99 indicators have been used.

    Please suggest me fast,

    Thanks in adv,
    Susan.

  • #2
    Re: How to use more than 99 indicators in RPGLE............

    If you are programming in RPGIV, which you should be since you mentioned RPGLE, then you can do one of the following:

    A) Add new code using free format RPG statements that do not require indicators.

    B) If the indicator is needed for a display file, map the display file indicators to an INDDS data structure, specifying the INDARA on the display file.
    Michael Catalani
    IS Director, eCommerce & Web Development
    Acceptance Insurance Corporation
    www.AcceptanceInsurance.com
    www.ProvatoSys.com

    Comment


    • #3
      Re: How to use more than 99 indicators in RPGLE............

      Hi Micheal,

      Very very Thanks for your quick reply..
      We are not supposed to use free format.Also i wanted to use in display file.
      Could you please elaborate or explain me with example so that it wil be very usefull and i need to do it deliver it.

      Thanks in advance,
      Susan.

      Comment


      • #4
        Re: How to use more than 99 indicators in RPGLE............

        It's hard to believe you need 99 indicators for a single format!
        1. Try to use several formats
        2. Replace error messages with other techniques (for example error subfiles) and only use a single indicator for each input field
        3. Rethink your design
        4. Do not use any *IN-Indicators in your RPG opcodes (even if you are not allowed to use free format you can avoind *IN indicators)

        If it's not possible, you need to use the same *IN-indicator twice and have to design carefully.

        Birgitta

        Comment


        • #5
          Re: How to use more than 99 indicators in RPGLE............

          if you choose to reuse indicators you can save them and replace them when you are done
          but i9ts not pretty
          PHP Code:
           Indicators Pointer                                        
          d IndicatorPtr    S               
          *   Inz (%Addr(*In))       
           * 
          Indicators Data Structure                                 
          d                 DS                  Based 
          (IndicatorPtr)   
          d Ind                           99                           

          d errors          ds                  qualified inz                  
          d   DataString                 103    dim
          (100overlay(errors)       
          d    ind                        99    overlay(datastring:1)          
          d    rrn                         4  0 overlay(datastring:*next)      

           
          // save the error indicators             
           
          if %lookup(count errors.rrn) = *zeros
            
          z+=1;                                   
            
          errors.ind(Z) = ind;                    
            
          errors.rrn(z) = count;                  
           endif; 
          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: How to use more than 99 indicators in RPGLE............

            You could try to tweak your program using the INDDS file keyword like shown on this recent post. IMHO it's worth a go.
            Philippe

            Comment


            • #7
              Re: How to use more than 99 indicators in RPGLE............

              Originally posted by susan View Post
              Hi Micheal,

              Very very Thanks for your quick reply..
              We are not supposed to use free format.Also i wanted to use in display file.
              Could you please elaborate or explain me with example so that it wil be very usefull and i need to do it deliver it.

              Thanks in advance,
              Susan.
              You can have a look at the popup calendar program on my website.



              The display file uses a lot of indicators, but inside the program they are mapped to an indicator data structure. Even though the display file uses indicators 31-72, because they are mapped to an indicator array, indicators 31-72 in the program are free. Doing anything to indicators 31-72 inside the program will not affect the display file, nor does the display file affect those indicators inside the program.

              For a quick fix, I would probably suggest finding an indicator you can free up in your program by using another method instead of using an indicator to hold a result. Even if you cant use free format RPG, you can still use rpgiv bifs that eliminate the use of an indicator. (ie on a chain statement, replace the indicator with %found or NOT %found bifs instead of an indicator.)

              ie: here's a quick example of fixed format RPGIV using the %lookup bifs instead of an indicator:

              Code:
              fChecking  if   e             disk                        
               
              d CheckingNbr     s              5p 0 inz( 645 )          
               
              c     CheckingNbr   chain     Checking                    
              c                   if        NOT %found( Checking )      
              c     'Not Found'   dsply                                 
              c                   else                                  
              c     'Found'       dsply                                 
              c                   endif                                 
              c                   eval      *inlr = *on
              Michael Catalani
              IS Director, eCommerce & Web Development
              Acceptance Insurance Corporation
              www.AcceptanceInsurance.com
              www.ProvatoSys.com

              Comment


              • #8
                Re: How to use more than 99 indicators in RPGLE............

                Hello Susan.

                There are a number of ways of acquiring additional indicators for use, but it depends on what you are trying to do.

                If you want True/false Type variables, you can define them on a D spec using the N data type, or declare a "like" variable against an indicator:
                Code:
                d myindicator1    s               n              
                d myindicator2    s                   like(*inlr)
                If you need to use more than 99 indicators with native indicator functionality, for example with DDS, an old trick is to "double up" on your indicator usage. First you will need to free up at least one indicator. Then you can use that indicator in conjunction with other indicators. For example, lets say indicators 02 to 10 were already in use, and you had indicator 01 free. You can have indicator 1 *OFF then AND this with indicators 2 through 10. Then you can "double up" by having indicator 01 *ON then AND this with indicators 02 through 10 also. When doubling up like this, you will need to review existing code, as the logic for indicators already in use will need to take into account the ANDing against your doubling-up indicator.

                Another technique (potentially the simplest) that works well for native indicator functionality, is to save indicators being used somewhere, reuse the indicators saved, then restore the indicators to their previous values:

                Code:
                d savind          s             10a                            
                c                   movea     *in(10)       savind
                                                                               
                 * use indicators 10-19 as you wish here ...                   
                                                                               
                c                   movea     savind        *in(10)
                I hope I'm on the right track here, and you find this of use.

                Kind Regards.
                Roger.
                RTFM works best when you know which MTFR.

                Comment


                • #9
                  Re: How to use more than 99 indicators in RPGLE............

                  Since nobody has suggested it so far ...

                  Perhaps the best way to handle situations where 99 indicators is "just not enough" is to use the attribute bytes and set those directly instead of setting indicators which indirectly control the attribute bytes.

                  Goodness knows why 99 is not enough but ...

                  Comment


                  • #10
                    Re: How to use more than 99 indicators in RPGLE............

                    Originally posted by JonBoy View Post
                    Since nobody has suggested it so far ...

                    Perhaps the best way to handle situations where 99 indicators is "just not enough" is to use the attribute bytes and set those directly instead of setting indicators which indirectly control the attribute bytes.

                    Goodness knows why 99 is not enough but ...
                    if i come across a program using 99 indicators (much less more then 99!) i'd first consider suicide, rule that out then rewrite the program using real conditional logic rather than cobbled together trash. (just think upgrading to a Lexus from a redneck Bondo-mobile)
                    I'm not anti-social, I just don't like people -Tommy Holden

                    Comment


                    • #11
                      Re: How to use more than 99 indicators in RPGLE............

                      In an MBA kinda way that sounds perfect, but in a work environment where lets say its your order
                      entry program written by the ORACLE 35 years ago...who by the way is still working in IT,
                      then a rewrite is really NOT going to happen.
                      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


                      • #12
                        Re: How to use more than 99 indicators in RPGLE............

                        Susan, its 2011. Why not Free format? You work in a buggy whip plant?
                        Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

                        Comment


                        • #13
                          Re: How to use more than 99 indicators in RPGLE............

                          Hi Susan --

                          To add to the other suggestions here: compile the program. Then go to the section that lists all indicators and where (i.e. line numbers) where they are used/modified. Try to find one that is only used a few times. You may able to eliminate that indicator by using a named field instead.

                          For example, a lot of times I will have a subr that evaluates if a record should be processed. If often goes like this:

                          OOPS -- Forgot that your shop doesn't use /free until after I got done writing all of this. Hopefully it will still be helpful.

                          Code:
                                 Exsr EvaluateRecord;
                          
                                 // EvaluateRecord subr returns 80 on if record should be processed.
                                 If (*IN80 = *ON);
                                    ProcessRecord;
                                 EndIf;
                          
                                 //*******************************************************
                                 BegSR EvaluateRecord;
                                 //-----------------------------------------------------------------------
                          
                                    // Evaluate record to determine if it should be processed.  If so, return ind 80 on.
                          
                                    // Set off each time -- will be turned only if record should be processed.
                                    *IN80 = *OFF;
                                
                                    // Elimination test #1
                                    If (a = b);
                                       LeaveSR;
                                    EndIf;
                               
                                    // Elimination test #2
                                    If (c <> d);
                                       LeaveSR;
                                    EndIf;
                               
                                    // Elimination test #3
                                    If (e >= 100);
                                       LeaveSR;
                                    EndIf;
                               
                                    // Etc, etc, etc, etc.
                                
                                    // If you did not leave the subr, record should be processed.  Return ind 80 on.
                                    *IN80 = *ON;
                          
                                 EndSR;
                          I use the "process of elimination" method because it helps avoid nesting.

                          If I needed to free up an indicator, could use a processing flag instead. Ind 80 is only used in three places:
                          1) Set off at start of EvaluateRecord subr
                          2) At end of EvaluateRecord subr
                          3) To test if ProcessRecord subr should be called

                          Like so:
                          Code:
                                *Process this record flag
                               D ProcessRcd      S               N 
                          
                          
                                 //***********************************************************************
                                 BegSR EvaluateRecord;
                                 //-----------------------------------------------------------------------
                          
                                    // Evaluate record to determine if it should be processed.
                                    // If so, return "process this record" flag set to true.
                          
                                    // Reset each time -- will be turned only if record should be
                                    // processed.
                                    ProcessRcd = @FALSE;
                                
                                    // Elimination test #1
                                    If (a = b);
                                       LeaveSR;
                                    EndIf;
                               
                                    // just like previous example
                                
                                    // If you did not leave the subr, record should be processed.
                                    ProcessRcd = @TRUE;
                          
                                 EndSR;
                          I'm moving in that direction.

                          The @TRUE and @FALSE are *ON/*OFF. There's a DDS that has all constants and is used with /COPY. (Learned that one from Barbara Morris -- link enclosed)



                          TinyURL:


                          Here's a small smattering of what's in the copy book. It's used in almost every program.
                          Code:
                            * Function Key Definitions                
                           D @F01            C                   x'31'
                           D @F02            C                   x'32'
                           D @F03            C                   x'33'
                           D @F04            C                   x'34'
                          
                            * Processing Modes & Return Values               
                           D @Add            C                   'Add       '
                           D @Cancel         C                   'Cancel    '
                           D @Delete         C                   'Delete    '
                           D @Exit           C                   'Exit      '
                           D @Update         C                   'Update    '
                           D @View           C                   'View      '
                          
                           * Logic Fields - For Testing Against Flags, Returning Values, etc.   
                          D @True           C                   *ON                             
                          D @False          C                   *OFF                            
                                                                                                
                          D @Valid          C                   *ON                             
                          D @Invalid        C                   *OFF                            
                                                                                                
                          D @CusLocked      C                   *ON                             
                          D @CusNotLocked   C                   *OFF
                          Well, that's probably waaaaaay more information than you needed, but hopefully it helps.
                          http://www.linkedin.com/in/chippermiller

                          Comment

                          Working...
                          X