Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Compare comp3 and comp filelds

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Rijit

Active User


Joined: 15 Apr 2010
Posts: 168
Location: Pune

PostPosted: Mon Aug 16, 2010 11:05 pm    Post subject: Compare comp3 and comp filelds
Reply with quote

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
View user's profile Send private message

dick scherrer

Site Director


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

PostPosted: Mon Aug 16, 2010 11:18 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Rijit

Active User


Joined: 15 Apr 2010
Posts: 168
Location: Pune

PostPosted: Tue Aug 17, 2010 12:16 am    Post subject:
Reply with quote

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..
icon_smile.gif
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Tue Aug 17, 2010 12:28 am    Post subject:
Reply with quote

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
View user's profile Send private message
Rijit

Active User


Joined: 15 Apr 2010
Posts: 168
Location: Pune

PostPosted: Tue Aug 17, 2010 12:40 am    Post subject:
Reply with quote

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
View user's profile Send private message
Traveler

New User


Joined: 12 Aug 2010
Posts: 8
Location: Highlands, NJ

PostPosted: Tue Aug 17, 2010 12:46 am    Post subject:
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7905
Location: Bellevue, IA

PostPosted: Tue Aug 17, 2010 12:57 am    Post subject:
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Tue Aug 17, 2010 12:57 am    Post subject:
Reply with quote

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
View user's profile Send private message
Rijit

Active User


Joined: 15 Apr 2010
Posts: 168
Location: Pune

PostPosted: Tue Aug 17, 2010 1:03 am    Post subject:
Reply with quote

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
View user's profile Send private message
Rijit

Active User


Joined: 15 Apr 2010
Posts: 168
Location: Pune

PostPosted: Tue Aug 17, 2010 1:05 am    Post subject:
Reply with quote

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.. icon_rolleyes.gif
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Tue Aug 17, 2010 5:00 am    Post subject:
Reply with quote

Oh,
Quote:
Freaking


Whew. I feel better now.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7905
Location: Bellevue, IA

PostPosted: Tue Aug 17, 2010 6:03 am    Post subject:
Reply with quote

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
View user's profile Send private message
Rijit

Active User


Joined: 15 Apr 2010
Posts: 168
Location: Pune

PostPosted: Tue Aug 17, 2010 8:34 am    Post subject:
Reply with quote

Thank you Robert for the details..
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: Tue Aug 17, 2010 9:09 am    Post subject:
Reply with quote

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
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Tue Aug 17, 2010 4:42 pm    Post subject:
Reply with quote

Phrzby Phil wrote:
Oh,
Quote:
Freaking


Whew. I feel better now.

Substitute other F-words at your own discretion... icon_razz.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Aug 17, 2010 4:56 pm    Post subject:
Reply with quote

Read the Fine Manual.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Tue Aug 17, 2010 5:15 pm    Post subject:
Reply with quote

Read The Fabulous Manual icon_smile.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Aug 17, 2010 5:19 pm    Post subject:
Reply with quote

Kjeld wrote:
Read The Fabulous Manual icon_smile.gif


Kjeld, even I tend not to be that sarcastic.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Tue Aug 17, 2010 5:30 pm    Post subject:
Reply with quote

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 icon_wink.gif ), and indispensable to developers.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Aug 17, 2010 5:36 pm    Post subject:
Reply with quote

Kjeld,
you are being tooooooooo serious.

but, following up on your comment, most REDBOOKs I would put in the Fabulous category.
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
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts COMPARE command sivatechdrive TSO/ISPF 7 Fri Sep 16, 2016 4:31 pm
No new posts Icetool or Joinkeys example to compar... ishant chauhan DFSORT/ICETOOL 21 Sat Aug 20, 2016 2:40 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us