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 the output of this code?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
kshirabdhi

New User


Joined: 22 Nov 2007
Posts: 13
Location: Noida

PostPosted: Fri Jan 08, 2010 12:01 pm    Post subject: What is the output of this code?
Reply with quote

I have the following varibles in the working storage.

01 WS-A PIC X(30) VALUE 'ABCDEFGHIJKLMNOPQRESTUVWXYZ ' .

01 WS-B REDEFINES WS-A.
10 WS-B1 PIC X(10).
10 WS-B2 PIC 9(10).
10 WS-B3 PIC X(10).

If I display B1, B2 and B3 respectively, what is the value displayed in B2? Will it throw any error as WS-B2 is a numeric field?
Back to top
View user's profile Send private message

Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Fri Jan 08, 2010 12:10 pm    Post subject:
Reply with quote

Quote:
What is the output of this code?

I don't know.... You tell us.
It would be a very simple test and you'll see the results in seconds....
Back to top
View user's profile Send private message
kshirabdhi

New User


Joined: 22 Nov 2007
Posts: 13
Location: Noida

PostPosted: Fri Jan 08, 2010 12:14 pm    Post subject:
Reply with quote

If I had mainframe connection, I would have seen the results in seconds and would not have posted it here.

I can not test as I have no resource icon_sad.gif
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Jan 08, 2010 12:47 pm    Post subject:
Reply with quote

It will not through any error if you just display it. Numeric variable will get populated with character value (KLMNOPQRSH).
Back to top
View user's profile Send private message
kshirabdhi

New User


Joined: 22 Nov 2007
Posts: 13
Location: Noida

PostPosted: Fri Jan 08, 2010 12:51 pm    Post subject:
Reply with quote

Thank you Sambhaji.
One more query ... If we move alphabets to numberic field, it throws error; but in this case wile displaying characters through a numeric field it works fine. How?
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Jan 08, 2010 12:56 pm    Post subject:
Reply with quote

Can't feed more...

Get the COBOL compiler from
http://ibmmainframes.com/downloads.php
And try on yourself.
Let us know if you are facing any problem.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8121
Location: East Dubuque, Illinois, USA

PostPosted: Fri Jan 08, 2010 5:07 pm    Post subject:
Reply with quote

kshirabdhi, there is a link to manuals at the top of the page. Click on it, find the COBOL Language Reference and Programming Guide manuals, and read them -- cover to cover. You will learn much from doing this and be able to answer many questions on your own.

While you cannot move 'ABC' to a numeric DISPLAY variable, if you set up a PIC X variable and move 'ABC' to it, you can then move that variable to the numeric DISPLAY variable with no problems.

Quote:
If we move alphabets to numberic field, it throws error
No, it does not. JAVA throws errors, COBOL does not. COBOL abends but it does not "throw" things -- ever. Getting the terminology right is a repeated request by the moderators on this forum since if you cannot get the terminology right you cannot get the concepts right. And so far your terminology is not right.
Back to top
View user's profile Send private message
l.nethaji

New User


Joined: 16 Mar 2008
Posts: 90
Location: tamil nadu

PostPosted: Fri Jan 08, 2010 10:54 pm    Post subject: Hi,
Reply with quote

The main use of redefines is like it can be used for avoiding SOC7 error.

Only when we do arithmatic operation i.e moving X(3) to 9(3) soc7 occurs.

But in redefines we just override it on the same memory location.

Thats y we wont face error in redefines.

Hope this helps
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Jan 08, 2010 11:11 pm    Post subject:
Reply with quote

Quote:
The main use of redefines is like it can be used for avoiding SOC7 error.


not true.
main use of redefines is to have different definitions of same area.

Quote:
Only when we do arithmatic operation i.e moving X(3) to 9(3) soc7 occurs.


not true
1. a move is not an arithmetic operation.
2. you won't get a SOC7 because of receiving field. it is due to bad data in sending field.

actually, nothing you said helps, other than as a good example of a bad example.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Fri Jan 08, 2010 11:15 pm    Post subject: Re: Hi,
Reply with quote

l.nethaji wrote:
Only when we do arithmatic operation i.e moving X(3) to 9(3) soc7 occurs.


Not exactly correct.
According to the COBOL Language Reference Manual:

When the category of the sending item is alphanumeric, alphanumeric-edited, national, or national-edited, the data is moved as if the sending item were described as an unsigned integer."

So... Moving a field defined as PIC X(3) to one defined as PIC 9(3) won't result in a S0C7 if the value of the X(3) field is, for example, '123', or '987'. It will only result in a S0C7 if the value of the X(3) field does not qualify as a valid unsigned integer - e.g. 'XYZ'.
Back to top
View user's profile Send private message
l.nethaji

New User


Joined: 16 Mar 2008
Posts: 90
Location: tamil nadu

PostPosted: Sat Jan 09, 2010 12:00 am    Post subject: Thanks for the reply
Reply with quote

Hi,

Its true


" a good example of a bad example."
_________________


I learnt a lot from mine .

thanks
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Read two inputs and write into output... murali.andaluri DFSORT/ICETOOL 6 Wed Jul 26, 2017 7:35 pm
No new posts UNIT=AFF for Easytrieve code gandikk JCL & VSAM 7 Wed Jul 12, 2017 11:42 pm
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts JES2 doesn't honor the priority of th... Aron Lendvai JCL & VSAM 7 Thu Jun 29, 2017 1:41 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm


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