Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Compare yesterday's date to the one o... migusd SYNCSORT 7 Fri Sep 22, 2017 11:35 pm
No new posts Comparing 2 Files using Current time arunsoods DFSORT/ICETOOL 3 Fri Sep 22, 2017 6:00 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us