|
View previous topic :: View next topic
|
| Author |
Message |
pkmurali Warnings : 1 Active User

Joined: 15 Dec 2005 Posts: 271
|
|
|
|
Hi,
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
and i want the output in the following format.
50010000000001
50020000100002
50030000200003
Is it possible in JCL? |
|
| Back to top |
|
 |
umavivekanand
New User

Joined: 26 Apr 2006 Posts: 5 Location: Banglore
|
|
|
|
Hi Murali ,
My guess is that a simple SYNCSORT jcl should do the trick.
//S010 EXEC PGM=SYNCSORT,REGION=1024K
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1:1,4,5:30,5,10:45,5,15:66X)
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
Please do let me know if this answers your query.
Thanks
Uma  |
|
| Back to top |
|
 |
amrita.chatterjee
New User

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)
/*
I hope this will help you.  |
|
| Back to top |
|
 |
amrita.chatterjee
New User

Joined: 27 Apr 2006 Posts: 48 Location: Bangalore, India
|
|
|
|
Hi
I have done a small mistake, the control card will be
SORT FIELDS=COPY
INREC FIELDS=(1:1,4,5:30,5,10:45,5) |
|
| Back to top |
|
 |
umavivekanand
New User

Joined: 26 Apr 2006 Posts: 5 Location: Banglore
|
|
|
|
Hi Amrita,
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.
please advise. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

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:
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
OPTION COPY
OUTREC FIELDS=(1,4,35,5,70,5)
/*
|
|
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

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. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

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. |
|
| Back to top |
|
 |
umavivekanand
New User

Joined: 26 Apr 2006 Posts: 5 Location: Banglore
|
|
|
|
Sorry abt the confusion guys .. guess i was beating around the bush to give a simple explanation .
guess frank's explanatio says it all :(
Regards
Uma
P.S : and regarding the x,y , z positions , thats was a typing issue from my end , x - posn in o/p file and y : posn in input file |
|
| Back to top |
|
 |
pkmurali Warnings : 1 Active User

Joined: 15 Dec 2005 Posts: 271
|
|
|
|
Thanks You All
Murali. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|