Except where there is a good reason for using the RPG cycle, programs should be fully procedural. Procedural programs are generally easier to follow, as well as to debug. In addition, if you are using the RPG cycle, the input primary file of an RPG III program, which updates the file, is allocated to the program with an exclusive update lock. This is not recommended as it can prevent other users from accessing records on the file.
Structured programming operations should be used wherever possible; for example use IF rather than COMP. This is because they are easier to follow than COMP statements and indicator comparisons, and therefore are less likely to contain coding errors. The corresponding END and ELSE statements should indicate the matching operation in the comment column (positions 61-79). The CA 2E Toolkit Tidy RPG III Source (YTDYRPGSRC) command can be used to document structured constructs automatically.
Avoid explicit branching altogether, that is, the use of the RPG III GOTO, CAB, and TAG operations. If you do use explicit branching, restrict it so that you only employ structured programming constructs, NEXT and PREVIOUS; that is, branch only to the beginning or end of the current loop, never to an arbitrary point. The only legitimate use of the GOTO or CAB statements should be to achieve an ‘ITERATE’ or a ‘QUIT’.
| Copyright © 2011 CA. All rights reserved. | Tell Technical Publications how we can improve this information |