View previous topic :: View next topic
|
Author |
Message |
Rijit
Active User
Joined: 15 Apr 2010 Posts: 168 Location: Pune
|
|
|
|
I have 2 flat files FILEA & FILEB
In FILEA --> records have unique employee number field stored in a comp format ( actually FILEA has been downloaded from a DB2 table and the employee column in the table was an integer)..so the extracted data is binary..
In FILEB --> records have the unique employee number field stored in PD format.
My objective is to read FILEB sequentially and extract the data from FILEA by matching the employee field. But I am not sure how to proceed as the data formats are varying in both the files for the employee number. So how do I compare?
I have planned to write a COBOL code..But can anyone suggest a better way of doing such a task may be using JCL/SORT? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Whether COBOL or some utility (i.e. sort) is the better choice depends on the complete requirement. . .
If you use COBOL, sort both files on the employee number (BI for comp and PD for comp-3) and match/merge the files (there is tested sample code in a "sticky" near the top of the cobol part of the forum).
To compare the fields simply use an IF:
Code: |
IF COMP-FLD = COMP3-FLD |
|
|
Back to top |
|
|
Rijit
Active User
Joined: 15 Apr 2010 Posts: 168 Location: Pune
|
|
|
|
Dick, I found the program. Thanks! If I am not wrong, in the COBOL program the following line does the comparison between the records of the 2 files:
IF COMP-CAPP = COMP-ELIG GO TO 100-CAP-ELIG-MATCH.
But here you both the fields COMP-ELIG & COMP-CAPP have the same datatype PIC 9(9). So the comparson is a straightforward one. In my case the scenario is quite similar except the dataypes of the 2 fields are different (Lets asume COMP-CAPP is COMP & COMP-ELIG is a PD field). How will this be handled in the COBOL program. Will direct comparison work?
Also I was thinking if I could load the second Input file COMP-ELG into a VSAM with key as CER-PROV. becoz I have huge number of records to process..
|
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
But here you both the fields COMP-ELIG & COMP-CAPP have the same datatype PIC 9(9). So the comparson is a straightforward one. In my case the scenario is quite similar except the dataypes of the 2 fields are different (Lets asume COMP-CAPP is COMP & COMP-ELIG is a PD field). How will this be handled in the COBOL program. Will direct comparison work?
RTFM |
|
Back to top |
|
|
Rijit
Active User
Joined: 15 Apr 2010 Posts: 168 Location: Pune
|
|
|
|
I may look a bit foolish but can you please elaborate! I don't know what you are refereing to by RTFM Craq. |
|
Back to top |
|
|
Traveler
New User
Joined: 12 Aug 2010 Posts: 8 Location: Highlands, NJ
|
|
|
|
Think about the problem a little. If you are in COBOL you can created two fields that are both used for the comparison. Define these two fields as smiple fields pic s9(9) , the move will translate the data into display format , you could even go a step furthur and redefine the fields as pic x(9) and use the pic x for the comparison. So that you do a char to char compare. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
Will direct comparison work?
RTFM |
There is a link to manuals at the top of this page. Click on it, find the COBOL manuals for your version of COBOL, and start reading. If you read long enough, you will find out much about how COBOL will automatically convert numeric data from one format to another for comparison in an IF statement. Let me repeat Craq's comment for emphasis -- your level of expertise in COBOL is appallingly low for somebody attempting to write code in it:
Read The Freaking Manual
|
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Rijit wrote: |
I may look a bit foolish but can you please elaborate! I don't know what you are refereing to by RTFM Craq. |
YOU CAN DIRECTLY COMPARE A COMP-3 FIELD AND A COMP FIELD WITH NO PROBLEM! Just read the COBOL manual. |
|
Back to top |
|
|
Rijit
Active User
Joined: 15 Apr 2010 Posts: 168 Location: Pune
|
|
|
|
dick scherrer wrote: |
Hello,
Whether COBOL or some utility (i.e. sort) is the better choice depends on the complete requirement. . .
If you use COBOL, sort both files on the employee number (BI for comp and PD for comp-3) and match/merge the files (there is tested sample code in a "sticky" near the top of the cobol part of the forum).
To compare the fields simply use an IF:
Code: |
IF COMP-FLD = COMP3-FLD |
|
I would like to know if the direct comparison will work in the cobol or we should go for a redefine/move as stated by Traveler. |
|
Back to top |
|
|
Rijit
Active User
Joined: 15 Apr 2010 Posts: 168 Location: Pune
|
|
|
|
Craq Giegerich wrote: |
Rijit wrote: |
I may look a bit foolish but can you please elaborate! I don't know what you are refereing to by RTFM Craq. |
YOU CAN DIRECTLY COMPARE A COMP-3 FIELD AND A COMP FIELD WITH NO PROBLEM! Just read the COBOL manual. |
Thanks for right advise, may be I need to get into my boots and revisit the COBOL manual.. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Oh,
Whew. I feel better now. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
From the manual:
Quote: |
6.1.6.4 Relation conditions
A relation condition specifies the comparison of two operands. The relational operator that joins the two operands specifies the type of comparison. The relation condition is true if the specified relation exists between the two operands; the relation condition is false if the specified relation does not exist.
Comparisons are defined for the following:
* Two operands of class alphabetic
* Two operands of class alphanumeric
* Two operands of class DBCS
* Two operands of class national
* Two operands of class numeric
* Two operands of different classes where each operand is one of the classes alphabetic, alphanumeric, or national
* Two operands where one is a numeric integer and the other is class alphanumeric or national |
Notice that you can compare two numeric variables (or a numeric variable and a numeric literal) -- no matter how the numeric variable is defined. |
|
Back to top |
|
|
Rijit
Active User
Joined: 15 Apr 2010 Posts: 168 Location: Pune
|
|
|
|
Thank you Robert for the details.. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Hopefully, you realize that the details Robert provided are a direct quote from the manual that people advised you to read. . . |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Phrzby Phil wrote: |
Oh,
Whew. I feel better now. |
Substitute other F-words at your own discretion... |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Read the Fine Manual. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Read The Fabulous Manual |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Kjeld wrote: |
Read The Fabulous Manual |
Kjeld, even I tend not to be that sarcastic. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
OK, you're right, only a few manuals would really qualify for that adjective.
On the other hand, some manuals or at least parts of them have become rather famous (another f-word ), and indispensable to developers. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Kjeld,
you are being tooooooooo serious.
but, following up on your comment, most REDBOOKs I would put in the Fabulous category. |
|
Back to top |
|
|
|