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
 

 

Repeat Header on Control Break

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Sun Mar 31, 2013 12:28 pm    Post subject: Repeat Header on Control Break
Reply with quote

Hi All,

I need a help in formatting a CSV file by adding first record (Header) after each control break.

For example my input is as follows
custno,item,cost
1001,234,23.00
1001,437,87.00
1001,787,89.00
1002,777,20.00
1002,343,23.30
1003,778,09.00
1003,989,99.00
1003,999,99.00

Then output file should be BREAK on cust number (repeat headers for each customer change) output should be as follows

custno,item,cost
1001,234,23.00
1001,437,87.00
1001,787,89.00
custno,item,cost
1002,777,20.00
1002,343,23.30
custno,item,cost
1003,778,09.00
1003,989,99.00
1003,999,99.00

Please help this is urgent.

Thanks,
OVReddy.[/list]
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Sun Mar 31, 2013 12:43 pm    Post subject: Reply to: Repeat Header on Control Break
Reply with quote

Quote:
Please help this is urgent.

Your problem... not our icon_evil.gif
claiming urgency will just annoy people,
lowering Your chances of getting help.

did You search the forum? there are quite a few examples of the same requirement
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Sun Mar 31, 2013 2:26 pm    Post subject: Reply to: Repeat Header on Control Break
Reply with quote

You need to look at SECTIONS and HEADER3 on OUTFIL.
Back to top
View user's profile Send private message
rakesha.hg

Active User


Joined: 21 Mar 2008
Posts: 161
Location: bangalore

PostPosted: Tue Apr 02, 2013 11:03 am    Post subject: Reply to: Repeat Header on Control Break
Reply with quote

hi,

Try something like this
Code:

//STEP01 EXEC PGM=SORT                                         
//SYSPRINT DD SYSOUT=*                                         
//SYSOUT   DD SYSOUT=*                                         
//SORTOUT  DD SYSOUT=*                                         
//SORTIN   DD *                                                 
CUSTNO,ITEM,COST                                               
1001,234,23.00                                                 
1001,437,87.00                                                 
1001,787,89.00                                                 
1002,777,20.00                                                 
1002,343,23.30                                                 
1003,778,09.00                                                 
1003,989,99.00                                                 
1003,999,99.00                                                 
//SYSIN   DD *                                                 
  OMIT COND=(1,16,CH,EQ,C'CUSTNO,ITEM,COST')                   
  SORT FIELDS=(1,4,CH,A)                                       
  OUTFIL FNAMES=SORTOUT,                                       
        SECTIONS=(1,4,HEADER3=(1:'CUSTNO,',8:'ITEM,',13:'COST'))
/*                                                             


Output -
Code:
CUSTNO,ITEM,COST
1001,234,23.00 
1001,437,87.00 
1001,787,89.00 
CUSTNO,ITEM,COST
1002,777,20.00 
1002,343,23.30 
CUSTNO,ITEM,COST
1003,778,09.00 
1003,989,99.00 
1003,999,99.00 


Further If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Apr 02, 2013 12:00 pm    Post subject: Reply to: Repeat Header on Control Break
Reply with quote

Code:
//STEP01 EXEC PGM=SORT                                         
//SYSPRINT DD SYSOUT=*                                         
//SYSOUT   DD SYSOUT=*             
//SYMNAMES DD *
CUSTNO-ITEM-COST,C'CUSTNO,ITEM,COST'
//SYMNOUT DD SYSOUT=*                           
//SORTOUT  DD SYSOUT=*                                         
//SORTIN   DD *                                                 
CUSTNO,ITEM,COST                                               
1001,234,23.00                                                 
1001,437,87.00                                                 
1001,787,89.00                                                 
1002,777,20.00                                                 
1002,343,23.30                                                 
1003,778,09.00                                                 
1003,989,99.00                                                 
1003,999,99.00                                                 
//SYSIN   DD *                                                 
  OPTION COPY
  OMIT COND=(1,16,CH,EQ,CUSTNO-ITEM-COST)                   
  OUTFIL SECTIONS=(1,4,HEADER3=(1:CUSTNO-ITEM-COST))
/*


A symbol/SYMNAME can avoid the possibility of a typo, using the same constant for the OMIT and the HEADER3.

The SORT is not needed, unless sorting the file is part of the requirement.
Back to top
View user's profile Send private message
rakesha.hg

Active User


Joined: 21 Mar 2008
Posts: 161
Location: bangalore

PostPosted: Tue Apr 02, 2013 12:30 pm    Post subject: Reply to: Repeat Header on Control Break
Reply with quote

Thanks Bill for the recommendation, will keep in mind for future icon_biggrin.gif
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Sat Apr 06, 2013 10:39 pm    Post subject:
Reply with quote

Thanks for the reply. I got it in a different way but this looks optimized. One more question can we do this for a comma separated file with variable length fields.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Sat Apr 06, 2013 11:16 pm    Post subject: Reply to: Repeat Header on Control Break
Reply with quote

Yes. You can PARSE for the key field, add it to the record, temporarily, use the temporary field with whatever method you have chosen, and drop the temporary field before output.

If that doesn't get you there, post the details in a new topic, please.
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
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm
No new posts Control-M manuals JPVRoff All Other Mainframe Topics 0 Fri May 20, 2016 11:15 am
No new posts Remove header only knobi SYNCSORT 5 Mon Feb 15, 2016 10:42 pm
No new posts GROUP - header data to be repeated in... Musab Ahmed DFSORT/ICETOOL 3 Mon Feb 01, 2016 11:36 am
No new posts Which Control block has the DSNTYPE i... sudarshan.srivathsav PL/I & Assembler 4 Thu Jan 28, 2016 11:29 pm


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