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

Question about COBOL Redefines clause


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

New User


Joined: 02 Dec 2005
Posts: 5

PostPosted: Fri Dec 02, 2005 3:13 pm
Reply with quote

Hi

Which one is correct ?

01 IN-RECORD.
03 A PIC S9(8)V9(2) COMP-3.
03 B REDEFINES A .
05 C PIC 9(5).
05 D PIC 9(5).

01 A PIC S9(8)V9(2) COMP-3.
01 B REDEFINES A .
05 C PIC 9(5).
05 D PIC 9(5).
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Fri Dec 02, 2005 4:12 pm
Reply with quote

The REDEFINES clause cannot be used in a level 01 entry in the File Section.

Regards,

Priyesh.
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 411
Location: Colarado, US

PostPosted: Fri Dec 02, 2005 4:37 pm
Reply with quote

Hi draviki

Priyesh you are right. So for your query option one is correct.

More information on REDEFINES

Allows the same area of memory to be referenced by more than one data-name with different format and sizes.

Multiple 01 levels of same FD are Implicitly Redefined

Restrictions on REDEFINES
    OCCURS and REDEFINES cannot be combined
    Qualification of data-name-2 not required
    Value Clauses only in Condition Names
    Redefinition Ceases Whenever a Level No is <= that of data-name-1 or data-name-2 is encountered
    The Size of Data-name-1 must be Less than or equal to Data-name-2
    Data item lengths and types can also be respecified within an area


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

New User


Joined: 24 Nov 2005
Posts: 49
Location: chennai

PostPosted: Fri Dec 02, 2005 5:24 pm
Reply with quote

hi,

Multiple 01 levels of same FD are Implicitly Redefined ?....plz explain me this one..

regards,
akashs
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Dec 04, 2005 3:49 am
Reply with quote

He means that if you define more than 1 01 level in an FD they all define the same space that the rec was read into.

This means that you can use any dataname of any 01 level to reference the various offsets in the FD rec.

This is usually done where you have multiple rec types in a file. Each 01 would be used to access a different rec type.
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 411
Location: Colarado, US

PostPosted: Sun Dec 04, 2005 11:05 am
Reply with quote

Hi mmwife,


That was a wonderful expalnation. Thanks for your valuable information.
Back to top
View user's profile Send private message
mk_kumar315

New User


Joined: 21 Nov 2005
Posts: 10

PostPosted: Mon Dec 05, 2005 12:41 pm
Reply with quote

Hi priyesh and iknow,

As for as my Knowledge, what i learnt is:

We can REDEFINE an element of 01 level,if both are at the same level and both should have the same data type.

And also REDEFINES can be used with OCCURS clause if REDEFINES is sub-ordinate to the OCCURS clause.

If Iam WRONG, Please Let Me Know.

M.K.Kumar.
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top