Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

What is HIGH-VALUE and LOW-VALUE in Cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Thu Jul 27, 2006 2:44 pm    Post subject: What is HIGH-VALUE and LOW-VALUE in Cobol
Reply with quote

Hi,

What is the basic difference between 'HIGH-VALUE' and 'LOW-VALUE' in cobol.

Some times in cobol, I have seen
MOVE LOW-VALUE TO WS-VARIABLE.

I remember i have seen HIGH-VALUE in the searches but never moved to a variable

What exactly are the both for??

~Vamsi
Back to top
View user's profile Send private message

dkalyan_c

New User


Joined: 06 Apr 2006
Posts: 17

PostPosted: Thu Jul 27, 2006 4:10 pm    Post subject: HIGH-VALUE / LOW-VALUE
Reply with quote

HIGH-VALUE/HIGH-VALUES
Represents one or more occurrences of the character that has the
highest ordinal position in the collating sequence used. For the
EBCDIC collating sequence, the character is X'FF'; for other collating
sequences, the actual character used depends on the collating
sequence. HIGH-VALUE is treated as a nonnumeric literal.
LOW-VALUE/LOW-VALUES
Represents one or more occurrences of the character that has the
lowest ordinal position in the collating sequence used. For the
EBCDIC collating sequence, the character is X'00'; for other collating
sequences, the actual character used depends on the collating
sequence. LOW-VALUE is treated as a nonnumeric literal.
Back to top
View user's profile Send private message
dkalyan_c

New User


Joined: 06 Apr 2006
Posts: 17

PostPosted: Thu Jul 27, 2006 4:20 pm    Post subject: HIGH-VALUE / LOW-VALUE
Reply with quote

U CANNOT MOVE LOW OR HIGH VALUES TO "PIC 9" FIELD
CAN MOVE ONLY TO "PIC X" FIELD

MOVE LOW-VALUE TO WS-VARIABLE-1.
MOVE HIGH-VALUE TO WS-VARIABLE-2.

RESULT:

WS-VARIABLE-1= x'0000'
WS-VARIABLE-2= x'0000'
Back to top
View user's profile Send private message
Raja Suman Chowdary

New User


Joined: 20 Sep 2006
Posts: 1
Location: Bangalore

PostPosted: Wed Sep 20, 2006 7:17 pm    Post subject: Re: What is HIGH-VALUE and LOW-VALUE in Cobol
Reply with quote

Can anyone explain this in detail with examples? I didn't understand the explanation posted in the forum previously..
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Jun 04, 2008 12:33 pm    Post subject:
Reply with quote

Hi,

There are occasions when you may wish to set a variable to an infinitely high or infinitely low number. For example, suppose you were merging two files on surnames as the primary key:


*in data division FILE SECTION
Code:

 FD FILE-1.
 01 RECORD-1.
     03 IN-NAME-1 PIC X(20).
     03 FILLER    PIC X(50).

 FD MERGE-FILE.
 01 RECORD-OUT    PIC X(70).

   :
   :

   PERFORM WITH TEST AFTER EOF-FLAG-1 AND EOF-FLAG-2
*loop until each file has been read to completion
*read each file
Code:
      READ FILE-1
          AT END SET EOF-FLAG-1 TO TRUE
          MOVE HIGH-VALUES TO IN-NAME-1
      END-READ
      READ FILE-2
          AT END SET EOF-FLAG-2 TO TRUE
          MOVE HIGH-VALUES TO IN-NAME-2
      END-READ

*sort the records (assuming no 2 names are the same)
*on ascending surname
Code:
      IF IN-NAME-1 IS < IN-NAME-2 THEN
          WRITE RECORD-OUT FROM RECORD-1
      ELSE
          WRITE RECORD-OUT FROM RECORD-2
      END-IF

   END-PERFORM

In this example, when IN-NAME-1 is less than IN-NAME-2 (based on their ASCII values e.g. A < B etc..) then the FILE-1 record (RECORD-1) is written to the merge file (RECORD-OUT). One of FILE-1 and FILE-2 will come to an end before the other so the completed file has its IN-NAME- value set to constant that will ALWAYS be greater than the IN-NAME- value still being read, ensuring all remain files are written to the merge file. This is done with the lines: MOVE HIGH-VALUES TO IN-NAME-1 and MOVE HIGH-VALUES TO IN-NAME-2

It is important to note that HIGH-VALUES and LOW-VALUES are ALPHANUMERIC in type, so you can't set numerically defined variables to this type (you would have to implicitly redefine the variable first). This is an annoying quirk of COBOL.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us