Skip to Content
0
Oct 18, 2011 at 07:39 AM

cannot get subtotal text in ALV

41 Views

Hi all,

I cannot get the text for my subtotal. Anyone have any idea?

&----


& Report ABC&

&----


*&

*&

&----


REPORT ABC.

  • after getting data*

SORT lt_manpower by gsber landx50 bukrs.

PERFORM set_header.

PERFORM set_fieldcatalog USING alv_fieldcat.

alv_layout-colwidth_optimize = 'X'.

alv_layout-zebra = 'X'.

  • alv_layout-cell_merge = 'X'.

  • alv_layout-get_selinfos = 'X'.

alv_layout-no_totalline = 'X'.

PERFORM data_sort USING alv_sort.

PERFORM data_get_events.

PERFORM data_subtotal_text USING ls_manpower

alv_subtot_text .

PERFORM set_alv.

&----


*& Form data_get_events

&----


  • text

----


FORM data_get_events.

CONSTANTS: lc_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

CONSTANTS: c_formname_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.

DATA ls_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = lt_event

EXCEPTIONS

LIST_TYPE_WRONG = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • Subtotal

READ TABLE lt_event INTO ls_event WITH KEY name = slis_ev_subtotal_text.

IF sy-subrc = 0.

MOVE c_formname_subtotal_text to ls_event-form.

MODIFY lt_event FROM ls_event INDEX sy-tabix.

ENDIF.

ENDFORM. "data_get_events

&----


*& Form data_subtotal_text

&----


  • text

----


  • -->VALUE(LT_MANPOWER) text

  • -->LS_SUBTOT_TEXT text

----


FORM data_subtotal_text USING lt_total TYPE ty_manpower_struct

ls_subtot_text TYPE slis_subtot_text.

  • Division total

IF ls_subtot_text-criteria = 'GSBER'.

ls_subtot_text-display_text_for_subtotal = 'Division total'.

ENDIF.

  • Country total

IF ls_subtot_text-criteria = 'LANDX50'.

ls_subtot_text-display_text_for_subtotal = 'Country total'.

ENDIF.

  • Company Code total

IF ls_subtot_text-criteria = 'BUKRS'.

ls_subtot_text-display_text_for_subtotal = 'Company Code total'.

ENDIF.

  • ls_subtot_text-display_text_for_subtotal = 'Sub total text'.

ENDFORM. "data_subtotal_text

&----


*& Form set_alv

&----


  • text

----


FORM set_alv.

DATA lv_repid TYPE syrepid.

lv_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = lv_repid

i_callback_top_of_page = 'ALV_TOP_OF_PAGE'

is_layout = alv_layout

it_fieldcat = alv_fieldcat

it_sort = alv_sort

it_events = lt_event

  • i_default = 'X'

  • i_save = 'A'

TABLES

t_outtab = lt_manpower

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. "set_alv

&----


*& Form alv_top_of_page

&----


  • text

----


FORM alv_top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = alv_top_of_page.

ENDFORM. "alv_top_of_page

Edited by: Siong Chao on Oct 18, 2011 9:39 AM

Edited by: Siong Chao on Oct 18, 2011 9:40 AM