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

Easytrieve - how to get all matching records


IBM Mainframe Forums -> CA Products
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
lakshmi08

New User


Joined: 01 Jul 2010
Posts: 6
Location: delhi

PostPosted: Mon Jul 05, 2010 5:13 pm
Reply with quote

Hi all,
I got a requirement to compare two sequential files and write the matched records to one file and non matched records to another file using eazytreive. However, here the case is that even the repeated matching records should be written to the outfile. Like for example,
Infile1:
ERA
ERA
ERI
ERI
ENM

INFILE2:
ERA
ERA
ERA
ENM

then the matched out file should have:
ERA
ERA
ERA
ERA
ERA
ERA
ENM

Can anyone suggest how to proceed for this?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Mon Jul 05, 2010 5:18 pm
Reply with quote

Look at the JCl / DFSORT forums, depending on which sort product that you have installed.

Matching records is a very common request and there will be many good examples.
Back to top
View user's profile Send private message
lakshmi08

New User


Joined: 01 Jul 2010
Posts: 6
Location: delhi

PostPosted: Mon Jul 05, 2010 5:35 pm
Reply with quote

But the requirement is to write it in eazytrieve, just wondering if it is feasible or not? because you have to get the repeated records from file 1 as well as from file2(two input files)
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Mon Jul 05, 2010 5:43 pm
Reply with quote

Well, it seems to me that the person who set the requirement by stating that a great waste of effort is needed here, is somewhat mentally lagging behind a cerebally impaired amoeba.

A sort solution would take about 10 minutes to produce and without fail be far more resource efficient that any home grown program.

So what logic will you employ to do this ?
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Mon Jul 05, 2010 5:44 pm
Reply with quote

Match/Merge in the Easytrev manual (chapter synchronized file processing) will explain it all.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Mon Jul 05, 2010 5:51 pm
Reply with quote

This will work for your given example. It may be worth comparing the resource used by both methods .
Code:
//STEP0010 EXEC PGM=ICETOOL                       
//TOOLMSG  DD SYSOUT=*                           
//DFSMSG   DD SYSOUT=*                           
//IN1      DD DSN=Input file 1,DISP=SHR       
//         DD DSN=Input file 2,DISP=SHR       
//OUT      DD SYSOUT=*                           
//OUT2     DD SYSOUT=*                           
//TOOLIN   DD *                                   
 SELECT FROM(IN1) TO(OUT) ON(1,3,CH) ALLDUPS DISCARD(OUT2)     
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Mon Jul 05, 2010 6:00 pm
Reply with quote

Expat,

poaching on someone's (my) territory icon_biggrin.gif
Back to top
View user's profile Send private message
lakshmi08

New User


Joined: 01 Jul 2010
Posts: 6
Location: delhi

PostPosted: Mon Jul 05, 2010 6:01 pm
Reply with quote

Sorry, I forgot to mention that the key position of the two input files are not the same. For input file 1 the position is from 15 to 18 position. For 2nd input position it is 1st position to 4 rth position.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Mon Jul 05, 2010 6:04 pm
Reply with quote

lakshmi08,

after all help you got till now, start to RTFM.

A sample :

Code:

FILE TRANSA1                                                            00360007
TRANID      1      1 A                                                  00370007
TRANAV      1      8 A                                                  00380007
CLASSAV    11      3 A                                                  00390007
PSBAV      16      8 A                                                  00400007
*                                                                       00410007
FILE TRANSFC                                                            00420007
TRANID      1      1 A                                                  00430007
TRANFC      1      8 A                                                  00440007
CLASSFC    11      3 A                                                  00450007
PSBFC      16      8 A                                                  00460007
*                                                                       00470007
FILE TRANS                                                              00480007
TRANREC     1     30 A                                                  00490007
TRANUT      1      8 A                                                  00500007
PSBUT       9      8 A                                                  00510007
CLASS1     17      3 A                                                  00520007
SYS1       20      4 A                                                  00530007
CLASS2     24      3 A                                                  00540007
SYS2       27      4 A                                                  00550007

JOB INPUT(TRANSA1 KEY(TRANAV, PSBAV) TRANSFC KEY(TRANFC, PSBFC))        00940007
IF MATCHED                                                              00950007
   TRANUT = TRANAV                                                      00960007
   PSBUT = PSBAV                                                        00970007
   CLASS1 = CLASSAV                                                     00980007
   SYS1 = 'A1#1'                                                        00990007
   CLASS2 = CLASSFC                                                     01000007
   SYS2 = 'FC00'                                                        01010007
   PUT TRANS                                                            01020007
   GOTO JOB                                                             01030007
END-IF                                                                  01040007
IF NOT TRANSA1                                                          01050007
   TRANUT = TRANFC                                                      01060007
   PSBUT = PSBFC                                                        01070007
   CLASS1 = ' '                                                         01080007
   SYS1 = ' '                                                           01090007
   CLASS2 = CLASSFC                                                     01100007
   SYS2 = 'FC00'                                                        01110007
   PUT TRANS                                                            01120007
   GOTO JOB                                                             01130007
END-IF                                                                  01140007
IF NOT TRANSFC                                                          01150007
   TRANUT = TRANAV                                                      01160007
   PSBUT = PSBAV                                                        01170007
   CLASS1 = CLASSAV                                                     01180007
   SYS1 = 'A1#1'                                                        01190007
   CLASS2 = ' '                                                         01200007
   SYS2 = ' '                                                           01210007
   PUT TRANS                                                            01220007
   GOTO JOB                                                             01230007
END-IF                                                                  01240007
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Mon Jul 05, 2010 6:12 pm
Reply with quote

PeterHolland wrote:
Expat,
poaching on someone's (my) territory icon_biggrin.gif

Peter, please consider me suitably chastised icon_eek.gif

However I'd still go for the sort solution.
Back to top
View user's profile Send private message
rkarthik22

New User


Joined: 18 Apr 2009
Posts: 47
Location: India

PostPosted: Fri Jul 09, 2010 5:08 pm
Reply with quote

Hi Lakshmi,

have you try the solution given by Mr. Expat and Mr.Peter?

Thanks,
Karthik
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Fri Jul 09, 2010 7:33 pm
Reply with quote

Hello,

@lakshmi08 -

Please re-read your original post. There are 5 ERA records and 2 ENM input records but your "expected output" shows 6 ERA znd only 1 ENM. Is that is really what you want?

You never did post why you had a problem. . .

Have you tried the suggestions already provided?
Back to top
View user's profile Send private message
rkarthik22

New User


Joined: 18 Apr 2009
Posts: 47
Location: India

PostPosted: Fri Jul 09, 2010 7:59 pm
Reply with quote

Hi d.sch.,

I dont find any issue with the input and the expected output records...

Since it is many-to-many match concept, the expected o/p is correct.

(both the input files has got duplicates)

It goes like this..

Infile1 1st ERA is matched to first three ERA's of infile2

Infile2 2nd ERA is matched to first three ERA's of infile2

So totally Six ERA's in the output.

Infile1 last record ENM is matched to infile2 's ENM . so totally one ENM records.

Finally, the expected output should be correct

@lakshmi,

Can you pls share what you have tried so far?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Fri Jul 09, 2010 8:19 pm
Reply with quote

Hello,

Quote:
I dont find any issue with the input and the expected output records...

Since it is many-to-many match concept, the expected o/p is correct.
Only with assumptions. . . . Because a proper explanation was not initially posted icon_sad.gif

Let's assume that these are inventory items. If a "matched" list was needed, there are 5 ENA items not 6.

One way to do get to your understanding of the needed output is to use arrays and not use the MATCHED feature of Easytrieve.
Back to top
View user's profile Send private message
rkarthik22

New User


Joined: 18 Apr 2009
Posts: 47
Location: India

PostPosted: Fri Jul 09, 2010 8:56 pm
Reply with quote

We had this kind of similar requirement last year.

Description:

Generally with eazytrieve we cant handle many to many situation's , i.e if we are having a match on two files then the first file should have only single occurrences of the key, but with this code you can deal with many to many condition,that is multiple occurences of key in file1 and as well as in file2.

Solution:

we can solve this using an working storage array, terms used in this code are first dup (which means the first duplicate record in a set of duplicate records),
in if matched , only the first record of a group will be handled, rest will be treated as not matched so the rest of records in a group will be handled in not matched.
last-dup means last duplicate record in a set of duplicate records.

1)so for the first duplicate record in a group it will come under if matched and i will write all the records from file2 in a array till the key is same.

2)so for the second record in a group(from the first file)it will come under if not matched and we will read from the ws-array instead of file til the key is same (save key = rcifkey1 )

3)and when we reach the last dup in a group we will move spaces to the array for handling the next group.

I will NOT post the code , until i get back something from the OP - Lakshmi.

I dont know whether he/she tried anything yet!!!!
Back to top
View user's profile Send private message
CaptBill

New User


Joined: 28 May 2009
Posts: 20
Location: Oklahoma City, OK USA

PostPosted: Sat Jul 10, 2010 5:34 am
Reply with quote

lakshmi08 wrote:
But the requirement is to write it in eazytrieve, just wondering if it is feasible or not? because you have to get the repeated records from file 1 as well as from file2(two input files)


As a "professional" problem solver (that's what a programmer is) you get a set of requirements from a client. It is your job to decide on the appropriate tool to use, not the client OR your manager. They tell you what they need, you decide how to deliver it to them.
Back to top
View user's profile Send private message
lakshmi08

New User


Joined: 01 Jul 2010
Posts: 6
Location: delhi

PostPosted: Mon Jul 12, 2010 2:13 pm
Reply with quote

Hi all,
Sorry for the delayed reply...the explanation given by rkarthik22 is correct. In the first infile for one ERA occurence there are 3 matching ERAs in the second file, and similarly for the second ERA too. Hence 6 ERAs in the output is correct requirement.
However I didn't try the alternatives given by xperts in this post, I tried it by writing a COBOL code and it worked fine for me. I know it may not be an optimal solution but due to the time constraint on the deliverable I couldn't experiment.
Back to top
View user's profile Send private message
rkarthik22

New User


Joined: 18 Apr 2009
Posts: 47
Location: India

PostPosted: Mon Jul 12, 2010 3:32 pm
Reply with quote

@Lakshmi,

Thanks for letting us know...

I will share the easytrieve code tomorrow sure...

Can you please share your cobol code with us...
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 -> CA Products

 


Similar Topics
Topic Forum Replies
No new posts Overwriting SSN Digits in Easytrieve ... CA Products 0
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
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
Search our Forums:

Back to Top