Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

how to insert records to an existing file using dfsort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: how to insert records to an existing file using dfsort
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: 1288
Location: Chennai, India

PostPosted: Tue Oct 23, 2007 10:05 am    Post subject: Reply to: how to insert records to an existing file using df
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    Post subject:
Reply with quote

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

DFSORT Moderator


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

PostPosted: Tue Oct 23, 2007 9:46 pm    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Wed Oct 24, 2007 11:05 am    Post subject: Reply to: how to insert records to an existing file using df
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 Moderator


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

PostPosted: Wed Oct 24, 2007 9:13 pm    Post subject:
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    Post subject: Reply to: how to insert records to an existing file using df
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: 1288
Location: Chennai, India

PostPosted: Thu Oct 25, 2007 10:56 am    Post subject: Reply to: how to insert records to an existing file using df
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 4 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us