|
View previous topic :: View next topic
|
| Author |
Message |
harinair_kn Warnings : 2 New User

Joined: 27 Feb 2006 Posts: 16 Location: India
|
|
|
|
Please find the joinkey sort below.
| Code: |
//STEP00A EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD DSN=SKUROOL.INPUT1,DISP=SHR
//SORTJNF2 DD DSN=SKUROOL.INPUT2,DISP=SHR
//SORTOUT DD DSN=...
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(1,4,A)
JOINKEYS FILES=F2,FIELDS=(1,4,A)
REFORMAT FIELDS=(F1:1,4,F2:5,4)
SORT FIELDS=COPY
|
Is there any possible REFORMAT option to get an output with sum of any fields?
Eg:
Input 1 - 1001 500
Input 2 - 1001 550
Required Output - 1001 1050 |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Please state your requirement clearly...
If you just want to add values based on key, use of just SORT FIELDS\SUM FIELDS will suffice. join keys not required for this.
Please provide below information:
1: LRECL\RECFM of all input and output files
2: key field and other field positions\lengths
3: Sample input records
4: Expected output records for sample input shown. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
REFORMAT is NOT used for summing. REFORMAT is used for joining the records.
If you want to sum fields, you can use SORT/SUM, or OUTFIL with TRAILERx and TOT, for the records produced by REFORMAT. For example:
| Code: |
JOINKEYS FILES=F1,FIELDS=(1,4,A)
JOINKEYS FILES=F2,FIELDS=(1,4,A)
REFORMAT FIELDS=(F1:1,4,F2:5,4)
SORT FIELDS=COPY
OUTFIL TRAILER1=(TOT=(1,4,ZD,TO=ZD),X,TOT=(5,4,ZD,TO=ZD))
|
You would have to give more details about what your trying to do before I could give you more specific help. Show an example of the records in each input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input files. If file1 can have duplicates within it, show that in your example. If file2 can have duplicates within it, show that in your example. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|