Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Help needed regarding REDEFINES

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Help needed regarding REDEFINES
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: 8201
Location: Dubuque, Iowa, USA

PostPosted: Thu Apr 23, 2009 8:20 pm    Post subject:
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10375
Location: italy

PostPosted: Thu Apr 23, 2009 8:36 pm    Post subject: Reply to: Help needed regarding REDEFINES
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: 6970
Location: porcelain throne

PostPosted: Thu Apr 23, 2009 8:37 pm    Post subject:
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

Site Director


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

PostPosted: Fri Apr 24, 2009 12:44 am    Post subject:
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    Post subject:
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    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
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am
No new posts Help Needed with View Direct shailesh_do CA Products 2 Wed Jul 13, 2016 10:39 am
No new posts Information needed on using the COBAN... venugopal.dondla COBOL Programming 5 Thu Oct 08, 2015 3:34 pm
No new posts Help needed in Conditional statement ... vinu78 DB2 5 Tue Sep 15, 2015 10:14 am
No new posts Help needed to locate the changes wh... thesumitk TSO/ISPF 6 Fri Jun 12, 2015 6:21 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us