I have the following requirement
Input file: LRECL:10
DATA0001
DATA00002
DATA03
DATA4
DATA 005
DATA06
DATA00002
DATA03
DATA4
DATA 005
DATA06
The space you see in the records are deliberate and not typo. The field in the input file might vary in length, i need all the fields within single quotes followed by a comma except for the last record(last record will have single quotes but should exclude comma and include a closed bracket ')')
Expected Output: LRECL:13
'DATA0001',
'DATA00002',
'DATA03',
'DATA4',
'DATA 005',
' DATA06')
'DATA00002',
'DATA03',
'DATA4',
'DATA 005',
' DATA06')
Sort card i used is as follows:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
BUILD=(1:1,10,JFY=(SHIFT=LEFT,LEAD=C'''',TRAIL=C''',',LENGTH=13)))
OUTFIL FNAMES=SORTOUT,REMOVECC
TRAILER1=(1,12,C')')
INREC IFTHEN=(WHEN=INIT,
BUILD=(1:1,10,JFY=(SHIFT=LEFT,LEAD=C'''',TRAIL=C''',',LENGTH=13)))
OUTFIL FNAMES=SORTOUT,REMOVECC
TRAILER1=(1,12,C')')
The output i am getting:
'DATA0001',
'DATA00002',
'DATA03',
'DATA4',
'DATA 005',
'DATA06',
'DATA06', )
'DATA00002',
'DATA03',
'DATA4',
'DATA 005',
'DATA06',
'DATA06', )
Issues with the above output:
1. When there is a space in the first position of the field(last record) it is getting shifted left as i have left justified, but i want the first character to be space(as input) in the output.
2. I was not able to remove the comma in the last record.
3. I am getting a repetition of the last record, as i have used TRAILER1 function. If possible, i want to avoid this, though it is harmless.
Can someone please help me with this?