Ü  Difference between return and SETON LR

 

*INLR = *ON ( SETON    LR)

RETURN

Files and resources are released
in this case.

Return ends the program returning to calling program. No resources are released.

Return with *INLR = *On

Files and resources are released and control returns to the calling program.

 Return without *INLR = *On

Resources remain locked until job ends or this program is recalled and changes the value of *INLR.

After LR is on, you can still continue processing additional commands.

 

e.g.

*inlr=*on;

return; (control will come here.)

 

 

RETURN returns control to the calling program immediately and doesn’t process anything after this.

e.g.                     

return;

*inlr=*on; ( will not get processed.)

 

 

When PGMA calls PGMB for the first time PGMB executes the *INZSR, PGMB uses the RETRN operation to return to PGMA. When PGMA call PGMB the second time, Is the*INZSR executed?

If you specify SETON  LR  in called program, the *INZSR will be executed again as the resource was freed in the first call.

When PGMA calls PGMB for the first time PGMB executes the *INZSR, PGMB uses the RETRN operation to return to PGMA. When PGMA call PGMB the second time, Is the*INZSR executed?

 

If you specify RETRN in called program, the *INZSR will not execute again as the resource was not freed in the first call.

Not setting on LR (in OPM programs) will keep the program in memory, keeps file  open and pointers set, retains variable values, and prevents the *INZSR from being executed the next time the program is called, as well as INZ specified in your D-specs.

 

As a rule, never seton LR when a program will be called multiple times.  This rule most definitely applied to a trigger program that could be called hundreds or possibly thousands of times.

 

 

 




 

 







User Comments:



Subscribe

.  


Copyright © www.go4as400.com, 2013-2023. Copyright notice   Terms of services   Privacy policy