Skip to Content
0
Former Member
Nov 21, 2008 at 10:53 PM

Alv sort and grping o.k. on screen but not on report

57 Views

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