VALUE clause
COBOL can assign variables default values as they are being declared.
In this example, the variable FIRST-STRING is set to be blank characters, FIRST-NUMBER is given the value 5 and SECOND-STRING the value ‘HELLO’. It can be important that these values are preserved because the target program might expect that these values are in place.
01 VALUES-TEST.
02 FIRST-STRING PIC X(10) VALUE SPACES.
02 FIRST-NUMBER PIC S9(8) VALUE 5.
02 SECOND-STRING PIC X(10) VALUE 'HELLO'.
IBM® Record Generator for Java™ supplies the method setInitialValues() that sets the default values. This method is automatically called when the default zero arguments constructor is called.
public static void main(String [] args){
ValuesTest values = new ValuesTest();
int firstNumber = values.getFirstNumber(); //Will be set to the value 5
String secondString = values.getSecondString(); //Will be set to HELLO
}