View previous topic :: View next topic
|
Author |
Message |
Ensign
New User
Joined: 19 May 2009 Posts: 9 Location: Spain
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
|