|
View previous topic :: View next topic
|
| Author |
Message |
suhaas02
New User
Joined: 16 Jul 2012 Posts: 7 Location: India
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Yous, to the initial glance, is a simpler version of this problem. Does the solution there help you out? |
|
| Back to top |
|
 |
suhaas02
New User
Joined: 16 Jul 2012 Posts: 7 Location: India
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
suhaas02
New User
Joined: 16 Jul 2012 Posts: 7 Location: India
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
suhaas02
New User
Joined: 16 Jul 2012 Posts: 7 Location: India
|
|
|
|
Sorry for late reply...
I splitted it into two...One file having only headers and another is having main data... |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| 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 |
|
 |
suhaas02
New User
Joined: 16 Jul 2012 Posts: 7 Location: India
|
|
|
|
| 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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
suhaas02
New User
Joined: 16 Jul 2012 Posts: 7 Location: India
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| 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 |
|
 |
suhaas02
New User
Joined: 16 Jul 2012 Posts: 7 Location: India
|
|
|
|
| I have read it when I did some search on old posts...I will find it and then test it... |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|