I need a help.
I have an input file in the following format.
5001TROPICANA PRODUCTS, INC. 00000CORPORATE 00001DISBURSEMENT BANK ACCOUNTS
5002TROPICANA PRODUCTS, INC. 00001CORPORATE 00002DISBURSEMENT BANK ACCOUNTS
5003TROPICANA PRODUCTS, INC. 00002CORPORATE 00003DISBURSEMENT BANK ACCOUNTS
Here, the OUTREC FIELDS command formats the input file to your required output format.
If you notice , there are 3 sets of values in the Command specified
x:y,z
where x: position of the field in the input file
y: Desired position of the field in the output file
z :length of the field
Joined: 27 Apr 2006 Posts: 48 Location: Bangalore, India
Hi,
You can fulfill your requirement by this.
Actually you want to copy the column position 1-4, column position 30-34 & column position 30-34 into the output file so,
you can do this by below job
//JS0010 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=input file,DISP=SHR
//SORTOUT DD DSN=output file,
// DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=30,BLKSIZE=0),
// SPACE=(CYL,(1,1),RLSE),
// UNIT=SMS
//SORTOFXX DD DUMMY
//SORTXSUM DD DUMMY
//SORTWKNN DD UNIT=SYSDA
//SYSIN DD *
SORT FIELDS=COPY
INREC FIELDS=(1:1,4,5:30,5,10:30,5)
/*
As per your answer , INREC FIELDS can be used. But is not mandatory while using INREC that the SORT FIELDS used be one of the fields specified in INREC command. As for the OUTREC command , it is independent of the SORT FIELDS. Here , as per Murali's example , we have given a generic SORT FIELDS=COPY.
So when going for more detailed programming here , my guess is that we'd br forced to use a field not required at all in the output in case we go for the INREC command. But the OUTREC as per my knowledge is independent of the SORT FIELDS command. Hence a dataset can be sorted using a field that NEED not be included in the output in the case of OUTREC which is not the case with the other.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
pkmurali,
Since you didn't use code tags, it's hard to tell what your records look like exactly, but looking at them using the quote function, it appears that you have some spaces that aren't showing, and the fields that you want are actually in 1-4, 35-39 and 70-74. Given that, here's a DFSORT job that will do what you asked for. Note that there are many variations using INREC, OUTREC, OUTFIL, c: (output column), etc which will all work. This version is the simplest:
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Uma wrote
Quote:
If you notice , there are 3 sets of values in the Command specified
x:y,z
where x: position of the field in the input file
y: Desired position of the field in the output file
z :length of the field
You have this wrong. x: is the starting position for the output field. y is the starting position for the input field. z is the length of the input field.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
umavivekanand wrote
Quote:
As per your answer , INREC FIELDS can be used. But is not mandatory while using INREC that the SORT FIELDS used be one of the fields specified in INREC command. As for the OUTREC command , it is independent of the SORT FIELDS. Here , as per Murali's example , we have given a generic SORT FIELDS=COPY.
So when going for more detailed programming here , my guess is that we'd br forced to use a field not required at all in the output in case we go for the INREC command. But the OUTREC as per my knowledge is independent of the SORT FIELDS command. Hence a dataset can be sorted using a field that NEED not be included in the output in the case of OUTREC which is not the case with the other.
Huh? I don't really understand what you're trying to say here, but whatever point you're trying to make about INREC vs OUTREC with COPY is wrong. INREC and OUTREC can both be used with SORT FIELDS=COPY (or OPTION COPY) and perform exactly the same function. INREC is processed before COPY and OUTREC is processed after COPY, but for COPY that really doesn't make any difference. For SORT (e.g. SORT FIELDS=(p,m,f,s)), it does make a difference since INREC reformats the unsorted records while OUTREC reformats the sorted records.
If you're still confused, then please explain clearly what you're confused about and I'll try to clear up your confusion.