View previous topic :: View next topic
|
Author |
Message |
sureshbait Warnings : 1 New User
Joined: 02 Feb 2007 Posts: 5 Location: Chennai
|
|
|
|
Hi
i want to find end of file using 88 level
with out using IF and File status
is it possible? |
|
Back to top |
|
|
bshkris
New User
Joined: 21 Mar 2005 Posts: 41 Location: pune
|
|
|
|
you can use evaluate true condition for this case. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Code: |
01 WS-FILE-XXX PIC X VALUE 'N'.
88 WS-FILE-XXX-END VALUE 'Y'.
88 WS-FILE-XXX-OK VALUE 'N'.
READ FILE-XXX
AT END SET WS-FILE-XXX-END TO TRUE
END-READ
PERFORM UNTIL WS-FILE-XXX-END
. . .
END-PERFORM |
These pieces of code will allow you to sequentially read a file until the end without using a single IF |
|
Back to top |
|
|
gorgatz
New User
Joined: 15 Oct 2007 Posts: 2 Location: manila, philippines
|
|
|
|
im sorry for my first post. i thought users are allowed to edit their posts. moderators pls kindly delete it for me. thanks.
I just want to add something to Marso's code. Before doing the the first read, u should set WS-FILE-XXX-OK to TRUE. Listed below is the revised code.
Code: |
01 WS-FILE-XXX PIC X VALUE 'N'.
88 WS-FILE-XXX-END VALUE 'Y'.
88 WS-FILE-XXX-OK VALUE 'N'.
1000-MAIN-RTN.
SET WS-FILE-XXX-OK TO TRUE
PERFORM 2000-READ-RTN
THRU 2000-READ-RTN-EXIT UNTIL WS-FILE-XXX-END.
1000-MAIN-RTN-EXIT.
STOP-RUN.
EJECT
2000-READ-RTN.
READ FILE-XXX
AT END SET WS-FILE-XXX-END TO TRUE
END-READ
2000-READ-RTN-EXIT.
EXIT.
EJECT |
|
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
gorgatz,
I agree that Before doing the the first read, u should set WS-FILE-XXX-OK to TRUE, however marso has done it by using Value clause in working storage declaration. So no need of setting the variable once again. |
|
Back to top |
|
|
gorgatz
New User
Joined: 15 Oct 2007 Posts: 2 Location: manila, philippines
|
|
|
|
agkshirsagar wrote: |
gorgatz,
I agree that Before doing the the first read, u should set WS-FILE-XXX-OK to TRUE, however marso has done it by using Value clause in working storage declaration. So no need of setting the variable once again. |
im sorry i overlooked that part. you're right agkshirsagar no need to set the variable again. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
I didn't plan to write the whole program (I usualy avoid questions that start with "write a program for me...")
If I can, I just give a lead but you must continue from there, that's the best way to learn... |
|
Back to top |
|
|
sai mainframes
New User
Joined: 02 Nov 2007 Posts: 8 Location: hyderabad
|
|
|
|
hi all,
SET WS-FILE-XXX-OK TO TRUE .
no need of this if you are accessing this file at one time ( open, read, close)
but if you are going to read the file multiple number of times (i mean to say if it is in loop (all open, read, close operations)....u need to set this...........to true......
any wrong this....
please correct me....... |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
In fact, there is a bigger problem: in gorgatz example everything is OK as long as there is no processing done on the record.
If I add some processing (done in PERFORM 3000-) it gives:
Code: |
1000-MAIN-RTN.
SET WS-FILE-XXX-OK TO TRUE
PERFORM 2000-READ-RTN
THRU 2000-READ-RTN-EXIT UNTIL WS-FILE-XXX-END.
1000-MAIN-RTN-EXIT.
STOP-RUN.
EJECT
2000-READ-RTN.
READ FILE-XXX
AT END SET WS-FILE-XXX-END TO TRUE
END-READ
PERFORM 3000-PROCESS-RECORD-FROM-FILE
2000-READ-RTN-EXIT.
EXIT.
EJECT |
or it could be:
Code: |
1000-MAIN-RTN.
SET WS-FILE-XXX-OK TO TRUE
PERFORM UNTIL WS-FILE-XXX-END
PERFORM 2000-READ-RTN THRU 2000-READ-RTN-EXIT
PERFORM 3000-PROCESS-RECORD-FROM-FILE
END-PERFORM
1000-MAIN-RTN-EXIT.
STOP-RUN.
EJECT
2000-READ-RTN.
READ FILE-XXX
AT END SET WS-FILE-XXX-END TO TRUE
END-READ
2000-READ-RTN-EXIT.
EXIT.
EJECT |
But then I can already hear everybody shouting "HO! HE! AYE!"
Yes, 3000-PROCESS will also be executed after the EOF is raised...
To stay with the original request (no IFs) we can use:
Code: |
1000-MAIN-RTN.
SET WS-FILE-XXX-OK TO TRUE
PERFORM 2000-READ-RTN
THRU 2000-READ-RTN-EXIT UNTIL WS-FILE-XXX-END.
1000-MAIN-RTN-EXIT.
STOP-RUN.
EJECT
2000-READ-RTN.
READ FILE-XXX
AT END SET WS-FILE-XXX-END TO TRUE
NOT AT END PERFORM 3000-PROCESS-RECORD-FROM-FILE
END-READ
2000-READ-RTN-EXIT.
EXIT.
EJECT |
or in the second case:
Code: |
1000-MAIN-RTN.
PERFORM 2000-READ-RTN THRU 2000-READ-RTN-EXIT
PERFORM UNTIL WS-FILE-XXX-END
PERFORM 3000-PROCESS-RECORD-FROM-FILE
PERFORM 2000-READ-RTN THRU 2000-READ-RTN-EXIT
END-PERFORM
1000-MAIN-RTN-EXIT.
STOP-RUN.
EJECT
2000-READ-RTN.
READ FILE-XXX
AT END SET WS-FILE-XXX-END TO TRUE
END-READ
2000-READ-RTN-EXIT.
EXIT.
EJECT |
|
|
Back to top |
|
|
|