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

REDIFINES with different PIC clause and size


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
minikaushik

New User


Joined: 03 Jul 2007
Posts: 1
Location: banglore

PostPosted: Wed Jul 11, 2007 7:01 pm
Reply with quote

Everywhere its written that REDEFINES can be used for different data description entries and sizes.

and is this feasible?

01 dn1 pic a(5).
01 dn2 REDEFINES pic 9(10).
(in this data types different and we are redefining a small storage location with a bigger one)

or..............

01 dn1 pic x(10).
01 dn2 REDEFINES pic 9(5).
(in this we are redefining a large storage size with a smaller one)

Regards,
Mini kaushik
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Jul 11, 2007 7:47 pm
Reply with quote

Yes, it is feasible.
The larger redefining the smaller might raise a warning, but COBOL will take care of everything.
Back to top
View user's profile Send private message
nagasri83

New User


Joined: 20 May 2005
Posts: 15
Location: chennai

PostPosted: Thu Jul 12, 2007 5:05 am
Reply with quote

It is feasible, but people never do this type of coding with different lengths as the data will be truncated.

There are few chances that your program end with Data exception error (S0C7) even if you use same length.

Quote:

Data Division.
01 dn1 pic X(5).
01 dn2 REDEFINES pic 9(5).
....

Procedure Division.
....
Move 'test1' to dn1.
Display 'Data in redefine clause: ' dn2.
....


After executing the above code, you program fails at Display statement as dn2 is declared as numeric but logical storage space contains alphanumeric.

If your not clear, you can try the above way and see the result.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Jul 12, 2007 9:37 am
Reply with quote

nagasri83 wrote:
It is feasible, but people never do this type of coding with different lengths as the data will be truncated.
What? Never? Truncated? I think not.......
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Using Java/C/C++ to retrieve dataset ... Java & MQSeries 6
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts To search DB2 table based on Conditio... DB2 1
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
No new posts Dataset size increase on adding 1 byt... DFSORT/ICETOOL 8
Search our Forums:

Back to Top