140 pts.
 RPGLE Program help
I have a scenario .. I have program

 

FColstatlf IF   E           k Disk                              FColstatkk O    E             Disk                              F                                                               C                   Read      colstatlf                         C                   Eval      *inlr = *on                       C                   Dow       Not (%Eof(Colstatlf))             C                   Eval      Tablcod = Tablcode                C                   write     rstatre                           C                   Read      Colstatlf                         C                                                               C                   Enddo                                       C                                                               C                   Eval      *inlr = *on                      

 

In the above program i have issued EVAL *INLR = *ON AFTER reading the file COLSTATLF. As i know issuing *INLR =*ON closes all the files. But still the program is working and all the records are written in output file?? Can anyone tell me, how the program is works even though after issuing *INLR =*ON all the files will be closed.???



Software/Hardware used:
ASKED: December 1, 2009  1:00 PM
UPDATED: December 3, 2009  5:06 PM

Answer Wiki:
Setting on LR does not close any files. All setting on LR does is set on the LR indicator. The RPG cycle will not not check to see if the LR indicator is on until it gets to the end of your C specs. Therefore, all your C specs will be processed before the LR indicator is checked and any files are closed. A flow chart of the RPG cycle can be found at: http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/books_web/c092508656.htm
Last Wiki Answer Submitted:  December 1, 2009  2:34 pm  by  ElTerrifico   620 pts.
All Answer Wiki Contributors:  ElTerrifico   620 pts. , CharlieBrowne   33,730 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

A while back in one of the iSeries newsletters the writer discussed setting on LR at the top of the program. The idea was that there may be various reasons a progreammer decides to end a program. That way, LR is on whenever the programs ends without needing to code *INLR = *ON mutiple times.
Be careful about setting on LR early in the *INZSR subroutine – it can prevent files from opening.

 5,570 pts.

 

Be careful about setting on LR early in the *INZSR subroutine – it can prevent files from opening.

I’m not sure where you got that idea. Files are already opened before *INZSR is run. The location of setting on LR can’t be earlier than when files are already opened.

Tom

 110,215 pts.

 

Setting on *INLR in *INZSR will cause the program to end at the end of initialization BEFORE any “MainLine” C Specs are run.

 7,205 pts.

 

If you want the program to end after you set on LR, code a Return.

 5,740 pts.

 

I “got that idea” when my program acted like the SQL statements were not being executed when *INLR was on *INZSR. As soon as I moved setting on *INLR out of *INZSR, everything worked just fine. I think it was BitCat who set me straight on that one.

 5,570 pts.