Does seting *inlr in non-cycle programs has any effect?

1k views Asked by At

I have recently stumbled on a service program in which *inlr = *on is used after explicit close of a file (code below). It feels rather excessive for me. From what I have found it is rpg cycle that handles releasing of resources. So if there is no cycle (ie. in programs with main/nomain h-specs) there is no way for *inlr = *on to have any effect, but... I have not been able to find any confirmation, and since cycle related issues are very new to me I might be missing something...

if %open(file);      
  close file;        
endif;                  
*inlr = *on;            
return *on; 
3

There are 3 answers

6
Charles On BEST ANSWER

In short no.

"last record" indicator is only used by the cycle. It's not used in a NOMAIN service program or a linear MAIN program.

The RPG IV Programmer's Guide says

Note No cycle code is generated for subprocedures or when MAIN or NOMAIN is specified on the control specification.

Additional References
IBM's Barbara Morris (RPGLE Compiler developer, in a post to the RPG mailing list)

The linear-main procedure will just end when it gets to the end of the calculations. You can set on *INLR if you want, but it won't do any of the cycle-related things like closing files.

Here is a comparison of a cycle-main module and a linear-main module.http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=%2Frzasd%2Fsc09250802.htm "

0
jmarkmurphy On

In a linear main, or nomain module, *inlr has no effect. As far as I know, there is no explicit documentation of this, but the ILE RPG Programmer's Guide, on page 4, states

Note: No cycle code is generated for subprocedures or when MAIN or NOMAIN is specified on the control specification.

Since checking *inlr is part of the cycle, this inferrs no function

2
lou wilkinson On

try this:

cl program to call rpg program

    pgm
    call testlrr
    call testlrr
    call testlrr
    endpgm

then this for the rpg

    ctl-opt  dftactgrp(*no) actgrp('QILE');

    dcl-pr TESTLRR   extpgm('TESTLRR');
    end-pr;

    dcl-pi TESTLRR;
    end-pi;

    dcl-s counter      zoned(5:0);

    counter = counter + 5;

    dsply counter;

    return;            

you'll see the values of the variables continue to increment in the subsequent calls.

yes...you can deal with it via activation groups, inz statements, etc....but *inlr is pretty cheap and pretty foolproof.