# Declaring FILE STATUS variable correctly

**URL:** <https://community.openmainframeproject.org/t/declaring-file-status-variable-correctly/6791>\
**Category:** COBOL technical questions\
**Created:** [April 27, 2022, 9:31pm UTC](https://community.openmainframeproject.org/t/declaring-file-status-variable-correctly/6791 "2022-04-27T21:31:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![srbentley](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@srbentley](https://community.openmainframeproject.org/u/srbentley)\
**Post date:** [April 27, 2022, 9:31pm UTC](https://community.openmainframeproject.org/t/declaring-file-status-variable-correctly/6791/1 "2022-04-27T21:31:59Z")

</div>

So I’m trying out my first COBOL project in 30 years. I’m trying to use XCode with Zowe, have my main frame account all working but getting File Status 90 when trying to open my file. I have read up on getting the second byte of the file status as it gives more detail, but am not able to define that PIC X(2) in order to get that secondary information. Every attempt I get this error:

“FILE STATUS” data-name “WS-FILE-STATUS” was not defined as a  
two-character item. The data name was discarded.

Since COMP-X isn’t available (which I saw in online examples), this was my last attempt:

```
   01 WS-FILE-STATUS.
       05 STATUS-KEY-1 PIC X.
       05 STATUS-KEY-2 PIC X.
       05 BINARY-STATUS REDEFINES STATUS-KEY-2 PIC 9(2) COMP-5.

```

Appreciate the help!

SB

---

<div class="post-metadata">

**Author:** ![Dima](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@Dima](https://community.openmainframeproject.org/u/Dima)\
**Post date:** [November 7, 2022, 6:43pm UTC](https://community.openmainframeproject.org/t/declaring-file-status-variable-correctly/6791/2 "2022-11-07T18:43:31Z")

</div>

Dear SB,  
File status need to be defined in FILE DEFINITION as  
FILE STATUS IS WS-RETURN-CODE WS-EXTENDED-CODE

WORKING-STORAGE  
01 WS-REURN-CODE PIC XX.  
01 WS-EXTENDED-RETURN-CODE.  
05 VSAM-R15-RETURN-CODE PIC S99 COMP.  
05 VSAM-FUNCTION-CODE PIC S9 COMP.  
05 VSAM-FEEDBACK-CODE PIC S999 COMP  
Hope this helps  
Dima

---

<div class="post-metadata">

**Author:** ![Kapitan](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.openmainframeproject.org/kapitan/32/298_2.png) [@Kapitan](https://community.openmainframeproject.org/u/Kapitan)\
**Post date:** [November 15, 2024, 12:29am UTC](https://community.openmainframeproject.org/t/declaring-file-status-variable-correctly/6791/3 "2024-11-15T00:29:27Z")

</div>

Hi  
Please show how have you coded the select statement. You should have something like this  
Select Infile assign to disk  
File status is ws-status.  
Then in working storage section define  
As follows  
01 ws-status. Pic 99.

You can then display the file status in your procedure division to track what’s going wrong.

Hope that helps else please show me your whole code to understand what’s going wrong.  
You can reach me on. [prasaduday60@gmail.com](mailto:prasaduday60@gmail.com)

Regards  
Kapitanuday

---

<div class="post-metadata">

**Author:** ![Subbaraman](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.openmainframeproject.org/subbaraman/32/1222_2.png) [@Subbaraman](https://community.openmainframeproject.org/u/Subbaraman)\
**Post date:** [January 30, 2025, 9:00am UTC](https://community.openmainframeproject.org/t/declaring-file-status-variable-correctly/6791/4 "2025-01-30T09:00:38Z")

</div>

FILE STATUS should be given in Data Division File Section only and it should be of X(02) character if possible to capture the file related errors.
