Q: Can I write a matrix report in SQR?
A: Yes. Example of a SQR cross-tab (matrix) report
---------------------------- Example code begins here -------------------------
Begin-Setup
Page-Size 60 133
declare printer
type = postscript
orientation = landscape
line-size = 8
char-size = 6
End-Setup
Begin-Report
Graphic (5,1,122) box 59 12
Graphic (1,20,103) box 63 12
Graphic (1,55,33) box 63 12
Graphic (8,1,122) horz-line 12
Graphic (11,1,122) horz-line 12
Graphic (14,1,122) horz-line 12
Graphic (17,1,122) horz-line 12
Graphic (20,1,122) horz-line 12
Graphic (23,1,122) horz-line 12
Graphic (26,1,122) horz-line 12
Graphic (29,1,122) horz-line 12
Graphic (32,1,122) horz-line 12
Graphic (35,1,122) horz-line 12
Graphic (38,1,122) horz-line 12
Graphic (41,1,122) horz-line 12
Do Main
End-Report
Begin-Procedure Main
let #count = 0
do DRA_HEADER
Begin-Select
iin_descr (+1,3,15) on-break print=change/top-page after=PRINT_DETAIL
so_code
decode(so_code,'D',count(esn_nbr)) &d_count_esn_nbr
decode(so_code,'D',nvl(sum(lbr_hrs),0)) &d_lbr_hrs
decode(so_code,'R',count(esn_nbr)) &r_count_esn_nbr
decode(so_code,'R',nvl(sum(lbr_hrs),0)) &r_lbr_hrs
decode(so_code,'A',count(esn_nbr)) &a_count_esn_nbr
decode(so_code,'A',nvl(sum(lbr_hrs),0)) &a_lbr_hrs
do GET_ESN_COUNT_2
if &so_code = 'D'
Move &d_count_esn_nbr to #d_count_esn_nbr
Move &d_lbr_hrs to #d_lbr_hrs
Divide #count_esn_nbr_2 into #d_lbr_hrs
add 1 to #count
end-if
if &so_code = 'R'
Move &r_count_esn_nbr to #r_count_esn_nbr
Move &r_lbr_hrs to #r_lbr_hrs
Divide #count_esn_nbr_2 into #r_lbr_hrs
add 1 to #count
end-if
if &so_code = 'A'
Move &a_count_esn_nbr to #a_count_esn_nbr
Move &a_lbr_hrs to #a_lbr_hrs
Divide #count_esn_nbr_2 into #a_lbr_hrs
add 1 to #count
end-if
from so, lbr_usage
where so.so_nbr = lbr_usage.so_nbr
and lbr_usage.eng_mdl_nbr = '06'
and so_code in ('D', 'R', 'A')
group by iin_descr, so_code
End-Select
End-Procedure
Begin-Procedure GET_ESN_COUNT_2
Begin-Select
count(esn_nbr) &count_esn_nbr_2
Move &count_esn_nbr_2 to #count_esn_nbr_2
from so, lbr_usage
where so.so_nbr = lbr_usage.so_nbr
and lbr_usage.iin_descr = &iin_descr
and lbr_usage.eng_mdl_nbr = '06'
group by iin_nbr
End-Select
End-Procedure
Begin-Procedure DRA_HEADER
Print 'Disassembly' (1,32) bold
Print 'Routing/Repair' (,65) bold
Print 'Assembly' (,100) bold
Print ' # of Avg.Hrs.' (3,25) bold
Print 'Engines per Engine Applied%' (4,25) bold
Print ' # of Avg.Hrs.' (3,59) bold
Print 'Engines per Engine Applied%' (4,59) bold
Print ' # of Avg.Hrs.' (3,93) bold
Print 'Engines per Engine Applied%' (4,93) bold
position (+2)
End-Procedure
Begin-Procedure PRINT_DETAIL
if #count = 3
position (-2)
else
if #count = 2
position (-1)
end-if
end-if
let #count = 0
Print #d_count_esn_nbr (,+7,4) edit 9999
Print #d_lbr_hrs (,+4,8) edit 999999.9
Let #d_tot_hrs = #d_lbr_hrs / (#d_lbr_hrs + #r_lbr_hrs + #a_lbr_hrs) * 100
Print #d_tot_hrs (,+3,4) edit 99.9
Print '%' ()
Print #r_count_esn_nbr (,+10,4) edit 9999
Print #r_lbr_hrs (,+4,8) edit 999999.9
Let #r_tot_hrs = #r_lbr_hrs / (#d_lbr_hrs + #r_lbr_hrs + #a_lbr_hrs) * 100
Print #r_tot_hrs (,+3,4) edit 99.9
Print '%' ()
Print #a_count_esn_nbr (,+10,4) edit 9999
Print #a_lbr_hrs (,+4,8) edit 999999.9
Let #a_tot_hrs = #a_lbr_hrs / (#d_lbr_hrs + #r_lbr_hrs + #a_lbr_hrs) * 100
Print #a_tot_hrs (,+3,4) edit 99.9
Print '%' ()
position (+2)
End-Procedure
Begin-Procedure HORZ_LINE
Graphic (#line_no,1,122) horz-line 12
End-Procedure
Begin-Heading 6
Print 'Applied Time Ratio Summary' (1,1) bold
Move 2 to #line_no
do HORZ_LINE
Print 'Summarized Average Applied Time and Applied Percent' (4,1) bold
End-Heading