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

SORT file having multiple Headers


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

New User


Joined: 16 Jul 2012
Posts: 7
Location: India

PostPosted: Mon Jul 16, 2012 6:19 pm
Reply with quote

Hi All,

I have report file with below structure. It has multiple headers (one after 4 records).
The below file is sorted on EMP-ID. I want to sort it on NAME without distrubing header structure.


1********************************************** ---- Header 1
Report Name PAGE : 1 ---- Header 2
********************************************** ---- Header 3
EMP-ID NAME SALARY DEPT ---- Header 4
11111 AAA 10000 IT ---- Main Data
22222 CCC 20000 HR ---- Main Data
33333 GGG 30000 ADMN ---- Main Data
44444 EEE 30000 IT ---- Main Data
1**********************************************
Report Name PAGE : 2
**********************************************
EMP-ID NAME SALARY DEPT
55555 DDD 10000 IT
66666 BBB 20000 HR
77777 HHH 30000 ADMN
88888 FFF 30000 IT
00000008 ---- Trailor


Required output should be sorted on NAME and there should be headers in place (each after every 4 records)


1********************************************** ---- Header 1
Report Name PAGE : 1 ---- Header 2
********************************************** ---- Header 3
EMP-ID NAME SALARY DEPT ---- Header 4
11111 AAA 10000 IT ---- Main Data
66666 BBB 20000 HR ---- Main Data
22222 CCC 20000 HR ---- Main Data
55555 DDD 10000 IT ---- Main Data
1**********************************************
Report Name PAGE : 2
**********************************************
EMP-ID NAME SALARY DEPT
44444 EEE 30000 IT
88888 FFF 30000 IT
33333 GGG 30000 ADMN
77777 HHH 30000 ADMN

00000008 ---- Trailor
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: Mon Jul 16, 2012 6:26 pm
Reply with quote

Yous, to the initial glance, is a simpler version of this problem. Does the solution there help you out?
Back to top
View user's profile Send private message
suhaas02

New User


Joined: 16 Jul 2012
Posts: 7
Location: India

PostPosted: Mon Jul 16, 2012 7:16 pm
Reply with quote

I tried doing SORT using DFSORT utility. However its grouping all headers, then main data and then after trailors.

I am expecting headers then 4 main data records, then header again 4 main data records and at last trailor.

Please help me.
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: Mon Jul 16, 2012 7:56 pm
Reply with quote

You have a file whose "general" order you want to maintain but want to sort within that.

Did you read the other thread? What did you not understand? What, by showing us the code, did you actually try?
Back to top
View user's profile Send private message
suhaas02

New User


Joined: 16 Jul 2012
Posts: 7
Location: India

PostPosted: Mon Jul 16, 2012 8:01 pm
Reply with quote

Actually I just want to sort on main data and after that want to enclose those with headers.

Can we do that using two files. I have now headers in one file and main data (sorted) into another file. Can we copy first 4 records from header file to output file then 4 records from main data file to output. Again 4 from header file and 4 from main data file?

Waiting
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: Mon Jul 16, 2012 8:24 pm
Reply with quote

Waiting?

Yes, you can do it either way. Have you split the file to do this specifically, or is it like that already?
Back to top
View user's profile Send private message
suhaas02

New User


Joined: 16 Jul 2012
Posts: 7
Location: India

PostPosted: Mon Jul 16, 2012 8:34 pm
Reply with quote

Sorry for late reply...

I splitted it into two...One file having only headers and another is having main data...
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Jul 16, 2012 9:46 pm
Reply with quote

suhaas02 wrote:
Sorry for late reply...

I splitted it into two...One file having only headers and another is having main data...


Suhaas02,

You don't have to split the file into 2 and then sort on it. You can do it all in single step.

1. What is the LRECL and RECFM of the input file?
2. What is the LRECL and RECFM of the output file?
3. Can the headers be generated? ( most the header data is constant, so we can generate it later)
4. How do you identify the header records? ex: like this
Code:

(1,1,CH,EQ,C'1',OR,         
 2,6,CH,EQ,C'REPORT',OR,   
 2,6,CH,EQ,C'******',OR,   
 2,6,CH,EQ,C'EMP-ID')       
Back to top
View user's profile Send private message
suhaas02

New User


Joined: 16 Jul 2012
Posts: 7
Location: India

PostPosted: Tue Jul 17, 2012 12:23 pm
Reply with quote

Skolusu wrote:
suhaas02 wrote:
Sorry for late reply...

I splitted it into two...One file having only headers and another is having main data...


Suhaas02,

You don't have to split the file into 2 and then sort on it. You can do it all in single step.

1. What is the LRECL and RECFM of the input file?
133 FB
2. What is the LRECL and RECFM of the output file?
133 FB
3. Can the headers be generated? ( most the header data is constant, so we can generate it later)
The header contains PAGE NO. it should get updated everytime we write it after 4 records. If it is possible to update PAGE NO., then its OK.
4. How do you identify the header records? ex: like this
Code:

(1,1,CH,EQ,C'1',OR,         
 2,6,CH,EQ,C'REPORT',OR,   
 2,6,CH,EQ,C'******',OR,   
 2,6,CH,EQ,C'EMP-ID')       


That's perfect
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jul 17, 2012 11:17 pm
Reply with quote

Use the following DFSORT JCL which will give you the desired results. I assumed that your key to be sorted is at position 8 for 4 bytes.

Code:

//STEP0100 EXEC PGM=SORT     
//SYSOUT   DD SYSOUT=*       
//SORTIN   DD DSN=Your Input FB 133 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  OMIT COND=(1,1,CH,EQ,C'1',OR,                                     
             2,6,CH,EQ,C'REPORT',OR,                                 
             2,6,CH,EQ,C'******',OR,                                 
             2,6,CH,EQ,C'EMP-ID')                                   
                                                                     
  SORT FIELDS=(8,4,CH,A),EQUALS                                           
  OUTFIL REMOVECC,LINES=8,                                           
  HEADER2=('1',132'*'/,                                             
           2:'REPORT NAME:  IBM DATA REPORT',110:'PAGE : ',PAGE,/,   
           133'*'/,                                                 
           2:'EMP-ID NAME SALARY DEPT')                             
//*
Back to top
View user's profile Send private message
suhaas02

New User


Joined: 16 Jul 2012
Posts: 7
Location: India

PostPosted: Mon Aug 06, 2012 4:10 pm
Reply with quote

I was on leave so couldn't reply on time...I really worked for LRECL 80 and not for 133...
I think some minor changes are required...

Thanks to all for support and help !!!
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: Mon Aug 06, 2012 5:07 pm
Reply with quote

suhaas02 wrote:
I was on leave so couldn't reply on time...I really worked for LRECL 80 and not for 133...
I think some minor changes are required...

Thanks to all for support and help !!!


So you're going to manage the change from 133 to 80 yourself?
Back to top
View user's profile Send private message
suhaas02

New User


Joined: 16 Jul 2012
Posts: 7
Location: India

PostPosted: Mon Aug 06, 2012 5:21 pm
Reply with quote

I have read it when I did some search on old posts...I will find it and then test it...
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
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
Search our Forums:

Back to Top