View previous topic :: View next topic
|
Author |
Message |
vishweshkrishnadevaram
New User
Joined: 17 Nov 2006 Posts: 7
|
|
|
|
Hi,
I've a requirement where I need to extract a date from header record of input file and this date should be written to all the data records in output file. Also, I need to use SUM FIELDS to sum data of few fields. Can anyone suggest me, whether we can do this using SORT? |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
vishweshkrishnadevaram,
Show us a sample Data with DCB attributes of the files along with the position of the date field to be moved , the sorting fields and summing fields and their formats |
|
Back to top |
|
|
vishweshkrishnadevaram
New User
Joined: 17 Nov 2006 Posts: 7
|
|
|
|
Hi Kolusu,
Actually the requirement is changed now and the date need not be moved to the data record. Thanks for the response. But just curious to know, if it's possible to retrieve a field from a record and use it in all the next records.
Vishwesh |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
vishweshkrishnadevaram wrote: |
Hi Kolusu,
Actually the requirement is changed now and the date need not be moved to the data record. Thanks for the response. But just curious to know, if it's possible to retrieve a field from a record and use it in all the next records.
Vishwesh |
You can very easily push the header record on to the detail records using the new WHEN=GROUP function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:
I assumed your input is 80 byte lrecl and FB recfm
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
<HEADER> 20080303
<DETAIL1>
<DETAIL2>
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,8,CH,EQ,C'<HEADER>'),
PUSH=(31:10,8)),
IFTHEN=(WHEN=(1,8,CH,EQ,C'<HEADER>'),OVERLAY=(31:8X))
/* |
The output from this job is
Code: |
<HEADER> 20080303
<DETAIL1> 20080303
<DETAIL2> 20080303
|
If you don't have the July, 2008 PTF installed, ask your System Programmer to install it (it's free).
For complete details on the new WHEN=GROUP and the other new functions available with PTF UK90013, see:
Use [URL] BBCode for External Links |
|
Back to top |
|
|
|