IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Find end of file using 88 level with out using IF


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sureshbait
Warnings : 1

New User


Joined: 02 Feb 2007
Posts: 5
Location: Chennai

PostPosted: Thu Oct 25, 2007 1:20 pm
Reply with quote

Hi
i want to find end of file using 88 level

with out using IF and File status

is it possible?
Back to top
View user's profile Send private message
bshkris

New User


Joined: 21 Mar 2005
Posts: 41
Location: pune

PostPosted: Thu Oct 25, 2007 1:33 pm
Reply with quote

you can use evaluate true condition for this case.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Oct 25, 2007 2:36 pm
Reply with quote

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
View user's profile Send private message
gorgatz

New User


Joined: 15 Oct 2007
Posts: 2
Location: manila, philippines

PostPosted: Tue Oct 30, 2007 10:57 am
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Tue Oct 30, 2007 11:01 am
Reply with quote

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
View user's profile Send private message
gorgatz

New User


Joined: 15 Oct 2007
Posts: 2
Location: manila, philippines

PostPosted: Tue Oct 30, 2007 11:05 am
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Nov 01, 2007 3:27 pm
Reply with quote

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
View user's profile Send private message
sai mainframes

New User


Joined: 02 Nov 2007
Posts: 8
Location: hyderabad

PostPosted: Fri Nov 02, 2007 3:50 pm
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Sun Nov 04, 2007 9:16 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top