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

Merge a variable number of records from a single file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
tuxama

New User


Joined: 25 Jan 2007
Posts: 42
Location: france

PostPosted: Tue Aug 10, 2021 8:35 pm
Reply with quote

Hello,

As input, a single file which contains for example :

Code:

A1 ; SERVICE1 ; MAIL1
A1 ; SERVICE2 ; MAIL2
A1 ; SERVICE3 ; MAIL1
A2 ;                ;
A3 ; SERVICE1 ; MAIL1
A4 ; SERVICE3 ; MAIL25
A4 ; SERVICE6 ; MAIL12
etc.


Expected output :

Code:

A1 ; SERVICE1 ; MAIL1 ; SERVICE2 ; MAIL2 ; SERVICE3 ; MAIL1
A2 ;                ;
A3 ; SERVICE1 ; MAIL1
A4 ; SERVICE3 ; MAIL25 ; SERVICE6 ; MAIL12


The key is on the first two characters
The number of record is variable

The only way I can imagine is a Rexx script.

But I am interested in a DFSORT solution if it exists. because it is a tool that I use when I can.

Does anyone have a lead to explore ?

Thanks by advance
best regards
Alan.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Wed Aug 11, 2021 2:42 am
Reply with quote

You can try for example PARSE and a couple of IFTHEN to reformat, but it won't look pretty nor may it be efficient using a SORT product I afraid.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2024
Location: USA

PostPosted: Wed Aug 11, 2021 7:13 pm
Reply with quote

With SORT, the maximum number of elements to be combined into one string is limited to a reasonable value. Usually about 10 elements, theoretically - up to 100. Each new element requires its own reformatting parameter in SORT statements.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Thu Aug 12, 2021 4:20 am
Reply with quote

little research could get you similar problems and solutions discussed in past.
Please see these posts to get an idea and give a try. If something doesn’t work then share us the results and someone may help further.
www.ibmmainframeforum.com/syncsort-synctool/topic9154.html
www.ibmmainframeforum.com/syncsort-synctool/topic4000.html
Back to top
View user's profile Send private message
tuxama

New User


Joined: 25 Jan 2007
Posts: 42
Location: france

PostPosted: Thu Aug 12, 2021 7:21 pm
Reply with quote

Hello,

Thank you for your time and your answers.
I thought there was no easy fix.

I will do a little rexx it will be simple and easily maintainable.

tuxama.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2024
Location: USA

PostPosted: Thu Aug 12, 2021 8:12 pm
Reply with quote

REXX approach should be OK unless you need to handle millions, or hundreds of millions records. Otherwise you might be faced performance issues.

P.S.
The total number of code needed for REXX solution is not seriously different from SORT solution.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts ICETOOL returns no records JCL & VSAM 1
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
Search our Forums:

Back to Top