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

Combine Duplicate Records within a File using Syncsort


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Ramanan-R

New User


Joined: 21 Mar 2007
Posts: 66
Location: Chennai, Tamilnadu, India

PostPosted: Tue Feb 02, 2010 5:27 pm
Reply with quote

I have an Input File (RECFM=FB,LRECL=80) as below,

First 10 bytes of numeric (Key Field - Cust ID) followed by a space and next 10 bytes (Order Number starts from Column 12)

There can be a maximum of 5 duplicate records/Orders per Key/Cust-ID in the input file.

Input File:
Code:
000020009 XFD0181278
000020009 XAD2316746
000021235 XAC0184197
000021235 XBC5287291
000021235 XBK7267140
000021268 XAM4190257
000021268 XAM2358112
000021268 XAL7921186
000021268 XBW8542133


Expected Output:
Code:
000020009 XFD0181278|XAD2316746
000021235 XAC0184197|XBC5287291|XBK7267140
000021268 XAM4190257|XAM2358112|XAL7921186|XBW8542133


One record for each Cust-ID with their Order numbers separated by Pipe delimiter.


Regards,
Ramanan R
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Feb 04, 2010 6:00 pm
Reply with quote

Ramanan-R,

The first field in your sample data has just 9 digits whereas the explanation given above says it's of 10 bytes. Considering the latter one, the below Synctool job should give you the desired results.
Code:
//STEP0100 EXEC PGM=SYNCTOOL                                   
//TOOLMSG  DD SYSOUT=*                                         
//DFSMSG   DD SYSOUT=*                                         
//IN       DD DSN= Input  File (FB/80)                         
//OUT      DD DSN= Output File (FB/80)                         
//TOOLIN   DD *                                                 
  SPLICE FROM(IN) TO(OUT) ON(1,10,CH) WITH(22,11) WITH(33,11) -
                  WITH(44,11) WITH(55,11) WITHEACH USING(CTL1) 
//CTL1CNTL DD *                                       
  INREC IFTHEN=(WHEN=INIT,                           
        OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,10))),     
        IFTHEN=(WHEN=(81,8,ZD,EQ,1),                 
        BUILD=(1,21)),                               
        IFTHEN=(WHEN=(81,8,ZD,EQ,2),                 
        BUILD=(1,10,22:C'|',12,10)),                 
        IFTHEN=(WHEN=(81,8,ZD,EQ,3),                 
        BUILD=(1,10,33:C'|',12,10)),                 
        IFTHEN=(WHEN=(81,8,ZD,EQ,4),                 
        BUILD=(1,10,44:C'|',12,10)),                 
        IFTHEN=(WHEN=(81,8,ZD,EQ,5),                 
        BUILD=(1,10,55:C'|',12,10)),IFOUTLEN=80       
  SORT FIELDS=COPY
Back to top
View user's profile Send private message
Ramanan-R

New User


Joined: 21 Mar 2007
Posts: 66
Location: Chennai, Tamilnadu, India

PostPosted: Thu Feb 04, 2010 7:43 pm
Reply with quote

Hi Arun icon_smile.gif ,

Thanks for the reply. Actually Cust-ID is 9 bytes and a customer can place a maximum of five orders but the numbers of orders cannot be predicted.

When i tried the below input, the Cust-ID (000020008) and its Order# (XFD0180000) didn't come in output.

Input:

Code:
000020008 XFD0180000 >> (Customer with One Order)
000020009 XFD0181278
000020009 XAD2316746
000021235 XAC0184197
000021235 XBC5287291
000021235 XBK7267140
000021268 XAM4190257
000021268 XAM2358112
000021268 XAL7921186
000021268 XBW8542133


Got Output as below:

Code:
000020009 XFD0181278 |AD2316746                     
000021235 XAC0184197 |BC5287291 |BK7267140           
000021268 XAM4190257 |AM2358112 |AL7921186 |BW8542133


Thanks Again,

Regards,
Ramanan R
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Feb 04, 2010 11:55 pm
Reply with quote

Ramanan-R,

Adding the keyword KEEPNODUPS to ur TOOLIN card should take care of this. I am away from office and cant test this now.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top