View previous topic :: View next topic
|
Author |
Message |
julian123
New User
Joined: 14 Aug 2006 Posts: 25
|
|
|
|
hi,guys, i have a question.
i download data from a db to a file, and then, i want to insert three lines on the top of this file. how to do it, could you help. thx a lot.
example:
input file:
aaaaaaabbbbbbbcccccccddddddd
aaaaaaabbbbbbbcccccccddddddd
aaaaaaabbbbbbbcccccccddddddd
output file:
*****TITLE***** <-- ADD
REPORT ID: XXXX <-- ADD
FIELD1 FIELD2 FIELD3 FIELD4 <-- ADD
aaaaaaabbbbbbbcccccccddddddd
aaaaaaabbbbbbbcccccccddddddd
aaaaaaabbbbbbbcccccccddddddd |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Julian,
Use the below mentioned SORT card for your reqt.
Code: |
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=OUT1,REMOVECC,
HEADER2=(1:C'************TITLE*********',/,
1:C'REPORT ID: XXXX',/,
1:C'FIELD1 FIELD2 FIELD3 FIELD4'),
OUTREC=(1:1,80)
/*
|
output:
Code: |
************TITLE*********
REPORT ID: XXXX
FIELD1 FIELD2 FIELD3 FIELD4
AAAAAAABBBBBBBCCCCCCCDDDDDDD
AAAAAAABBBBBBBCCCCCCCDDDDDDD
AAAAAAABBBBBBBCCCCCCCDDDDDDD
|
Just change the field positions as per your requirement. |
|
Back to top |
|
|
julian123
New User
Joined: 14 Aug 2006 Posts: 25
|
|
|
|
thank you, Aaru. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Julian,
I'd suggest this DFSORT job instead:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,
HEADER1=(C'************TITLE*********',/,
C'REPORT ID: XXXX',/,
C'FIELD1 FIELD2 FIELD3 FIELD4')
/*
|
You don't need OUTREC= since you're not changing the data records. HEADER1 (the report header) is a better choice than HEADER2 (the page header) for your requirement. HEADER1 will only write the records at the top of the file regardless of how many data records you have. HEADER2 will write the header records at the top of each page so if you have more than one page of data records (> 60) you'll get the header lines more than once. Also, you don't need FNAMES=ddname if you use //SORTOUT as the output data set since FNAMES=SORTOUT is the default. |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Frank,
Thanks a ton for the details. It helped me in understanding the difference between HEADER1 and HEADER2. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Glad I could help. Note that there's also a HEADER3 (the section header). |
|
Back to top |
|
|
julian123
New User
Joined: 14 Aug 2006 Posts: 25
|
|
|
|
hi, Frank and Aaru, thank you very much for your suggestion.
at the beginning, i referred to a book -> dfsort application programming guide.
and i use header1, header2 and header3(within section) to realize it,
but obviously, the solutions you provided are better, thank you. |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Frank,
Quote: |
Note that there's also a HEADER3 (the section header). |
Yes, I had a look at the manual after seeing your last post and got to know about HEADER3. Thanks again.
Julian,
Quote: |
at the beginning, i referred to a book -> dfsort application programming guide. |
You are welcome. The DFSORT getting started.pdf available in the manual section is one excellent material. Do refer to that to more about DFSORT. |
|
Back to top |
|
|
|