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
 

 

Create CSV file using DFSORT/ICETOOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Srileka

New User


Joined: 21 Jun 2007
Posts: 19
Location: India

PostPosted: Tue Oct 14, 2008 10:02 am    Post subject: Create CSV file using DFSORT/ICETOOL
Reply with quote

Hi,
I have a requirement to create a CSV file. All the fields in my input are not of same length. The start/end position of the fields may not be the same every time i generate the Input file.

Input
1----- 2-------- 3---------------- 4--- 5------
514 514 A123456789012345 P 1009200
514 514 B123456789012345 P 1013200
514 514 C123456789012345 P 1013200


Output
1-----,2--------,3----------------,4---,5------
514 ,514 ,A123456789012345 ,P ,1009200
514 ,514 ,B123456789012345 ,P ,1013200
514 ,514 ,C123456789012345 ,P ,1013200

Please let me know if this is possible with DFSORT/ICETOOL.

Thanks in Advance.
Srileka.V
Back to top
View user's profile Send private message

Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Oct 14, 2008 11:30 am    Post subject:
Reply with quote

Quote:
The start/end position of the fields may not be the same every time i generate the Input file.

How will you identify the field? Are they seperated by Space?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Oct 14, 2008 11:31 am    Post subject:
Reply with quote

Hello,

How should the process know when to insert a comma and how many commas should be inserted?

You need to post the "rules" for processing.
Back to top
View user's profile Send private message
Srileka

New User


Joined: 21 Jun 2007
Posts: 19
Location: India

PostPosted: Tue Oct 14, 2008 12:23 pm    Post subject:
Reply with quote

Hi,
The start and end positions of the fields can be identified by the spaces in the below line. This is the first line of the input file.

1----- 2-------- 3---------------- 4--- 5------

Other lines can have more than one spaces between the fields and the fields themselves can also have spaces.

Say a COMMENT field can have a value like 'This is for test'

Thanks,
Srileka.V
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Oct 14, 2008 12:31 pm    Post subject:
Reply with quote

If field has space inbetween as example shown by you above will the field will be enclosed in the QUOTES or DOUBLE QUOTES? like 'This is for test' OR "This is for test" ?

Also,
Show us the example of when any field is blank? will the be three spaces as

here field four is blank.
-----s--------s----------------sss------
please clarify on these.
Back to top
View user's profile Send private message
Srileka

New User


Joined: 21 Jun 2007
Posts: 19
Location: India

PostPosted: Tue Oct 14, 2008 12:46 pm    Post subject:
Reply with quote

No the fields are not enclosed by any quotes.

I have masked my input file.

Here the ~ signs are the spaces which are part of field value. And # are delimiter spaces. So the only way of finding the start and end positions of the fields is to identify the positions of # in the first line.

Code:

1-----#2--------#3----------------#4---#5------#6-----#7------------#
514~~~#514~~~~~~#A123456789012345~#P~~~#1009200#~~~~~~#THIS~IS~TEST1#
514~~~#514~~~~~~#B123456789012345~#P~~~#1013200#~~~~~~#THIS~IS~TEST2#
514~~~#514~~~~~~#C123456789012345~#P~~~#1013200#~~~~~~#THIS~IS~TEST3#


Please let me know if am not clear.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Oct 14, 2008 3:37 pm    Post subject:
Reply with quote

Do you want spaces between two fields to be eaten up?
Post output expected for above posted input using CODE window
Back to top
View user's profile Send private message
Srileka

New User


Joined: 21 Jun 2007
Posts: 19
Location: India

PostPosted: Tue Oct 14, 2008 4:25 pm    Post subject:
Reply with quote

This is the expected output. It is not a problem even if you remove the leading and trailing blanks of the fields.


Code:
1-----,2--------,3----------------,4---,5------,6-----,7------------,
514   ,514      ,A123456789012345 ,P   ,1009200,      ,THIS IS TEST1,
514   ,514      ,B123456789012345 ,P   ,1013200,      ,THIS IS TEST2,
514   ,514      ,C123456789012345 ,P   ,1013200,      ,THIS IS TEST3,

Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Oct 14, 2008 10:38 pm    Post subject: Reply to: Create CSV file using DFSORT/ICETOOL
Reply with quote

Srileka,

The following DFSORT JCL will give you the desired results. I assumed you only have 7 fields and the max of each field can be 20 bytes. If it is more than that you can adjust the length.

I also assumed that you have only 1 field where you want to preserve the space in between.ie. in the sample input your last field. If you have more fields then just enclose them in quotes and you are all set. I also used FINDREP to remove the quotes we added for preserving the spaces. FINDREP function of DFSORT IS available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) For complete details on the FINDREP function and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/

If you don't have that DFSORT PTF installed, ask your System Programmer to install it.

Code:

//STEP0100 EXEC PGM=ICEMAN                                           
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
514   #514      #A123456789012345 #P   #1009200#      #THIS IS TEST1#
514   #514      #B123456789012345 #P   #1013200#      #THIS IS TEST2#
514   #514      #C123456789012345 #P   #1013200#      #THIS IS TEST3#
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                   
  INREC PARSE=(%00=(ENDBEFR=C'#',FIXLEN=20),                         
               %01=(ENDBEFR=C'#',FIXLEN=20),                         
               %02=(ENDBEFR=C'#',FIXLEN=20),                         
               %03=(ENDBEFR=C'#',FIXLEN=20),                         
               %04=(ENDBEFR=C'#',FIXLEN=20),                         
               %05=(ENDBEFR=C'#',FIXLEN=20),                         
               %06=(ENDBEFR=C'#',FIXLEN=20)),                         
         BUILD=(%00,%01,%02,%03,%04,%05,C'''',%06,C'''')             
                                                                     
  OUTREC IFTHEN=(WHEN=INIT,                                           
  BUILD=(1,140,SQZ=(SHIFT=LEFT,PAIR=APOST,MID=C','))),               
  IFTHEN=(WHEN=INIT,FINDREP=(IN=C'''',OUT=C''))                       
/*                                                                   


The output from this job is

Code:

514,514,A123456789012345,P,1009200,THIS IS TEST1
514,514,B123456789012345,P,1013200,THIS IS TEST2
514,514,C123456789012345,P,1013200,THIS IS TEST3
Back to top
View user's profile Send private message
Srileka

New User


Joined: 21 Jun 2007
Posts: 19
Location: India

PostPosted: Wed Oct 15, 2008 9:21 am    Post subject:
Reply with quote

Thanks a lot for your response. But #, ~ are both spaces. I just used them as a mask for differentiating the delimiter space and the space wich is part of the field value. This is the original input file.
Code:
1----- 2-------- 3---------------- 4--- 5------ 6----- 7------------
514    514       A123456789012345  P    1009200        THIS IS TEST1
514    514       B123456789012345  P    1013200        THIS IS TEST2
514    514       C123456789012345  P    1013200        THIS IS TEST3


The number of fields may vary. Also field 7 is not the only field to have spaces in between. More than one fileds can also have spaces as their value.

I am really sorry if i have confused you.

Thanks,
Srileka.V
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Oct 16, 2008 12:25 am    Post subject:
Reply with quote

srileka,

You need to come up with the max number of fields. If you have more fields where you need to preserve the spaces then you need create them enclosed in quotes or apostrophes, so that it is easy to distinguish them.
Back to top
View user's profile Send private message
Srileka

New User


Joined: 21 Jun 2007
Posts: 19
Location: India

PostPosted: Thu Oct 16, 2008 9:32 am    Post subject:
Reply with quote

Thank you Kolusu. I shall try that way when generating my input file.
If that is not possible, REXX will easily solve this.

Thanks,
Srileka.V
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