COBOL 88 level number with Examples

COBOL 88 Level Number or Condition Names 

88 level number in COBOL is one of the most used declarations in mainframes development and it is considered as a special level number which is used to improve the readability of COBOL programs. As it gives a name to a condition, it is also called as ‘Condition Names’. Level number 88 is used to declare these items and it is declared as a subordinate to another data item of level numbers 01 to 49.

COBOL 88 Level Uses:

– Used to check the declared conditions in the program flow.
– Simplifies the IF and Perform UNTIL conditions by directly using these names in the program.

Example:

In the program flow, WS-GENDER-FLAG gets populated with either M or F from a database or file. After populating the value, either MALE or FEMALE gets SET accordingly. And these 88 level names can be used in conditions in the program to validate the value present in that field.

In this way, the condition names can be used directly in the IF conditions where it avoids using of WS-GENEDER-FLAG=’M’ etc.

Multiple Values in 88 Level:

Very useful part of condition names is, it can be validated against multiple values.For example: If there is a requirement to process based on the Continent and the input is the country codes.

So in the program, if any of the above values gets populated respective flag gets SET and that can be used in the program conditions.

Multiple values by THRU:

If the values given are continuous values then option ‘THRU’ can be given while declaring.

These condition names can be used in the program and process accordingly.

COBOL 88 Level SET:

Condition names can be set to true or False by using SET verb. It can also be set by moving any value to its group item.

Example: A bank process needs to identify whether the the card he is using is a Debit or Credit and based on that it needs to perform a different functionalities across the program. So here Declare a 88 level and set them based on the business logic.

COBOL 88 Level SET when Multiple values are assigned.

When the condition name has multiple values assigned and a SET verb is used then the first value specified in the VALUE clause gets moved into the variable.
As an example if FIRST-10 filed is SET, then the value present in the WS-NUMBER-CHECK would be 1 as 1 is the first value declared.

Notes:
  • Picture clause should not be given to 88 level items. It’s length is equal to it’s group level item.
  • Multiple values can be given by separating them with spaces or commas.
  • Condition names can be SET to TRUE but SET TO FALSE is an invalid case.
  • 88 Level can be subordinate to any level number from 01 to 49.
  • These are very useful in PERFORM … UNTIL loops.

Leave a Reply

Your email address will not be published. Required fields are marked *

Bitnami