Merging Datasets with removing duplicates

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

Post Reply
Harshal_Chaudhari
Member
Posts: 8
Joined: Tue Oct 30, 2012 5:14 pm

Merging Datasets with removing duplicates

Post by Harshal_Chaudhari » Thu Dec 06, 2012 10:25 am

Hi,

I have two datasets with the data as,

1st file:EIC009B
EIC011B
EIC013B
EIC014B
EIC028B
EIC032B

2nd file:APC065B
APC069B
EIC032B
CCC100B
CUC200B
EIC013B
EIC014B
CUC941B
DIC001B
DIC002B
I want to merge both these files into a third dataset and also it should be without any duplicates.So Please help me on this how to achieve this in a one step?

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Thu Dec 06, 2012 12:44 pm

What is your key? RECFM and LRECL of files.

Harshal_Chaudhari
Member
Posts: 8
Joined: Tue Oct 30, 2012 5:14 pm

Post by Harshal_Chaudhari » Thu Dec 06, 2012 4:04 pm

The File parameters are (LRECL=10,BLKSIZE=23470,RECFM=FB)

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Thu Dec 06, 2012 5:13 pm

And.... the... key... is...?

Harshal_Chaudhari
Member
Posts: 8
Joined: Tue Oct 30, 2012 5:14 pm

Post by Harshal_Chaudhari » Thu Dec 06, 2012 8:16 pm

About which key r u talking about did'n get you :roll:

Harshal_Chaudhari
Member
Posts: 8
Joined: Tue Oct 30, 2012 5:14 pm

Post by Harshal_Chaudhari » Thu Dec 06, 2012 8:17 pm

by the way i am not using any key

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Thu Dec 06, 2012 9:37 pm

OK, you want to "merge" two different datasets with different numbers of records and drop the duplicates.

If you have "no key" it is either "impossible" or you use the whole record as a key.

Makes me wonder now what you mean by "merge".

You MERGE on files which are already in sequence on your key (even if it the whole record). As the first few bytes of your records were obviously not in sequence, I presumed (and certainly wasn't going to spend time checking) that you had some other key that was in sequence.

So, it really sounds like you want to SORT, on the entire record, with SUM FIELDS=NONE? Concatenate your input datasets on SORTIN. Give it a whirl.

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Dec 07, 2012 1:56 am

I suspect what will work is a concatenated sort that removes duplicates?

As for the key, i suspect it is all of the data shown (which may or may not be all of the data in the records.
by the way i am not using any key
If you intend to remove duplicates, you will . . .
Have a good one

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Fri Dec 07, 2012 2:21 am

Whatever - why is this in the JCL forum? You cannot do this with JCL - except use the JCL to run a program (probably a sort program) to do what you want. If you think it can be done with JCL then look in the JCL manual.
Regards
Nic

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Dec 07, 2012 2:31 am

Because several forums support sort dialog in their JCL area?
Have a good one

Harshal_Chaudhari
Member
Posts: 8
Joined: Tue Oct 30, 2012 5:14 pm

Post by Harshal_Chaudhari » Fri Dec 07, 2012 9:08 am

For ur understanding my 3rd dataset after merging and removing duplicates will be,

APC069B
CCC100B
CUC200B
EIC032B
EIC009B
EIC011B
EIC013B
EIC014B
EIC028B
EIC032B
CUC941B
DIC001B
DIC002B

I want this kind of data in my output dataset
Hope you get that
Thanx in advance

Reagards,
Harshal
Thanx in advance

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Fri Dec 07, 2012 2:19 pm

Can you look at all the input records on both your input files and the expected output you have shown and EXACTLY state how you get from one to another.

Srilakshmi
Member
Posts: 3
Joined: Fri Feb 08, 2013 4:41 pm
Location: Bangalore

Post by Srilakshmi » Fri Feb 08, 2013 5:16 pm

Hi Harsh,

Use Sortcard as below

//SYSIN DD *
SORT FIELDS=(1,10,CH,A)
SUM FIELDS=(NONE,XSUM)

If you want the duplicate records written into some other file

Write //SORTXSUM DD DSN=FILENAME after the Outfile step

Try this :)
Thanks
Srilakshmi

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Fri Feb 08, 2013 6:16 pm

Did you look at the output order required? What if TS has DFSORT?

Srilakshmi
Member
Posts: 3
Joined: Fri Feb 08, 2013 4:41 pm
Location: Bangalore

Post by Srilakshmi » Fri Feb 08, 2013 6:41 pm

Oops output order is in Alphabetic way. Sorry! then I think it will be helpful if we can add a SEQNUM at the end of each record, remove duplicates and then sort it back using the SEQNUM.
Thanks
Srilakshmi

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others