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

Splitting a file into multiple files / multiple records


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

New User


Joined: 22 Mar 2022
Posts: 2
Location: US

PostPosted: Tue Mar 22, 2022 1:26 am
Reply with quote

Good day!!

Looking to see if SORT can be used to split a file into multiple files based on certain data characteristics. Appreciate any pointers if this can be done using Sort. Pls let me know if you need any additional information.

Input File
1234567890X’01’Name1X’02’Address1X’03’Phone1
2345678901X’01’Name2X’01’Name3X’03’Phone2
3456789012X’01’Name4X’02’Address2X’02’Address3X’03’Phone3X’03’Phone4

The Hex values determine what information follows –
X’01’ the information following this has the Name with Total Length of 20 Chars
X’02’ the information following this has the Address with total of 30 Chars
X’03’ the information following this has the Phone with total of 10 Chars

The output should be as below.

File 01 – Name details
1234567890X’01’Name1
2345678901X’01’Name2
2345678901X’01’Name3
3456789012X’01’Name4

File 02 – Address Details
1234567890X’02’Address1
3456789012X’02’Address2
3456789012X’02’Address3

File 03 – Phone Details
1234567890X’03’Phone1
2345678901X’03’Phone2
3456789012X’03’Phone3
3456789012X’03’Phone4

Regards & thanks
Amar
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Tue Mar 22, 2022 2:10 am
Reply with quote

Please, use the Code button to present ANY sample of your code and/or your data.
Back to top
View user's profile Send private message
amaran18

New User


Joined: 22 Mar 2022
Posts: 2
Location: US

PostPosted: Tue Mar 22, 2022 2:21 am
Reply with quote

Code:
Input File
1234567890X’01’Name1X’02’Address1X’03’Phone1
2345678901X’01’Name2X’01’Name3X’03’Phone2
3456789012X’01’Name4X’02’Address2X’02’Address3X’03’Phone3X’03’Phone4

The Hex values determine what information follows –
X’01’ the information following this has the Name with Total Length of 20 Chars
X’02’ the information following this has the Address with total of 30 Chars
X’03’ the information following this has the Phone with total of 10 Chars

The output should be as below.

File 01 – Name details
1234567890X’01’Name1
2345678901X’01’Name2
2345678901X’01’Name3
3456789012X’01’Name4

File 02 – Address Details
1234567890X’02’Address1
3456789012X’02’Address2
3456789012X’02’Address3

File 03 – Phone Details
1234567890X’03’Phone1
2345678901X’03’Phone2
3456789012X’03’Phone3
3456789012X’03’Phone4
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Tue Mar 22, 2022 4:18 am
Reply with quote

Is each of your separators - X’01’, etc. - really a 5-bytes character string???!!!
Either C’X’’01’’’ or X’01’?
Do you understand the difference?

P.S.
Your own comments to your code ARE NOT part of the code itself. They are not supposed to be enclosed into Code tags.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Tue Mar 22, 2022 4:56 am
Reply with quote

You need to resolve several different and independent issues:

0. How to use the Code button, to make your samples clear to others

1. How to consider your field separators: either as 5-bytes character strings, or 1-byte hexadecimal ones?

2. How to perform parsing of variable length fields in a record?

3. How to split various fixed-length fields into several output “files”=DDNAMES?

You can start to train yourself in each of those steps separately.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Wed Mar 23, 2022 5:43 am
Reply with quote

I do not expect to get clear answers to my simple questions from the TS…

I suppose the field separators are X’01’, X’02’, X’03’, but not C’X’’01’’’ etc.

Code:
//*==============================================================
//SPLIT    EXEC PGM=ICETOOL                                   
//DFMSG    DD  SYSOUT=*                                         
//TOOLMSG  DD  SYSOUT=*                                         
//SORTIN   DD  *                                               
1234567890 Name1 Address1 Phone1                                 
2345678901 Name2 Name3 Phone2                                   
3456789012 Name4 Address2 Address3 Phone3 Phone4               
//*                                                                                                 
//SPLIT    DD  SPACE=(TRK,(20,20))                             
//*                                                             
//NAME     DD  SYSOUT=*                                         
//ADDRESS  DD  SYSOUT=*                                         
//PHONE    DD  SYSOUT=*                                         
//*                                                             
//TOOLIN   DD  *                                               
 COPY FROM(SORTIN)   TO(SPLIT)                 USING(PARS)     
 SORT FROM(SPLIT)    TO(NAME,ADDRESS,PHONE)    USING(SPLT)     
//*                                                             
//PARSCNTL DD  *                                               
 INREC FINDREP=(INOUT=(X'01',X'0001',                           
                       X'02',X'0002',           
                       X'03',X'0003'))           
 SORT FIELDS=COPY                               
 OUTFIL FNAMES=SPLIT,                           
        PARSE=(%=(ENDAT=X'00',                   
                  ENDAT=C' '),                   
               %1=(ENDBEFR=X'00',               
                   ENDBEFR=C' ',                 
                   FIXLEN=20,                   
                   REPEAT=10)),                 
        BUILD=(1,10,%1,                         
             /,1,10,%2,                         
             /,1,10,%3,                         
             /,1,10,%4,                         
             /,1,10,%5,                         
             /,1,10,%6,                         
             /,1,10,%7,                         
             /,1,10,%8,                         
             /,1,10,%9,                         
             /,1,10,%10)                         
//*                                             
//SPLTCNTL DD  *                                 
 SORT FIELDS=(1,10,CH,A),EQUALS                               
 OUTFIL FNAMES=NAME,INCLUDE=(11,1,CH,EQ,X'01')               
 OUTFIL FNAMES=ADDRESS,INCLUDE=(11,1,CH,EQ,X'02')             
 OUTFIL FNAMES=PHONE,INCLUDE=(11,1,CH,EQ,X'03')               
//*                                                           
//*============================================================


P.S.
I also do not expect any thank you…
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Thu Mar 24, 2022 9:48 am
Reply with quote

TOOLIN can be shortened:
Code:
COPY FROM(SORTIN) USING(PARS)
SORT FROM(SPLIT)  USING(SPLT)
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Thu Mar 24, 2022 7:05 pm
Reply with quote

Joerg.Findeisen wrote:
TOOLIN can be shortened:
Code:
COPY FROM(SORTIN) USING(PARS)
SORT FROM(SPLIT)  USING(SPLT)


Yes, but:

1) the first step for the clarity to become degraded

2) not related to the initial issue raised by TS...
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Write line by line from two files DFSORT/ICETOOL 7
Search our Forums:

Back to Top