Skip to Content
0
Former Member
Aug 23, 2006 at 04:12 PM

How to accumlate and use sort in ALV

45 Views

Hi

I am using collect statement for accumalation.

but it is not working.

the code is like this:

IF NOT p_otrstk IS INITIAL.

CLEAR it_zresult_tab1.

LOOP AT it_mard_tab INTO wa_mard_tab.

l_tabix = sy-tabix.

READ TABLE it_zresult_tab1 INTO wa_zresult_tab1

WITH KEY lgort = s_lgort1

lgort = s_lgort2

werks = s_werks

matnr = s_matnr.

IF sy-subrc EQ 0.

wa_zresult_tab1-speme = wa_mard_tab-speme.

wa_zresult_tab1-umlme = wa_mard_tab-umlme.

wa_zresult_tab1-insme = wa_mard_tab-insme.

wa_zresult_tab1-retme = wa_mard_tab-retme.

COLLECT wa_zresult_tab1 INTO it_zresult_tab1.

ENDIF.

ENDLOOP.

ENDIF.

do i need to use modify? but it is with modify it is giving dump.

and how to do subtotals in ALV grid?

the code is like this:

IF grid1 IS INITIAL .

  • Instantiate the grid container.

CREATE OBJECT g_custom_container

EXPORTING container_name = 'CCCONTAINER'.

*Instantiate the grid itself within the container.

CREATE OBJECT grid1

EXPORTING

i_parent = g_custom_container.

  • i_appl_events = 'X'.

  • Call method of grid1 class object to build/display the grid.

CALL METHOD grid1->set_table_for_first_display

EXPORTING

i_structure_name = 'ZRESULT_TAB'

is_variant = variant

  • i_save = 'U'

is_layout = gs_layout

CHANGING

it_outtab = it_zresult_tab

it_fieldcatalog = gt_fcat

IT_SORT = VT_SORT

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

and in the fieldcatalog

IF p_some = 'X'.

CLEAR: ls_sort.

  • t_fcat-no_out = 'X'.

ls_sort-fieldname = 'MATNR'.

ls_sort-subtot = 'X'.

APPEND ls_sort TO vt_sort.

but this is also not working.

Please help me.....

Thanks

Alekhya