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
 

 

Need cobol program to compare files

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

New User


Joined: 26 May 2007
Posts: 70
Location: chennai

PostPosted: Fri Jun 15, 2007 9:29 pm    Post subject: Need cobol program to compare files
Reply with quote

Hi ,

these are my requirements.

file1 - code1 - sorted
file 2 - code1 , account number - sorted acc to code1
file3 - account number and rate - sorted acc to acc number

i should have an output file with all code1 and its rate.

i have to fetch the account number matching the code1 and then go for file3 to fetch rate for the particular code.

Help me to solve this .
Back to top
View user's profile Send private message

Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Fri Jun 15, 2007 10:37 pm    Post subject:
Reply with quote

Refer to below posts ...

http://www.ibmmainframes.com/viewtopic.php?t=21803
http://www.ibmmainframes.com/viewtopic.php?t=21299
http://www.ibmmainframes.com/viewtopic.php?t=19416
http://www.ibmmainframes.com/viewtopic.php?t=16924
http://www.ibmmainframes.com/viewtopic.php?t=9015
http://www.ibmmainframes.com/viewtopic.php?t=5248
Back to top
View user's profile Send private message
venuhunev

New User


Joined: 26 May 2007
Posts: 70
Location: chennai

PostPosted: Fri Jun 15, 2007 11:05 pm    Post subject:
Reply with quote

is there any way to do it in JCL itself ? without going to COBOL ?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Jun 15, 2007 11:19 pm    Post subject:
Reply with quote

JCL = Job Control Language.

This is the medium by which the user conveys to the operating system which program or utility to execute. It may also be used to indicate which, if any, files are to be processed by the selected programs / utilities.

JCL by itself does nothing but the above.
Back to top
View user's profile Send private message
venuhunev

New User


Joined: 26 May 2007
Posts: 70
Location: chennai

PostPosted: Fri Jun 15, 2007 11:22 pm    Post subject:
Reply with quote

even DFSORT, SYNCSORT couldnt help ?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Sat Jun 16, 2007 12:36 am    Post subject:
Reply with quote

venuhunev wrote:
even DFSORT, SYNCSORT couldnt help ?


Those are both utilities!
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Sat Jun 16, 2007 3:32 am    Post subject:
Reply with quote

The JOIN functionality of the sort utilities could be used to get you what you want. You may have to join file 2 to file 3 to make file 4 then join file 1 to file 4, but it can be done without using cobol.
Back to top
View user's profile Send private message
Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Sat Jun 16, 2007 3:51 am    Post subject:
Reply with quote

First of all if your requirement was to do in JCL/SORT then you should post it in JCL or SORT forum. Not in COBOL forum


See this link sort tricks.. .

http://www-304.ibm.com/jct01004c/systems/support/storage/software/sort/mvs/tricks/pdf/sorttrck.pdf
Back to top
View user's profile Send private message
venuhunev

New User


Joined: 26 May 2007
Posts: 70
Location: chennai

PostPosted: Mon Jun 18, 2007 8:33 am    Post subject:
Reply with quote

i have a problem with my cobol..... its reading only certain records leaving out many things.... this is the code i wrote.... plz help me with some other code



IF CROBTN1 < CROBTN2
PERFORM P30001-BTN1-FILE-READ
END-IF

IF (CROBTN1 = CROBTN2)

PERFORM P22000-UPDATE-COUNT
IF BTN1-FILE-EOF
CONTINUE
ELSE
PERFORM P30001-BTN1-FILE-READ
END-IF
END-IF

IF CROBTN1 > CROBTN2
PERFORM P30002-BTNBAID-FILE-READ
END-IF
.


P22000-UPDATE-COUNT.
OPEN INPUT BAIDUSOC-FILE
PERFORM P30003-BAIDUSOC-FILE-READ UNTIL
BAIDUSOC-FILE-EOF
((BAID2 = BAID3) OR BAIDUSOC-FILE-EOF)
IF (BAID2 = BAID3)
PERFORM P40000-MOVE
PERFORM P41000-LISTALL-FILE-WRITE
CLOSE BAIDUSOC-FILE
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 Jun 18, 2007 10:18 am    Post subject:
Reply with quote

Hello,

The bits of code you've posted appear incomplete.

I'd suggest you start by creating new pseudo-code and "playing computer" (on paper) with 2 sets of sample data - representing the files you want to match/merge. Your process must be able to handle mis-matches in either file and duplicates if there are any (even though one or moare of those conditions may be in error). If you cannot successfully "walk thru" your solution by hand, it will probably not work when coded.

Keep in mind that you want a process that will work not only for this requirement but for most situations that require matching 2 files that you can customize for new requirements.

Many folks will tell you to use the sort, but there are many requirements that have needs that far exceed using the sort. Even if you find uses for the sort product, there will be other times you will be far ahead using good code. Knowing how to implement a 2-file-match (also known as a line-balance) routine is something that everyone who intends to program should be comfortable with.

This topic has been discussed many times in the forums and very much of the time, suggestions made will only work some of the time - some will not work at all. Be careful of which suggestions you follow. Quite a few people post suggestions that they have not even tested but "think will work" - and are often very mistaken.

Back to your routine. . . .

For starters, keep in mind that you need read each file only once in the code - sometimes you will see code that has several reads or performs of the reads and they often do not work - so the coder adds more reads/performs and just propogates the mess. If you find yourself coding multiple performs of the "reads", please re-think. When you execute the read code for the files, you need to test if that file has reached eof and if so, not read it. You will also need to check if a read is required this time thru the code. Next, you need to compare the "key" from each file - there can be only 3 outcomes.
1. key1 = key2
2. key1 < key2
3. key1 > key2
Depending on which of these occur, you process accordingly, and continue until both files reach eof.

I'll see if there is a reply to this topic when i'm mobile in the a.m. I believe i have a small match/merge cobol program on the system where i'll be and will post it if it might help.

If you create pseudo-code in the meantime and post it, you will get some responses (probably before i am on-site here).
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: Wed Jun 20, 2007 2:30 am    Post subject:
Reply with quote

Hello,

If i am successful, attached is a very small program that accomplishes a 2-file match/merge or "line balance". This was taken from a larger production program that runs regularly.

The attached code will need to be changed to meet requirements. When the "keys" are not contiguous, i find it much more straightforward to create group fields in working-storage consisting of the match keys and compare at the group level.
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 Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
No new posts I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 13 Tue Dec 06, 2016 8:30 pm


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