2008 Nov 21 10:53 PM
My ALV Grid is working fine on the screen and it is sorting/grouping everything as expected. The grouped field data (employee, Cur, Award) are only appearing once on the screen when they are the same values.
Employee Cur Award Award Name Unit Value
Joe CAD U001 xxx 1.0
111 2.0
22x 3.0
3xx 4.0
44x 5.0
The problem is that when I print, all these grouped values keep repeating (joe, cur and award is all the same so it should not repeat just like it is on the screen).
Employee Cur Award Award Name Unit Value
Joe CAD U001 xxx 1.0
Joe CAD U001 111 2.0
Joe CAD U001 22x 3.0
Joe CAD U001 3xx 4.0
Joe CAD U001 44x 5.0
Here is my code. Any suggestions would be most appreciated.
*----
-
-
-
-
-
*
form define_field_catalog.
perform append_field_catalog using:
Specify columns for the list display
Field Ref Tab Rep Text Len Grp Sum Col
'EMPNAME' ' ' text-002 '30' ' ' ' ' '1', " Emp Name
'WAERS' ' ' text-003 '04' ' ' ' ' '2', " Cur
'AWARD' ' ' text-004 '04' ' ' ' ' '3', " Award
'AWARDNAME' ' ' text-011 '10' ' ' ' ' '4', " Award Name
'UNITVALUE' ' ' text-005 '11' ' ' ' ' '5', " Unit Value
'NOOFUNITS' ' ' text-006 '11' ' ' 'X' '6', " No. Of Units
'BOOKVALUE' ' ' text-007 '11' ' ' 'X' '7', " Book Value
'MARKETPRICE' ' ' text-008 '11' ' ' ' ' '8', " Market Price
'MARKETVAL' ' ' text-009 '11' ' ' 'X' '9'. " Market Value
endform. "define_field_catalog
*----
-
-
-
-
-
*
FORM append_field_catalog
using fieldname " field name
ref_table " ddic table reference
reptext " text name
outputlen " output length
dogrp " do grp?
dosum " do sum?
col. " column
clear wa_fcat.
wa_fcat-fieldname = fieldname.
wa_fcat-col_pos = col.
wa_fcat-ref_table = ref_table.
wa_fcat-reptext = reptext.
wa_fcat-outputlen = outputlen.
wa_fcat-sp_group = dogrp.
wa_fcat-do_sum = dosum.
append wa_fcat to it_fcat.
ENDFORM. "append_field_catalog
*----
-
-
-
-
-
*
FORM define_sort.
wa_sort-spos = '01'.
wa_sort-fieldname = 'EMPNAME'. "Emp Name
wa_sort-up = 'X'.
wa_sort-group = '*'.
wa_sort-obligatory = 'UL'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort.
wa_sort-spos = '02'.
wa_sort-fieldname = 'WAERS'. "Currency
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort.
wa_sort-spos = '03'.
wa_sort-fieldname = 'AWARD'. "Award
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort.
ENDFORM. "define sort
*----
-
-
-
-
-
*
*Define Fields for Alv and sort/group them
PERFORM define_field_catalog.
PERFORM define_sort.
*Define Object and Method
IF ref_container is initial.
Create Object ref_container
exporting
extension = 2000
exceptions
others = 1.
IF SY-SUBRC <> 0.
MESSAGE a001(zqm). "Invalid Object.
ENDIF.
CREATE OBJECT REF_ALV
EXPORTING
I_PARENT = ref_container
I_APPL_EVENTS = space
EXCEPTIONS
others = 1.
IF SY-SUBRC <> 0.
MESSAGE a001(zqm). "Invalid Object.
ENDIF.
CALL METHOD REF_ALV->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'IT_ALVTAB'
IS_LAYOUT = wa_layout
CHANGING
IT_OUTTAB = it_alvtab
IT_FIELDCATALOG = it_fcat
IT_SORT = i_sort
EXCEPTIONS
others = 1.
IF SY-SUBRC <> 0.
MESSAGE a002(zqm). "Invalid Method.
ENDIF.
ENDIF.
ENDMODULE. " PBO_ALV_100 OUTPUT
2008 Nov 22 10:28 AM
BEFORE PRINTING U DELETE DUPLICATE RECORD.
FOR EXAMPLE:-
loop at <ITAB>
.
DELETE ADJACENT DUPLICATES FROM <ITAB>.
endloop.
2008 Nov 22 4:30 PM
thx for the response, but these are not duplicate records so I don't want to delete them. The problem is that the Employee, Cur and Award may frequently be the same value but award name and unit value will be different. In my ALV on the screen it only shows the emp, cur and award once as per my example above but when I go to print this alv it repeats the values as per my example above.
2008 Nov 23 11:49 AM
Maybe it's not good to do so. Just for your information.
When printing, you can modify the internal table record. You can remove the value of fields joe, cur and
award if the two records are same with those fields.
2008 Nov 23 5:34 PM
thx for your response. I think i have decided that this report should not be an ALV so I will do it with old fashioned write statements. thx though