IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need to get all the records of all the occurances


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
GaniKrish143

New User


Joined: 30 Jan 2013
Posts: 4
Location: India

PostPosted: Wed Jan 30, 2013 2:51 pm
Reply with quote

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

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Wed Jan 30, 2013 2:58 pm
Reply with quote

USE SORTED FILES
and look at the TWO files match program here
www.ibmmainframes.com/viewtopic.php?t=22649
Back to top
View user's profile Send private message
GaniKrish143

New User


Joined: 30 Jan 2013
Posts: 4
Location: India

PostPosted: Wed Jan 30, 2013 3:35 pm
Reply with quote

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

New User


Joined: 10 Sep 2008
Posts: 93
Location: India

PostPosted: Wed Jan 30, 2013 4:04 pm
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jan 30, 2013 4:08 pm
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jan 30, 2013 4:09 pm
Reply with quote

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

New User


Joined: 10 Sep 2008
Posts: 93
Location: India

PostPosted: Wed Jan 30, 2013 4:15 pm
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jan 30, 2013 4:48 pm
Reply with quote

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

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Wed Jan 30, 2013 4:51 pm
Reply with quote

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

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Wed Jan 30, 2013 5:14 pm
Reply with quote

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

New User


Joined: 30 Jan 2013
Posts: 4
Location: India

PostPosted: Wed Jan 30, 2013 5:17 pm
Reply with quote

sorry Enrico, its type and am new to this site so bit tensed.
anyways Thanks for your valuable sugession icon_smile.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Wed Jan 30, 2013 5:24 pm
Reply with quote

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

New User


Joined: 30 Jan 2013
Posts: 4
Location: India

PostPosted: Wed Jan 30, 2013 5:55 pm
Reply with quote

I tried with Chandan code
its working fine for me

Thank you all of yoU icon_smile.gif for giving replies
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Wed Jan 30, 2013 6:46 pm
Reply with quote

Good to know that its working for you..

Regards,
Chandan
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts To Omit records based n SORT condition DFSORT/ICETOOL 6
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 5
No new posts ICETOOL returns no records JCL & VSAM 1
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
Search our Forums:

Back to Top