View previous topic :: View next topic
|
Author |
Message |
tushar_study
New User
Joined: 01 Feb 2007 Posts: 30 Location: Mumbai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
tushar_study
New User
Joined: 01 Feb 2007 Posts: 30 Location: Mumbai
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
the logic is flawed
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Is there more to record layout then you have shown us? |
|
Back to top |
|
|
|