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

Splitting variable field CSV file into 2 files.


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

New User


Joined: 12 Aug 2008
Posts: 7
Location: Chennai, India

PostPosted: Thu Jun 04, 2009 11:37 pm
Reply with quote

Hi all,

I have a requirement to split a Variable lenghth CSV file into 2 files.Each of the fields in the CSV file could change dynamically at record level.

Eg:

Input File ( with 4 fields):

ABC,DEFG,12345,XYZX
ZXYT,REF,WERTYUI,1,
DFRTYUI,HJK,1234,FGH

required Output file ( needs to be split on the 3rd field for each record)

Output file 1:
-----------------
ABC,DEFG,
ZXYT,REF,
DFRTYUI,HJK,

Output file 2
----------------
12345,XYZX
WERTYUI,1
1234,FGH


Is this possible with any of the DFSORT tricks??
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Jun 04, 2009 11:55 pm
Reply with quote

rahmanisgod,

The following JCL will give you the desired results. I assumed that each field has a max length of 10 bytes.

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
ABC,DEFG,12345,XYZX                                                     
ZXYT,REF,WERTYUI,1,                                                     
DFRTYUI,HJK,1234,FGH                                                   
//OUT1     DD SYSOUT=*                                                 
//OUT2     DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  SORT FIELDS=COPY                                                     
  INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=10),                           
               %02=(ENDBEFR=C',',FIXLEN=10),                           
               %03=(ENDBEFR=C',',FIXLEN=10),                           
               %04=(ENDBEFR=C',',FIXLEN=10)),                           
  BUILD=(%01,%02,%03,%04)                                               
                                                                       
 OUTFIL FNAMES=OUT1,BUILD=(01,20,SQZ=(SHIFT=LEFT,MID=C',',TRAIL=C',')) 
 OUTFIL FNAMES=OUT2,BUILD=(21,20,SQZ=(SHIFT=LEFT,MID=C','))             
/* 
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 FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top