SORT 2 COLUMNS INTO DISTINCT SINGLE COLUMN

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
Dunbar
Member
Posts: 7
Joined: Tue Jun 17, 2014 8:50 pm
Location: Arkansas

SORT 2 COLUMNS INTO DISTINCT SINGLE COLUMN

Post by Dunbar » Tue Jun 24, 2014 4:09 am

Im attempting to merge/splice/combine 2 columns into one single column and remove any duplicates. Any help would be greatly appreciated.

1 input file. Two columns are (11,16) and (28,16). Both columns could contain duplicates.

Code: Select all

000394187 0003 0000 000708 0003 0000 000707
000677514 0006 0000 002350 0006 0000 002915
000694993 0006 0000 002350 0006 0000 009905
Desired output would be

Code: Select all

0003 0000 000707
0003 0000 000708 
0006 0000 002350
0006 0000 002915
0006 0000 009905
 
This is as close as I can get so far... I think the 2nd copy is not keeping the results from the first copy so Im only seeing records from 2nd columns.

Code: Select all

//TOOLIN   DD *
 COPY FROM(SORT1) TO(T1) USING(CTL1)
 COPY FROM(SORT1) TO(T1) USING(CTL2)
 SORT FROM(T1) TO(LIST) USING(CTL3)
/*
//CTL1CNTL DD *
 INREC BUILD=(11,16)
/*
//CTL2CNTL DD *
 INREC BUILD=(28,16)
/*
//CTL3CNTL DD *
 SORT FIELDS=(1,16,CH,A)
/*
Any help would be greatly appreciated.

Dunbar
Member
Posts: 7
Joined: Tue Jun 17, 2014 8:50 pm
Location: Arkansas

Post by Dunbar » Tue Jun 24, 2014 4:32 am

Figured out part of it, I had the wrong disp on my T1 dataset. Now Im getting closer. Now I just need to get rid of the duplicate records.

Dunbar
Member
Posts: 7
Joined: Tue Jun 17, 2014 8:50 pm
Location: Arkansas

Post by Dunbar » Tue Jun 24, 2014 4:39 am

Figured it out.

Code: Select all

//TOOLIN   DD *
 COPY FROM(IN1) TO(T1) USING(CTL1)
 COPY FROM(IN1) TO(T1) USING(CTL2)
 SORT FROM(T1) TO(OUT1) USING(CTL3)
/*
//CTL1CNTL DD *
 INREC BUILD=(11,16)
/*
//CTL2CNTL DD *
 INREC BUILD=(28,16)
/*
//CTL3CNTL DD *
 SORT FIELDS=(1,16,CH,A)
 SUM FIELDS=NONE
/*

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

Post by William Collins » Tue Jun 24, 2014 2:06 pm

You could use ICETOOL's RESIZE (if you have DFSORT) or OUTFIL's BUILD with the slash operator (/) to put the first two passes of the file into one.

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