Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Splitting variable field CSV file into 2 files.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Splitting variable field CSV file into 2 files.
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    Post subject: Reply to: Splitting variable field CSV file into 2 files.
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us