Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Combine Duplicate Records within a File using Syncsort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Combine Duplicate Records within a File using Syncsort
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: 2285
Location: @my desk

PostPosted: Thu Feb 04, 2010 6:00 pm    Post subject:
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    Post subject:
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: 2285
Location: @my desk

PostPosted: Thu Feb 04, 2010 11:55 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us