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
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am


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