IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

how to insert records to an existing file using dfsort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
julian123

New User


Joined: 14 Aug 2006
Posts: 25

PostPosted: Tue Oct 23, 2007 9:05 am
Reply with quote

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
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Tue Oct 23, 2007 10:05 am
Reply with quote

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
View user's profile Send private message
julian123

New User


Joined: 14 Aug 2006
Posts: 25

PostPosted: Tue Oct 23, 2007 11:24 am
Reply with quote

thank you, Aaru.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Oct 23, 2007 9:46 pm
Reply with quote

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
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed Oct 24, 2007 11:05 am
Reply with quote

Frank,

Thanks a ton for the details. It helped me in understanding the difference between HEADER1 and HEADER2.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Oct 24, 2007 9:13 pm
Reply with quote

Glad I could help. Note that there's also a HEADER3 (the section header).
Back to top
View user's profile Send private message
julian123

New User


Joined: 14 Aug 2006
Posts: 25

PostPosted: Thu Oct 25, 2007 9:31 am
Reply with quote

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
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Oct 25, 2007 10:56 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top