IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Create CSV file using DFSORT/ICETOOL


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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

Moderator Emeritus


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

PostPosted: Tue Oct 14, 2008 11:31 am
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
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
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
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
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
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
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:

Use [URL] BBCode for External Links

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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top