Page 1 of 1

Cobol Level 88

PostPosted: Tue Apr 15, 2014 8:21 am
by weekeong81
Can anyone shade some light on this:
03  WS-STATUS            PIC X.
      88  VALID-STATUS   VALUE '1', '2', '9'   
      88  ACTIVE              VALUE '1'
      88  INACTIVE           VALUE '2'
      88  DROPPED           VALUE '9'
 SET VALID-STATUS TO TRUE.
What is the value in WS-STATUS after the SET statement?
Do you always get '1' or any value of '1', '2, or '9' ?

[Coded]

Re: Cobol Level 88

PostPosted: Tue Apr 15, 2014 1:02 pm
by BillyBoyo
From the SET for a condition-name you will always get the first value in the list for the VALUE clause on the 88-level which defines the condition-name.

So, in your case, yes, you always get '1'. Depending on the exact context, it could be unusual and confusing to use that line of code.

If you can provide more context, we can confirm or deny :-)

Re: Cobol Level 88

PostPosted: Tue Apr 15, 2014 7:09 pm
by dick scherrer
Hello and welcome to the forum,

Suggest you consider changing the code to one of the specific valid values so there will never be a question. . .

Re: Cobol Level 88

PostPosted: Thu Apr 24, 2014 2:47 pm
by Aki88
@weekeong81: adding onto what Billy and Dick have already suggested; from the way the '88' levels are arranged, what the program might be doing is:

First: Setting any one of the values from 'ACTIVE', 'INACTIVE', 'DROPPED' to TRUE
Second: Later down the line in the same program, checking the 'WS-STATUS' whether it falls under -- 'VALID STATUS' category, in which case the three values will be validated.
This can be done by coding any conditional statement such as below (please note your code 'might' be using some other condition)

IF VALID-STATUS  <-- Method 1
an EVALUATE TRUE statement with --
WHEN VALID-STATUS  <-- Method 2


I agree that the original query pertains to the value in WS-STATUS, but the purpose of having this kind of arrangement is tad bit different and can pertain to as above (the installation I currently support, has quite a few COBOL progs which use similar logic). Though as Dick has suggested the SET clause here can be made better, by setting a specific value.

Cheers.