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

Help needed regarding REDEFINES


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

New User


Joined: 01 Feb 2007
Posts: 30
Location: Mumbai

PostPosted: Thu Apr 23, 2009 8:12 pm
Reply with quote

I have a flat file, the RECORD layout for which is as follows :

Code:
05 REC-DETL PIC X(23).
05 REC-DETL1 REDEFINES REC-DETL.
     10   EMP-ID              PIC X(02).
     10   EMP-NAME         PIC X(08).
     10   EMP-SALARY      PIC 9(11)V99.
05 REC-DETL2 REDEFINES REC-DETL.
     10   EMP-PREV-REC1 PIC X(10).
     10   EMP-PREV-REC2 PIC X(13).



Is there a way I can find out which layout either of REC-DETL1 and REC-DETL2 is populated when i read the file in this layout ?

I need to extract the EMP-ID,EMP-NAME and EMP-SALARY and on a particular condition EMP-PREV-REC2 and move it to another layout.


Please help in this regard.

Thanks in advance,
Tushar

Please help me in this regard
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Apr 23, 2009 8:20 pm
Reply with quote

With REDEFINES, they are both populated when REC-DETL receives data. Whether or not the REC-DETL1 or REC-DETL2 format is to be used is not determined by COBOL but by you. You could check EMP-SALARY to be numeric -- presuming that EMP-PREV-REC2 is not numeric, that would give you a way to distinguish between the two.

There's a link to the manuals at the top of the page. If you don't understand the basics of REDEFINES, you need to spend some time in the COBOL Language Reference manual.
Back to top
View user's profile Send private message
tushar_study

New User


Joined: 01 Feb 2007
Posts: 30
Location: Mumbai

PostPosted: Thu Apr 23, 2009 8:24 pm
Reply with quote

Hi Robert,

Thanks for the response.....though REC-DETL2 is not numeric still an alphanumeric can contain numerics.

Please share your views on this.


Thanks,
Tushar
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Apr 23, 2009 8:36 pm
Reply with quote

the logic is flawed icon_biggrin.gif

when dealing with multiple record layout in the same dataset
there should always be a field( with values defined by application standards )

that the application/program can test to decide what names to use when accessing record fields

relying on <numericity> or other pattern for a generic field will yield sooner or later to a mismatch in processing
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Apr 23, 2009 8:37 pm
Reply with quote

Quote:
alphanumeric can contain numerics


alphanumeric yes that is true.
REC-DETL2 is a group item, which by definition is alphanumeric.

it is obvious that you have not bothered to read the documentation.

expecting us to teach you is selfish - all you will receive is sarcasm.

we will explain concepts that you do not understand,
we can only explain after you have told us your understanding.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Apr 24, 2009 12:44 am
Reply with quote

Hello,

You need to consider adding another field that is common to both record formats that contains the "record type".

What you have is 2 sets of the same record content, just named differently. As implemented, there is no way to know whether you are working with a "current" employee record or a "prev" record. . .
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Apr 24, 2009 1:00 am
Reply with quote

Is there more to record layout then you have shown us?
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 Mainframe Programmer with CICS Skill... Mainframe Jobs 0
No new posts Help needed to assemble IMS sample co... ABENDS & Debugging 4
No new posts RABBIT HOLE NEEDED - "Live"... All Other Mainframe Topics 0
No new posts Mainframe profiles needed @ Cognizant Mainframe Jobs 0
No new posts COBOL Student learning COBOL File Han... COBOL Programming 3
Search our Forums:

Back to Top