Figurative constants are reserved words that name and refer to specific constant values. These can be easily used by writing the word itself instead of the value.
The figurative constants supported by COBOL are:
ZERO, ZEROS, ZEROES SPACE, SPACES HIGH-VALUE, HIGH-VALUES LOW-VALUE, LOW-VALUES QUOTE, QUOTES ALL literal - which means fill the field with ALL "M" etc.
Figurative constants are not allowed as function arguments except in an arithmetic expression, where the expression is an argument to a function. The length of a figurative constant depends on the context of its use. When a figurative constant represents a string of one or more characters, the length of the string is determined by your COBOL system from context by applying the following rules in order:
ZERO or ZEROS or ZEROES: Represents the value ZERO – “0″, or one or more of the character ZERO – “0” depending on the context.
e.g. VAR01 thru VAR03 represents a zero value; the VAR04 thru VAR06 represents five 0 characters.
01 WS-VARIABLES 05 WS-VAR01 PIC 9(5) VALUE ZERO. 05 WS-VAR02 PIC 9(5) VALUE ZEROS. 05 WS-VAR03 PIC 9(5) VALUE ZEROES. 05 WS-VAR04 PIC X(5) VALUE ZERO. 05 WS-VAR05 PIC X(5) VALUE ZEROS. 05 WS-VAR06 PIC X(5) VALUE ZEROES.
COBOL input field editing
IF field-name IS [NOT] POSITIVE. NEGATIVE. ZERO.
Note: This test should be done on a numeric field.
IF AMT POSITIVE. Could be written as: IF AMT > 0. IF AMT NEGATIVE. IF AMT < 0. IF AMT ZERO. IF AMT = 0. IF field-name IS [NOT] NUMERIC. ALPHABETIC.
Note: This test should be done on an alphanumeric field.
Examples:
IF FLD-IN NUMERIC. IF FLD-IN ALPHABETIC. INITIALIZE field-name1 ALPHABETIC ALPHANUMERIC [REPLACING NUMERIC DATA BY field-name2 ] ALPHANUMERIC-EDITED literal-1 NUMERIC-EDITED
SPACE or SPACES: Represents one or more of the character space or blank. SPACE is treated as an alphanumeric literal when used in a context that requires an alphanumeric character. This can be used to handle the blank spaces in the string variables. This can help in initializing the string with empty spaces, or moving spaces for modifying their value. It can also be used to overwrite the value of the string.
e.g. MOVE SPACES TO WS-VAR04
HIGH-VALUE or HIGH-VALUES: Represents one or more of the character that has the highest ordinal position in the program collating sequence. (Hexadecimal Value – X’FF’). HIGH-VALUE is treated as an alphanumeric literal in a context that requires an alphanumeric character. These are used to specify the highest possible value to some variables in a particular program. In this the bit stream is actually in ‘ON’ state. All bits are set to high.
e.g. MOVE HIGH-VALUE TO WS-VAR04.
LOW-VALUE or LOW-VALUES: Represents one or more of the character that has the lowest ordinal position in the program collating sequence. (x”00″ for the ASCII character set). LOW-VALUE is treated as an alphanumeric literal in a context that requires an alphanumeric character. These are used to specify the lowest possible value or spaces to some variables in a particular program. In this the bit stream is actually in ‘OFF’ state. All bits are set to low or ‘00000000’.
e.g. MOVE LOW-VALUE TO WS-VAR04.
QUOTE or QUOTES: Represents one or more of the character “””. The word QUOTE or QUOTES cannot be used in place of a quotation mark in a source program to bound a nonnumeric literal. Thus QUOTE ABD QUOTE is incorrect as a way of stating “ABD”. QUOTE or QUOTES represents an alphanumeric character when used in a context that requires an alphanumeric character and must be non-numeric. These cannot be used in place of a quotation mark or an apostrophe to enclose a non-numeric literal.
ALL literal: Represents one or more characters of the string of characters comprising the literal. The literal must be either a nonnumeric literal or a national literal or a figurative constant other than ALL literal. This nonnumeric literal and this national literal may be concatenation expressions. When a figurative constant is used, the word ALL is redundant and is used for readability only. The figurative constant ALL literal must not be used with the CALL, INSPECT, INVOKE, STOP, or STRING statements.
NULL or NULLS: Represents one or more unset pointer or procedure-pointer values. A data item with USAGE POINTER or PROCEDURE-POINTER and with a value of NULL is guaranteed not to represent the address of any data item or procedure. The NULL value varies between environments and is generally consistent with the equivalent value used in non-COBOL languages for each environment.
e.g. MOVE SPACE TO WS-VAR01 MOVE SPACES TO WS-VAR01 MOVE ALL SPACES TO WS-VAR01
COBOL Blog: Click Here IBM Reference:Click Here
A well-maintained product backlog is crucial for successful product development. It serves as a single…
Incremental value to the customer refers to the gradual delivery of small, functional parts of…
A Product Market refers to the group of potential customers who might be interested in…
The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…
The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…
Choosing the right Scrum Master Certification depends on your current experience and career goals. If…