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

Repeat Header on Control Break


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sun Mar 31, 2013 12:43 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Mar 31, 2013 2:26 pm
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
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:

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Apr 02, 2013 12:00 pm
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
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Apr 06, 2013 11:16 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts Build a record in output file and rep... DFSORT/ICETOOL 11
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
No new posts Repeat a DD line- comment and insert ... CA Products 3
No new posts Comparing Header and Trailer. DFSORT/ICETOOL 7
Search our Forums:

Back to Top