My requirement is if there is no value in any of the field, then the field should have only a , and not ".
Say there are three fields and the value for one field of one record does not have a value, then the output file should have only a comma.
Whereas if the field has value, it should be enclosed within " and should have a comma after it.
I am giving the input again,
Code:
sandrew bangalore testing
akash development
lisa pune testing
john testing
Code:
Since the place field for secong record does not have any value, it should have only a , and not enclosed within "".
So my output should look like this
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
So in the second record after akash it is three ,,,.
No, it would be two commas:
"akash",,"development",
just like its two commas for the last record:
"john",,"testing",
Here's a DFSORT job that will do what you asked for. Since you didn't say, I assumed field1 is in positions 1-9, field2 is in positions 9-18 and field3 is in positons 20-30. I added more variations in the input records for a better test:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
sandrew bangalore testing
akash development
lisa pune testing
john testing
joan harry
harry
bill
Awesome !!!!!!!!!!! It worked just the way I wanted.
Thank you so much for the solution.
I had a problem while squeezing. It was ignoring the spaces that is between the characters of a field. For Example, If there is a blank between the first name and the last name, I would not want this space to be vanished.
So I added this option while squeezing
OUTREC BUILD=(1,658,SQZ=(SHIFT=LEFT,PAIR=QUOTE))
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
I had a problem while squeezing. It was ignoring the spaces that is between the characters of a field. For Example, If there is a blank between the first name and the last name, I would not want this space to be vanished.
So I added this option while squeezing
OUTREC BUILD=(1,658,SQZ=(SHIFT=LEFT,PAIR=QUOTE))
You didn't show that variation in your example, so I didn't code for it. But good for you for figuring out the solution for that variation yourself (that doesn't seem to happen very often here).