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 Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm
No new posts ISSUE IN copying Sequential file reco... thesumitk JCL & VSAM 2 Wed Dec 13, 2017 3:07 pm
No new posts File Tailoring -- Temporary dataset i... samzee71 CLIST & REXX 3 Fri Dec 01, 2017 3:12 am
No new posts Rexx - File tailoring samzee71 CLIST & REXX 10 Thu Nov 30, 2017 10:47 pm
No new posts Compare VSAM files using DFSORT pshongal DFSORT/ICETOOL 5 Thu Nov 23, 2017 10:24 am

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