Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Doing something when REWRITE INVALID KEY goes OK

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Doing something when REWRITE INVALID KEY goes OK
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri May 22, 2009 6:08 pm    Post subject: Reply to: Doing something when REWRITE INVALID KEY goes OK
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    Post subject: Reply to: Doing something when REWRITE INVALID KEY goes OK
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    Post subject:
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: 1224
Location: Israel

PostPosted: Sun May 24, 2009 1:03 am    Post subject:
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: 1224
Location: Israel

PostPosted: Sun May 24, 2009 1:12 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts IEF645I INVALID REFERBACK IN THE RC ... abdulrafi JCL & VSAM 2 Mon Aug 29, 2016 10:57 am
This topic is locked: you cannot edit posts or make replies. Updating value of key using rewrite s... ParminderKumar COBOL Programming 4 Thu Aug 04, 2016 12:46 am
No new posts Invalid frequency code, dataset descr... Bhanu Praveen JCL & VSAM 4 Fri Feb 05, 2016 10:43 am
No new posts IGZ0040S An invalid separate sign was... kishpra COBOL Programming 13 Sun Aug 02, 2015 2:41 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us