I have a file in which there is a field called claims and there are other fields. I have to put a comma after each value that occurs in claims feild?
I have to put this comma in all the lines except the last one.eg,
Code:
Claims name age
12345, a 20
56789, b 23
11991 c 25
hope this summarises the situation. ( this file is crated by fetching the results of a query into a dataset , so i know the no of lines in a file )?
Can somebody throw some light how this can be accomplished in sort or
any other utilities?
Thanks and Regards,
Deepti
Let me modify the query .
1. The addition of comma can be done thru outrec.
2. The omission of last row can be achieved by STOPREC.
However the problem that now i am facing is that it is a productionised job and hence the count ( i.e no of records in the file ) will change daily ?
hence i cant hardcode any value for stoprec in the sortcard nor i can give any symobolic.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Deepti,
Here's a DFSORT job that will do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.
Code:
//STEP1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//S1 DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
* Add seqnum at end of records.
INREC OVERLAY=(81:SEQNUM,8,ZD)
* T1 has records with seqnums.
OUTFIL FNAMES=T1
* S1 has a symbol as follows:
* LASTRCD,+n
* where n is the seqnum of the last record.
OUTFIL FNAMES=S1,REMOVECC,NODETAIL,
OUTREC=(80X),
TRAILER1=('LASTRCD,+',81,8)
/*
//STEP2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=&&T1,DISP=(OLD,PASS)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
OPTION COPY
* Add a comma for every record except the record
* whose seqnum is LASTRCD. Remove seqnum.
INREC IFOUTLEN=80,
IFTHEN=(WHEN=(81,8,ZD,NE,LASTRCD),
OVERLAY=(6:C','))
/*