Condition-name: level-88 statements

COBOL can define a set of level-88 elements, which list potential values for the preceding element. The level-88 statements can be used to test the value of the preceding element.

For example, if the element FLAG1 has a value of ‘Y’, then FLAG1-ON resolves to true when used to test the value of FLAG1.

01  BASIC-TEST-RECORD.                     
 02  FLAG1                  PIC X.         
   88 FLAG1-ON              VALUE 'Y'.     
   88 FLAG1-OFF             VALUE 'N'. 
When a structure of this type is processed by IBM® Record Generator for Java™, static fields are generated for each of the level-88 statements, which can be used to set the value of the preceding element. Also, methods are generated to test if the preceding element contains a specific value. For example:

public static void main(String[] args) {
       BooleanExample boolExample = new BooleanExample();
		
	//Set Flag 1 to have the value of 'N' or FLAG1-OFF
	boolExample.setFlag1(boolExample.FLAG1_OFF);
		
	//Test the value of flag 1
	if(boolExample.isFlag1On()){
		System.out.println("Flag is on");
	}else{
		System.out.println("Flag is off");  //This will print as the flag is off
	}
}
     
Level-88 elements that list multiple potential values or ranges, as illustrated in the following example, are not supported by the IBM Record Generator for Java.
02 FLAG2               PIC X(2).             
    88 FLAG-ALPHA        VALUES 'AA' 'AB' 'AC'.   
    88 FLAG-NUMERIC      VALUE 11 THRU 99. 

If multiple potential values are listed as part of a COBOL level-88 element, the IBM Record Generator for Java generates a Java method that only checks for the first value listed, and not the entire range.