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
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?
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
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