View previous topic :: View next topic
|
Author |
Message |
venuhunev
New User
Joined: 26 May 2007 Posts: 70 Location: chennai
|
|
|
|
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 |
|
|
Devzee
Active Member
Joined: 20 Jan 2007 Posts: 684 Location: Hollywood
|
|
Back to top |
|
|
venuhunev
New User
Joined: 26 May 2007 Posts: 70 Location: chennai
|
|
|
|
is there any way to do it in JCL itself ? without going to COBOL ? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
venuhunev
New User
Joined: 26 May 2007 Posts: 70 Location: chennai
|
|
|
|
even DFSORT, SYNCSORT couldnt help ? |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
venuhunev wrote: |
even DFSORT, SYNCSORT couldnt help ? |
Those are both utilities! |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
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 |
|
|
Devzee
Active Member
Joined: 20 Jan 2007 Posts: 684 Location: Hollywood
|
|
Back to top |
|
|
venuhunev
New User
Joined: 26 May 2007 Posts: 70 Location: chennai
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|