Access numerics fields by bytes.

All sort of Mainframes Interview Questions.
Post Reply
Manoj Verma
New Member
Posts: 6
Joined: Mon Jun 23, 2014 3:47 pm

Access numerics fields by bytes.

Post by Manoj Verma »

Hi,

Can we do byte level manipulation in COBOL? To this question, I said, yes we can do it. Then second question was, how can we access bytes in a numeric field? To which I had not had a good answer. But later I thought and said that every digit in any numeric field will take a byte and as such that is a byte level manipulation. But my interviewer was not satisfied. Can someone please help me with this question?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1886
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Access numerics fields by bytes.

Post by Robert Sample »

Reference modification only works with USAGE DISPLAY type data (USAGE DISPLAY, DISPLAY-1, NATIONAL). So your answer was seriously incomplete since numeric variables may be USAGE DISPLAY, COMP, COMP-3 (COMP-1 and COMP-2 should not ever be manipulated using reference modification, while COMP-4 and COMP-5 are the equivalent of COMP). For COMP and COMP-3 variables, to use reference modification on them you can either move them to a USAGE DISPLAY variable or use a REDEFINES to create a PIC X variable. If you use REDEFINES, manipulating the individual bytes requires significant knowledge of the internal representation of numbers or you'll manage to completely screw up the data.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Interview Questions.”