|
View previous topic :: View next topic
|
| Author |
Message |
Debasis Misra Warnings : 1 New User
Joined: 16 Sep 2008 Posts: 72 Location: Bangalore
|
|
|
|
Hi,
I had a requirement for which i am trying to write a sort. The requirement is as below,
Input file has records unloaded from a Table as below
| Code: |
0001 AA
0001 BB
0001 CC
0002 BB
0002 DD |
I need to get an output file in the format,
| Code: |
0001 AA,BB,CC
0002 BB,DD |
Is it possible to achieve this using sort? |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
Debasis Misra,
How many duplicates can be present in the input for field-1?
And input RECFM/LRECL? |
|
| Back to top |
|
 |
Debasis Misra Warnings : 1 New User
Joined: 16 Sep 2008 Posts: 72 Location: Bangalore
|
|
|
|
Arun,
The duplicates may vary in number. But the max that it can vary is 30.
The first four position indicates the key value. The logical record length of the input file is atleast 7 as the key is 4 byte with a space of 1 byte followed by the value of 2 bytes.
And the output file needs to be just enough to handle 30 duplicates along with the comma. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Debasis,
You can use this DFSORT/ICETOOL job to do what you asked for:
| Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file (FB/7)
//OUT DD DSN=... output file (FB/94)
//TOOLIN DD *
SPLICE FROM(IN) TO(OUT) ON(1,4,CH) WITHEACH -
WITH(9,2) WITH(12,2) WITH(15,2) WITH(18,2) WITH(21,2) -
WITH(24,2) WITH(27,2) WITH(30,2) WITH(33,2) WITH(36,2) -
WITH(39,2) WITH(42,2) WITH(45,2) WITH(48,2) WITH(51,2) -
WITH(54,2) WITH(57,2) WITH(60,2) WITH(63,2) WITH(66,2) -
WITH(69,2) WITH(72,2) WITH(75,2) WITH(78,2) WITH(81,2) -
WITH(84,2) WITH(87,2) WITH(90,2) WITH(93,2) -
USING(CTL1)
//CT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,2,ZD,EQ,23),OVERLAY=(72:6,2)),
IFTHEN=(WHEN=(95,2,ZD,EQ,24),OVERLAY=(75:6,2)),
IFTHEN=(WHEN=(95,2,ZD,EQ,25),OVERLAY=(78:6,2)),
IFTHEN=(WHEN=(95,2,ZD,EQ,26),OVERLAY=(81:6,2)),
IFTHEN=(WHEN=(95,2,ZD,EQ,27),OVERLAY=(84:6,2)),
IFTHEN=(WHEN=(95,2,ZD,EQ,28),OVERLAY=(87:6,2)),
IFTHEN=(WHEN=(95,2,ZD,EQ,29),OVERLAY=(90:6,2)),
IFTHEN=(WHEN=(95,2,ZD,EQ,30),OVERLAY=(93:6,2))
OUTFIL FNAMES=OUT,
BUILD=(1,5,6,89,SQZ=(SHIFT=LEFT,MID=C','))
/*
|
|
|
| Back to top |
|
 |
Gabriel Araujo Alves
New User
Joined: 20 Jul 2010 Posts: 38 Location: Brazil
|
|
|
|
where's my post??? I show some solution...  |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| Your solution was incomplete (for example, you didn't insert the commas) so I deleted it. Please don't post incomplete solutions. We have two DFSORT developers (myself and Kolusu) answering posts here, so we really don't need your "help". |
|
| Back to top |
|
 |
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
Wow Frank
I realize his post was incomplete/incorrect, but that was pretty harsh.
Maybe we should rename this the "Frank and Kolusu Forum".
'No one else need reply - they don't need your help' |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
There are several people who contribute good solutions to this list besides myself and Kolusu. I have no problem with people contributing good solutions. But correcting bad solutions takes too much time away from our day jobs of developing DFSORT and ICETOOL. We participate in several help boards and gets many private e-mails asking for solutions every day. We're happy to help customers use DFSORT and ICETOOL effectively and efficiently, but we don't have time to correct bad or incomplete solutions and such solutions just serve to confuse people.
If you consider that "harsh", I'm sorry.
| Quote: |
| Maybe we should rename this the "Frank and Kolusu Forum". |
No, it's correctly named the "DFSORT/ICETOOL Forum" and it's "staffed" by DFSORT/ICETOOL developers. I would think that having experts respond to the Forum would be considered helpful by most people. Would you want to call a helpline for a product and get "help" from somebody who didn't know the product well? |
|
| Back to top |
|
 |
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
I agree with everything you said.
The part that got me was:
| Quote: |
We have two DFSORT developers (myself and Kolusu) answering posts here, so we really don't need your "help".
|
|
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Not sure what about that "got you".
I said "your" help referring to THAT particular poster. From what I can tell, he just recently started using DFSORT/ICETOOL and is using this Forum to "practice". I advised him previously to feel free to practice all he wants, but not to post incomplete or untested solutions as they don't really help anyone. It's admirable that he wants to learn to use DFSORT/ICETOOL better, but at this point I believe he should be watching and learning until he becomes proficient at which point he can post all he wants. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|