IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Where do you use Low-Value and High-Value in COBOL


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ravindra reddy

New User


Joined: 21 Jan 2008
Posts: 7
Location: banglore

PostPosted: Tue Apr 15, 2008 4:22 pm
Reply with quote

Hi Can anyone help me regarding this Where do you use Low-Value and High-Value in COBOL also explain which kind of values they present?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Apr 15, 2008 4:37 pm
Reply with quote

ripped&stripped from enterprise cobol manual:
Quote:

Figurative constants are reserved words that name and refer to specific constant values. The reserved words for figurative constants and their meanings are:

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 used. HIGH-VALUE is treated as an alphanumeric literal.

HIGH-VALUE/HIGH-VALUES cannot be used in a context requiring a national character value.

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 used. LOW-VALUE is treated as an alphanumeric literal.

LOW-VALUE/LOW-VALUES cannot be used in a context requiring a national character value.


The above is what they represent. Where do you use them? When you need an alphanumeric literal representing x'00' or x'FF' on an IBM mainframe (or the lowest and highest of any other collating sequence).
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Apr 15, 2008 4:40 pm
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.

HIGH-VALUE is treated as an alphanumeric literal in a context that requires an alphanumeric character. For alphanumeric data with the EBCDIC collating sequence, the value is X'FF'. For other alphanumeric data, the value depends on the collating sequence in effect.

HIGH-VALUE is treated as a national literal when used in a context that requires a national literal. The value is national character NX'FFFF'.

When the context cannot be determined, an alphanumeric context is assumed and the value X'FF' is used.

Usage note:You should not use HIGH-VALUE (or a value assigned from HIGH-VALUE) in a way that results in conversion between one data representation and another. X'FF' does not represent a valid EBCDIC character, and NX'FFFF' does not represent a valid national character. Conversion of either the alphanumeric or the national HIGH-VALUE representation to another representation results in a substitution character. For example, conversion of X'FF' to UTF-16 would give a substitution character, not NX'FFFF'.

LOW-VALUE, LOW-VALUES
Represents one or more occurrences of the character that has the lowest ordinal position in the collating sequence used.

LOW-VALUE is treated as an alphanumeric literal in a context that requires an alphanumeric character. For alphanumeric data with the EBCDIC collating sequence, the value is X'00'. For other alphanumeric data, the value depends on the collating sequence in effect.

LOW-VALUE is treated as a national literal when used in a context that requires a national literal. The value is national character NX'0000'.

When the context cannot be determined, an alphanumeric context is assumed and the value X'00' is used.

These links are also...
ibmmainframes.com/about12669.html
ibmmainframes.com/about12621.html
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Tue Apr 15, 2008 5:04 pm
Reply with quote

ravindra,


Adding to what gnanas and dick said,

Consider this scenario, you are interfacing with a JAVA based appln and getting inputs from them. Say for ex, you are
checking if a field is populated in the input. Most of the coders would check for "field1 not= spaces".

But manytimes i have seen this check failing just because the input had "low-values" when the interfacing appln did not
actually send any data.

In that place it is always better to check for "SPACES OR LOW-VALUES" instead of just checking for spaces.
Back to top
View user's profile Send private message
ravindra reddy

New User


Joined: 21 Jan 2008
Posts: 7
Location: banglore

PostPosted: Wed Apr 16, 2008 10:27 am
Reply with quote

Thank alot dbzTHEdinosauer, gnanas, Aaru icon_smile.gif
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 218
Location: India

PostPosted: Wed Apr 16, 2008 12:19 pm
Reply with quote

ravindra reddy wrote:
Thank alot dbzTHEdinosauer, gnanas, Aaru icon_smile.gif


can anyone provide some code/Scenarion where they are exactly used for ..
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Apr 16, 2008 1:06 pm
Reply with quote

A little cheesy, but an example:

Java sends a null delimited string to cobol. Cobol must determine the length of the string and insert to a varchar column.

Code:

initialize var-char-area replacing alphanumeric by high-values

unstring input
             delimited by low-value
      into var-char-area
end-unstring

inspect var-char-area tallying counter for high-values

COMPUTE varchar-length = (length of var-char-area) - counter
end-compute

INSERT
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top