View previous topic :: View next topic
|
Author |
Message |
GaniKrish143
New User
Joined: 30 Jan 2013 Posts: 4 Location: India
|
|
|
|
Hi Everybody,
I have an issue in my cobol program.
The program takes 2 input files and gives 2 ouput files.
one file which will have account numbers
other will have acccount numbers corresponding records.
to get the records wrt to the account number, I have given the table and search concept.
The problem is when am searching for a account number in input file am getting the last occurence of records correspondint to accountno, I need to get all the records of all the occurances of accountno.
This is the search logic I have used.
Code: |
2400-SEARCH-RACT.
SET REIINDX TO 1
SEARCH REI-TABLE
AT END
MOVE 'N' TO WS-RACT-FOUND-SW
WHEN
WS-REI-TBL-KEY (REIINDX) = WS-ACT-CHECK
MOVE 'Y' TO WS-RACT-FOUND-SW
END-SEARCH.
2400-EXIT.
EXIT.
|
CODE' D
Please help in on this |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
Back to top |
|
|
GaniKrish143
New User
Joined: 30 Jan 2013 Posts: 4 Location: India
|
|
|
|
Hi Entico,
I did not asked for program for matching files.
my requirement is I have the input file which consists of records(80 in lengh) corresponding to each account.
in the second input file I have only the accounts(10 in length) which is coming from prevous step in jcl(the accounts which has the problems).
In the input file this account may occurs so many times, so I need all the records of all occurences of the accountno which is in second input file.
for this I loaded the first input file into a table and the used search concept in first input file using the accountno in the second input file, if a match occurs am moving the corresponding records to output file.
The problem is in search, while in linear search we will set the index to 1, to start from first position.
for example take this scenario, if a match encounters in 49th position, 65 th position, 74 th position and 98 th position.
when writing the output record it is moving only 98 th position records.
not all the matched records.
this is the issue.
and this is the code in search
2400-SEARCH-RACT.
SET REIINDX TO 1
SEARCH REI-TABLE
AT END
MOVE 'N' TO WS-RACT-FOUND-SW
WHEN
WS-REI-TBL-KEY (REIINDX) = WS-ACT-CHECK
MOVE 'Y' TO WS-RACT-FOUND-SW
END-SEARCH.
2400-EXIT.
EXIT. |
|
Back to top |
|
|
Ranjithkumar
New User
Joined: 10 Sep 2008 Posts: 93 Location: India
|
|
|
|
You can make the input file a VSAM (ESDS as you have multiple occurrences for each account). Then use START BROWSE / READ NEXT based on the account from the other file , to achieve what you want. This should be efficient than using the SEARCH. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
enrico's suggestion is much better than what you are doing, whether you asked for it or not. Sorry about that.
Are you saying your File 1 is the largest of the two files you are processing, and may have multiple occurrences (as records) of account-number, distributed across the file? And File 2 is just a list of, unique, account numbers you wish to process?
And then you decided to store the large file with the non-unique occurrences and SEARCH that? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Ranjithkumar wrote: |
You can make the input file a VSAM (ESDS as you have multiple occurrences for each account). Then use START BROWSE / READ NEXT based on the account from the other file , to achieve what you want. |
Are you suggesting making it a CICS program just to do less thinking about how to code it? |
|
Back to top |
|
|
Ranjithkumar
New User
Joined: 10 Sep 2008 Posts: 93 Location: India
|
|
|
|
Bill
I am not suggesting to make it a CICS program. I am suggesting to make the input file VSAM. By START BROWSE i do not mean the CICS STARTBR command. Its the same logic in batch, START the file using account number, read the next record until the key changes. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
So why make BROWSE "look" the same as START? BROWSE means nothing in Cobol.
Now, as to your suggestion re-described. You want to make the dataset VSAM. An ESDS. You want to use START. So you need an ESDS with an alternate index.
And without any information on numbers of records or percentage of "hits" you'd just go with this? Mmmm.... |
|
Back to top |
|
|
chandan.inst
Active User
Joined: 03 Nov 2005 Posts: 275 Location: Mumbai
|
|
|
|
Hi,,
Have you tried using PERFORM- VARYING concept fro searching the table like below
But this will not be good from Performance point of view
Code: |
PERFROM VARYING REIINDX FROM 1 BY 1
UNTIL REIINDEX > MAX value of occurence
IF WS-REI-TBL-KEY (REIINDX) = WS-ACT-CHECK
Do required processing
END-IF
END-PERFORM |
Only thing is you need to have another index which needs to be set to max value of occurence and then use for comparision.
See if this works for you
Regards,
Chandan |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
Quote: |
Hi Entico,
I did not asked for program for matching files. |
first ... learn to spell properly people' s name Enrico
second ...
the way You posted Your requirement ...
TWO input files ....
use the keys in one of them to process records from the other one
is ... in any IT dialect a matching process - whether You like it or not
if You want good answers learn to post CLEAR questions |
|
Back to top |
|
|
GaniKrish143
New User
Joined: 30 Jan 2013 Posts: 4 Location: India
|
|
|
|
sorry Enrico, its type and am new to this site so bit tensed.
anyways Thanks for your valuable sugession |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
GaniKrish143, based on what you have posted so far, your design is broken. A better design would be to sort your first file so the records for a given account are sequential, not scattered throughout the entire file.
If the accounts are scattered across the file, you do not want to use a SEARCH verb. Manually search the entire table looking for matches. |
|
Back to top |
|
|
GaniKrish143
New User
Joined: 30 Jan 2013 Posts: 4 Location: India
|
|
|
|
I tried with Chandan code
its working fine for me
Thank you all of yoU for giving replies |
|
Back to top |
|
|
chandan.inst
Active User
Joined: 03 Nov 2005 Posts: 275 Location: Mumbai
|
|
|
|
Good to know that its working for you..
Regards,
Chandan |
|
Back to top |
|
|
|