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
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.
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.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
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:
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.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
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.