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 to get all the records of all the occurances

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Need to get all the records of all the occurances
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Jan 30, 2013 2:58 pm    Post subject: Reply to: Issue in Cobol Program
Reply with quote

USE SORTED FILES
and look at the TWO files match program here
http://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    Post subject: Issue in Cobol Program
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: 94
Location: India

PostPosted: Wed Jan 30, 2013 4:04 pm    Post subject: Reply to: Issue in Cobol Program
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7233

PostPosted: Wed Jan 30, 2013 4:08 pm    Post subject: Reply to: Issue in Cobol Program
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7233

PostPosted: Wed Jan 30, 2013 4:09 pm    Post subject: Re: Reply to: Issue in Cobol Program
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: 94
Location: India

PostPosted: Wed Jan 30, 2013 4:15 pm    Post subject: Reply to: Issue in Cobol Program
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7233

PostPosted: Wed Jan 30, 2013 4:48 pm    Post subject: Reply to: Issue in Cobol Program
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: 269
Location: Mumbai

PostPosted: Wed Jan 30, 2013 4:51 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Jan 30, 2013 5:14 pm    Post subject: Reply to: Issue in Cobol Program
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    Post subject: Hi
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: 7913
Location: Bellevue, IA

PostPosted: Wed Jan 30, 2013 5:24 pm    Post subject:
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    Post subject: Issue in Cobol
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: 269
Location: Mumbai

PostPosted: Wed Jan 30, 2013 6:46 pm    Post subject:
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    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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts how to split records based on specifi... Venkata Ramayya DFSORT/ICETOOL 6 Wed Sep 28, 2016 3:20 am


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