Re-using Indicators in RPG400

5 pts.
Tags:
RPG/400
If we have used all the indicators from 01 - 99 in a RPG Program, How can we re-use the indicators in the same program. Can anyone provide me a solution please

Answer Wiki

Thanks. We'll let you know when a new response is added.

You can always reuse indicators, as often or as many times as you want. The problem is, if you’re dealing with an old, ancient, archaeic program that originated from RPG II or RPG III which should be retired or rewritten, you’ll need to carefully analyze how it uses whichever indicators you’re thinking of reusing in order to avoid messing up its current logic. You may have to save the values of an indicator to a work variable and then re-use that indicator, and then copy the value from the saved variable back into it once your new logic is done with it.

A better solution is to convert the program to RPG IV, if it hasn’t already been done. Then, the only reason to even use the numbered 1-99 indicators is if it’s an interactive program that uses a display file and needs those indicators to condition various behaviors on the screen. Any other numbered indicator can be replaced with a named indicator, where you can define and use as many as you want. And depending on what those indicators are being used for, you may be able to completely eliminate them by relying on the built in functions (BIFs) for file and record status (functions like %EoF, %Found, %Equal, etc.).

So instead of using a resulting indicator after a file operation, and then testing the value of that indicator to know whether or not a record was retrieved ,you would leave the resulting indicator off, and just use the approprate BIF to condition your logic. Instead of:
<pre>
KEYFIELD CHAIN MYFILE 98
IF *IN98 = *Off
(proceed)
ENDIF
</pre>
you would do this:
<pre>
KEYFIELD CHAIN MYFILE
IF %Found(MYFILE)
(proceed)
ENDIF
</pre>
or this:
<pre>
/Free
CHAIN (KEYFIELD) MYFILE;
IF %Found(MYFILE);
(proceed….)
ENDIF;
/End-Free
</pre>

CWC
*****************************

Re-write your program without indicators and publicly flog the person who wrote the program to set an example.

Steve

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    It can't be said much better than Cwc said it. First, stop using RPG/400 and convert to RPG IV. Second, start replacing numbered indicators with functions wherever possible. Where functions don't make sense, use indicator variables. And if the indicators are controlling DSPF attributes, replace them with the DSPATR(&program-to-system-field) form. Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    Short of their rewrite Just prior to your new code move the indicators to a hold area You could create an array with 99 1 character long fields named HIN MOVEA *IN HIN then use the indicators as you need to in the new code at the end of the new code repopulate the indicators MOVEA HIN *IN and they are all back where they were. Phil
    50,860 pointsBadges:
    report
  • YuVa47
    What Phil wrote is a good solution, but if you need to re-use only a few and say within a subroutine, the you can create a work-field called in a similar "name" as the indicator, like #IN99 and move the *IN99 into it. After you made your new stuff move back the #IN99 into *IN99. MOVE *IN99 #IN99 do something MOVE #IN99 *in99 But, again the best way is to convert to RPGIV. Good luck, YuVa47
    1,300 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following