Skip to Content
0
Feb 03, 2010 at 01:44 PM

HELP ON ALV

21 Views

I HAVE A MODULE POOL PROGRAM WRITTEN. WHERE IN I TAKE DOCUMENT NUMBER AND PERCENTAGE AS USER INPUTS,

AND DISPLAY AN ALV GRID IN A TAB STRIP CONTROL. I use object oriented way for displaying data in the

alv. when i display data, i have a column called percentage, and i need the total of this column in the

alv. I set the wa_fcat-do_sum = 'x' in the field catalog, but then the total does not get displayed in the alv grid.

The standard tool bar of alv grid has the sum button disabled, can't figure out why this is happening. Kindly help me on the

same with some useful inputs.given below is the code to display the field catalog and my alv grid display module.

MODULE build_fieldcatalog INPUT.

w_fcat-fieldname = 'EBELP'.

w_fcat-coltext = 'PO Item'.

w_fcat-col_pos = 1.

w_fcat-ref_table = 'IT_DISP'.

APPEND w_fcat TO t_fcat.

CLEAR w_fcat.

w_fcat-fieldname = 'MATNR'.

w_fcat-coltext = 'Material Number'.

w_fcat-col_pos = 2.

w_fcat-ref_table = 'IT_DISP'.

APPEND w_fcat TO t_fcat.

CLEAR w_fcat.

w_fcat-fieldname = 'MENGE'.

w_fcat-coltext = 'Quantity'.

w_fcat-col_pos = 3.

w_fcat-ref_table = 'IT_DISP'.

APPEND w_fcat TO t_fcat.

CLEAR w_fcat.

w_fcat-fieldname = 'NETPR'.

w_fcat-coltext = 'RATE'.

w_fcat-col_pos = 4.

w_fcat-ref_table = 'IT_DISP'.

APPEND w_fcat TO t_fcat.

CLEAR w_fcat.

w_fcat-fieldname = 'AMOUNT'.

w_fcat-coltext = 'Amount'.

w_fcat-col_pos = 5.

w_fcat-ref_table = 'IT_DISP'.

APPEND w_fcat TO t_fcat.

CLEAR w_fcat.

w_fcat-fieldname = 'PER_AMT'.

w_fcat-coltext = 'Percentage Amount'.

w_fcat-col_pos = 6.

w_fcat-ref_table = 'IT_DISP'.

w_fcat-DO_SUM = 'X'.

APPEND w_fcat TO t_fcat.

CLEAR w_fcat.

CREATE OBJECT t_cust

EXPORTING

  • parent =

container_name = 'CONT'

  • style =

  • lifetime = lifetime_default

  • repid =

  • dynnr =

  • no_autodef_progid_dynnr =

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6

.

IF sy-subrc <> 0.

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

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

ENDIF.

CREATE OBJECT t_grid

EXPORTING

  • i_shellstyle = 0

  • i_lifetime =

i_parent = t_cust

  • i_appl_events = space

  • i_parentdbg =

  • i_applogparent =

  • i_graphicsparent =

  • i_name =

  • i_fcat_complete = space

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

others = 5

.

IF sy-subrc <> 0.

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

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

ENDIF.

ENDMODULE. " build_fieldcatalog INPUT

MODULE alv_display INPUT.

w_lay-zebra = 'X'.

w_variant = sy-repid.

CALL METHOD t_grid->set_table_for_first_display

EXPORTING

  • i_buffer_active =

  • i_bypassing_buffer =

  • i_consistency_check =

  • i_structure_name = ' '

is_variant = w_variant

  • i_save =

i_default = 'X'

is_layout = w_lay

  • is_print =

  • it_special_groups =

  • it_toolbar_excluding =

  • it_hyperlink =

  • it_alv_graphics =

  • it_except_qinfo =

  • ir_salv_adapter =

CHANGING

it_outtab = it_disp

it_fieldcatalog = t_fcat

  • it_sort =

  • it_filter =

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.

ENDMODULE. " alv_display INPUT