Where do use LOW-VALUE and HIGH-VALUE in COBOL. Also explain which kind of values they represent?

Questions by sekhargupta   answers by sekhargupta

Showing Answers 1 - 3 of 3 Answers

One of the use cases of HIGH-VALUE and LOW-VALUE are in the Binary Search using SEARCH ALL. If the table to be searched is only partially populated, the SEARCH ALL may not work correctly. If the table is ordered in ascending sequence then, to get the SEARCH ALL to function correctly, the unpopulated elements must be filled with HIGH-VALUES. If the table is in descending sequence, the unpopulated elements should be filled with LOW-VALUES.

  Was this answer useful?  Yes

lfrank

  • Jan 8th, 2008
 

LOW-VALUE represents X'00' and HIGH-VALUE represents X'FF'. These equate to  the lower and upper limits of the collating sequence. All other values fall in between.

There are many uses. Say you wanted to know who had the highest and lowest sales for the month. Many people have specific "first time code" to read the first record and move the sales amount to the HIGH-SALE and LOW-SALE fields.

Define the fields as   05  HIGH-SALE  PIC 9(5)    VALUE LOW-VALUES. 
                      and     05  LOW-SALE   PIC 9(5)    VALUE HIGH-VALUES.

Then simply compare the input sales amount to HIGH-SALE and LOW-SALE and move it to HIGH-SALE when it is higher than the current value and to LOW-SALE when it is lower than the current value. 

  Was this answer useful?  Yes

Meetal

  • Feb 6th, 2012
 

One correction in example given above post ofr Ifrank. We can not move HIGH-VALUES/LOW-VALUES to PIC 9 (NUMERIC FIELD) . We can onlye move in PIC X (ALPHANUMERIC)

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions