View previous topic :: View next topic
Author
Message
Ramanan-R New User Joined: 21 Mar 2007Posts: 66 Location: Chennai, Tamilnadu, India
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
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
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
Ramanan-R New User Joined: 21 Mar 2007Posts: 66 Location: Chennai, Tamilnadu, India
Hi Arun ,
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
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
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
Please enable JavaScript!