It is customary in RPG programs to either allow the RPG cycle to set on the LR indicator after the last record...
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
in a primary file, or to manually set on *INLR when not using a primary file. This works perfectly well. However, if one program repeatedly calls another program, when the called program ends with LR on, the next call to that program must re-initialize the program.
Setting on the RT indicator, or using the RETURN (or RETRN in RPG III) opcode without setting on LR can result in a significant performance increase. I performed a benchmark test in which program B performed one simple addition, and program A calls program B 10000 times and ends. On the box that I ran this test, program A executed in around 5.2 seconds for 10000 calls to program B when program B ended with LR on, but ran in only 0.21 seconds when program B was changed to set the RT indicator on, rather that the LR.
Caution should be used here -- when the called program ends without LR on, and is called again, the variables will have the same values as when the program last returned, and all files will be open, and any file pointer from a READ, READP, READE, or READPE will remain uninitialized. The *INZSR will NOT run on the subsequent calls, so any variable initialization that you wish to be done on each call should be performed within the main program C specs.