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

Doing something when REWRITE INVALID KEY goes OK


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

New User


Joined: 19 May 2009
Posts: 9
Location: Spain

PostPosted: Fri May 22, 2009 5:41 pm
Reply with quote

REWRITE REG-FICHERO INVALID KEY
DISPLAY '*** FICHERO : ERROR REWRITE FICHERO'
DISPLAY 'EST-FICHERO : ' EST-FICHERO
MOVE 8 TO SW-CODE
PERFORM FIN
END-REWRITE.

I'm rewriting a file and I want to do something (ADD 1 TO W-COUNT) when the REWRITE goes OK... how could I code that? which is the best way to do it?

Thank you.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri May 22, 2009 6:08 pm
Reply with quote

Instead of using "INVALID KEY", use the 2-Byte file-status defined to the SELECT statement.

INVALID KEY can be raised for a number of issues and this is why the file-status check is recommended.

Regards,
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Sat May 23, 2009 3:13 am
Reply with quote

The way you have coded INVALID KEY to PERFORM-A
add NOT INVALID KEY to PERFORM-B within your REWRITE and END-REWRITE.

WTH.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat May 23, 2009 4:56 am
Reply with quote

I agree with Bill.

The status codes for service calls should be used, always.

With the increasing complexity of computer systems
and
the ever increasing error/warning return codes (status-code for I/O)
your code should interrogate these codes specifically (e.g. EVALUATE)
outside the I/O-END-I/O statement.
and
not rely on the 'old-style' clauses provided in the I/O syntax.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Sun May 24, 2009 1:03 am
Reply with quote

Everybody knows that the program never comes back from that PERFORM FIN, which sets the RETURN-CODE and does a STOP RUN...
So it could be:
Code:
REWRITE REG-FICHERO INVALID KEY
    DISPLAY '*** FICHERO : ERROR REWRITE FICHERO'
    DISPLAY 'EST-FICHERO : ' EST-FICHERO
    MOVE 8 TO SW-CODE
    PERFORM FIN
END-REWRITE.
ADD 1 TO W-COUNT.

Seriously now: use FILE STATUS as recommended. And bookmark, print and give to your friends this page.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Sun May 24, 2009 1:12 am
Reply with quote

After looking at this page, you will see that the only acceptable status is 00. All other codes are either irrelevant or indicate a serious error.
Therefore you can code:
Code:
REWRITE REG-FICHERO.
IF FICHERO-STAT NOT = '00' THEN
    DISPLAY '*** FICHERO : ERROR REWRITE FICHERO'
    DISPLAY 'EST-FICHERO : ' EST-FICHERO
    DISPLAY 'FICHERO-STAT : ' FICHERO-STAT
    MOVE 8 TO SW-CODE
    PERFORM FIN
ELSE
    ADD 1 TO W-COUNT
END-IF.
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 rewrite same SAY line CLIST & REXX 8
No new posts Invalid URL in Sticky topic TSO/ISPF 1
No new posts Blue zone error with an invalid exten... CICS 3
No new posts INVALID RECFM FOR DDNAME SYSLIN AND C... All Other Mainframe Topics 7
No new posts Invalid XML character while producing... IBM Tools 4
Search our Forums:

Back to Top