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 value of display after redefining...

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
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    Post subject: What is value of display after redefining...
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: 1439
Location: Bangalore,India

PostPosted: Tue Apr 10, 2007 10:33 am    Post subject:
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    Post subject:
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: 685
Location: Earth

PostPosted: Tue Apr 10, 2007 11:01 am    Post subject:
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    Post subject:
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: 685
Location: Earth

PostPosted: Tue Apr 10, 2007 12:03 pm    Post subject:
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    Post subject:
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: 685
Location: Earth

PostPosted: Tue Apr 10, 2007 12:32 pm    Post subject:
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    Post subject:
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: 1439
Location: Bangalore,India

PostPosted: Tue Apr 10, 2007 1:17 pm    Post subject:
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: 685
Location: Earth

PostPosted: Tue Apr 10, 2007 1:52 pm    Post subject: Re: What is value of display after redefining...
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    Post subject:
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    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 Display ZEDLMSG without Pressing F1 &... anandgbe CLIST & REXX 8 Thu Dec 15, 2016 4:20 pm
No new posts How to display value of an exit param... lind sh CICS 2 Sun Oct 09, 2016 12:28 pm
This topic is locked: you cannot edit posts or make replies. DSList (3.4) cannot display Chinese c... jacobdng TSO/ISPF 4 Wed Oct 05, 2016 2:51 pm
This topic is locked: you cannot edit posts or make replies. Get and display content of an address... lind sh CICS 1 Mon Aug 08, 2016 9:18 am
No new posts How to display data in separate lines... salilnigam1970 DFSORT/ICETOOL 2 Tue Jan 26, 2016 9:49 pm


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