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

What is value of display after redefining...


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

New User


Joined: 05 Apr 2007
Posts: 15
Location: pune

PostPosted: Tue Apr 10, 2007 10:27 am
Reply with quote

Hi ,
I have one quick question in mind please suggest me any solution.

working-storage section
01 a pic x(3)
01 b pic x(3) redefine a.

procedure division.

move 'ABC' to a.

display b.

add 2 to b.

display a.

display b.

so what is value of display a and display b at end of program.

thanks,
sudip ghanvat.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Tue Apr 10, 2007 10:33 am
Reply with quote

You will get error with the posted code.
Back to top
View user's profile Send private message
sudip_ghanvat

New User


Joined: 05 Apr 2007
Posts: 15
Location: pune

PostPosted: Tue Apr 10, 2007 10:40 am
Reply with quote

But here we adding numeric value in alphanumeric field .
as per my knowledge is it ok if we add numeric value in alphnumeric field.


so if we add 2 to b(means ABC ,new value of b)


then is it possible compiler convert 2 in ASCII value???


I am confuse on it,
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Tue Apr 10, 2007 11:01 am
Reply with quote

Don't get confused. This code will not compile.
Why don't you give it a try..?
Back to top
View user's profile Send private message
sudip_ghanvat

New User


Joined: 05 Apr 2007
Posts: 15
Location: pune

PostPosted: Tue Apr 10, 2007 11:15 am
Reply with quote

OHooooo!!1


Sorry guyss

i did a big mistake..

value of b is

01 B pic 9(3)


sorry for incovinance

Thanks,
sudip
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Tue Apr 10, 2007 12:03 pm
Reply with quote

Sudip,
Quote:
then is it possible compiler convert 2 in ASCII value???

Mainframes operate on EBCDIC codes, not on ASCII.

Adding number to a numeric field which contain alphanumeric data can cause S0C7 (Data Exception).
Arithmatic instructions of mainframes are Packed decimal instructions.
So while adding zoned decimal fields, compiler will generate code for 'packing' the number to packed decimal, add and unack again for display. I this process S0C7 can occur in ADD operation, so avoid doing such additions.
Back to top
View user's profile Send private message
sudip_ghanvat

New User


Joined: 05 Apr 2007
Posts: 15
Location: pune

PostPosted: Tue Apr 10, 2007 12:12 pm
Reply with quote

Ok,
But now my question is different actually bymistake i have put
value of 01 b pic x(3) instaed of

01 B pic 9(3)


previos field:
01 B pic x(3)

new field

01 B pic 9(3)
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Tue Apr 10, 2007 12:32 pm
Reply with quote

I have understood your question properly and have answered it in my last post.
Code:
01 a pic x(3)
01 b pic x(3) redefine a.

procedure division.
move 'ABC' to a. (as you are redefining, b will contain ABC)
display b.
add 2 to b.
(This 'add' will spawn following:
   pack -  'ABC' = x'C1C2C3' will get packed as 123
   add 2 to 123 = 125
unpack to  display 125 )

display a.  125
display b.


You WILL get S0C7 when adding in the packed field which is not numeric.
For example, instead of ABC move @#$ to the variable, you will get S0C7. Hope I am clear enough this time.
Back to top
View user's profile Send private message
sudip_ghanvat

New User


Joined: 05 Apr 2007
Posts: 15
Location: pune

PostPosted: Tue Apr 10, 2007 12:57 pm
Reply with quote

Abhijit,

my second field is

01 B pic 9(3) redefine a

not alphnumeric...
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Tue Apr 10, 2007 1:17 pm
Reply with quote

Same S0C7 as the data in the memory is not a numeric data.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Tue Apr 10, 2007 1:52 pm
Reply with quote

Quote:
my second field is

01 B pic 9(3) redefine a

Yes i know that. I have copied the code which was pasted by you.
If you declare it numeric then only code will compile and answer is, it will display 125 in this case.

I have explained that there is a large possibility that you may encounter S0C7 in such case ( Adding number to alphanumeric data, which you are doing).
However there will not be S0C7 in 'this case' because 'ABC' will be packed to 123 numeric and will give numeric result.
Back to top
View user's profile Send private message
sudip_ghanvat

New User


Joined: 05 Apr 2007
Posts: 15
Location: pune

PostPosted: Tue Apr 10, 2007 3:30 pm
Reply with quote

Thanks abhijit.

This is the i was excepting.....
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 How to display the leading zeros of a... DB2 7
No new posts SDSF display Max-RC in different colors TSO/ISPF 4
No new posts Converting a file from PD to display ... SYNCSORT 4
No new posts Unable to display comp variable COBOL Programming 4
No new posts Adding FIND to ISPF Panel display of ... TSO/ISPF 3
Search our Forums:

Back to Top