2016 May 02 1:09 PM
Hello all,
I created a screen (not sub-screen) in my program that get's it's data from another screen row
and show a resultset in Salv table, one of the columns contain float number (weight of carton ...)
When the user do total sum on this column he gets the result, but when he is closing this window
and open it for another set of data, the result of total sum remains the same althow it's not true (not
belong to the new dataset).
The code that I made for showing the data in the Salv :
In TOP include :
DATA: gc_prod_list TYPE scrfname VALUE 'PROD_CNTRL_LOG', "#EC NEEDED
gr_prod_list TYPE REF TO cl_salv_table, "#EC NEEDED
gr_prod_list_functions TYPE REF TO cl_salv_functions, "#EC NEEDED
gr_prod_list_display TYPE REF TO cl_salv_display_settings, "#EC NEEDED
gr_prod_list_layout TYPE REF TO cl_salv_layout, "#EC NEEDED
g_cont_prod_list TYPE REF TO cl_gui_custom_container, "#EC NEEDED
gr_prod_list_selections TYPE REF TO cl_salv_selections,
gr_prod_list_columns TYPE REF TO cl_salv_columns_table,
gr_prod_list_column TYPE REF TO cl_salv_column_table,
gt_prod_list_rows TYPE salv_t_row, "#EC NEEDED
gv_prod_list_flag type flag,
GV_prod_LIST_TITLE type string.
In Salv include :
FORM show_hu_prod CHANGING lv_show_prod_list TYPE flag.
DATA: lv_key TYPE salv_s_layout_key.
IF gt_prod_hu IS INITIAL.
MESSAGE i334(zwm). " No stock pallets to show
CLEAR lv_show_prod_list.
RETURN.
ENDIF.
IF lv_show_prod_list = 'X'.
gr_prod_list->refresh( ).
RETURN.
ENDIF.
lv_show_prod_list = 'X'.
IF cl_salv_table=>is_offline( ) EQ if_salv_c_bool_sap=>false.
CREATE OBJECT g_cont_prod_list
EXPORTING
container_name = 'PROD_CNTRL_LOG'.
ENDIF.
TRY.
cl_salv_table=>factory(
EXPORTING
r_container = g_cont_prod_list
container_name = 'PROD_CNTRL_LOG'
IMPORTING
r_salv_table = gr_prod_list
CHANGING
t_table = gt_prod_hu ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
gr_prod_list_functions = gr_prod_list->get_functions( ).
gr_prod_list_functions->set_all( abap_true ).
gr_prod_list_display = gr_prod_list->get_display_settings( ).
gr_prod_list_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_prod_list_layout = gr_prod_list->get_layout( ).
lv_key-report = sy-repid.
gr_prod_list_layout->set_key( lv_key ).
gr_prod_list_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
*... set the columns technical
DATA: lr_columns TYPE REF TO cl_salv_columns_table.
lr_columns = gr_prod_list->get_columns( ).
lr_columns->set_optimize( 'X' ).
PERFORM set_prod_hu_columns USING gr_prod_list.
gr_prod_list_selections = gr_prod_list->get_selections( ).
gr_prod_list_selections->set_selection_mode( if_salv_c_selection_mode=>single ).
SORT gt_prod_hu BY exidv.
IF gv_prod_list_flag IS INITIAL.
gr_prod_list->display( ).
gv_prod_list_flag = 'X'.
ELSE.
gr_prod_list->refresh( ).
ENDIF.
ENDFORM. " SHOW_HU_PROD
*&---------------------------------------------------------------------*
*& Form SET_HU_COLUMNS
*&---------------------------------------------------------------------*
FORM set_prod_hu_columns USING p_gr_table TYPE REF TO cl_salv_table.
DATA: lr_oref TYPE REF TO cx_root,
lv_text TYPE string. "#EC NEEDED
TRY .
gr_prod_list_columns = p_gr_table->get_columns( ).
CATCH cx_salv_not_found INTO lr_oref.
lv_text = lr_oref->get_text( ).
ENDTRY.
TRY.
gr_prod_list_column ?= gr_prod_list_columns->get_column( 'EXIDV' ).
CATCH cx_salv_not_found INTO lr_oref.
lv_text = lr_oref->get_text( ).
ENDTRY.
gr_prod_list_column->set_short_text( text-028 ).
gr_prod_list_column->set_medium_text( text-029 ).
gr_prod_list_column->set_long_text( text-029 ).
gr_prod_list_column->set_key( 'X' ).
TRY.
gr_prod_list_column ?= gr_prod_list_columns->get_column( 'MATNR' ).
CATCH cx_salv_not_found INTO lr_oref.
lv_text = lr_oref->get_text( ).
ENDTRY.
gr_prod_list_column->set_short_text( text-001 ).
gr_prod_list_column->set_medium_text( text-002 ).
gr_prod_list_column->set_long_text( text-002 ).
gr_prod_list_column->set_key( 'X' ).
TRY.
gr_prod_list_column ?= gr_prod_list_columns->get_column( 'MAKTX' ).
CATCH cx_salv_not_found INTO lr_oref.
lv_text = lr_oref->get_text( ).
ENDTRY.
gr_prod_list_column->set_short_text( text-003 ).
gr_prod_list_column->set_medium_text( text-004 ).
gr_prod_list_column->set_long_text( text-004 ).
TRY.
gr_prod_list_column ?= gr_prod_list_columns->get_column( 'ALTME' ).
CATCH cx_salv_not_found INTO lr_oref.
lv_text = lr_oref->get_text( ).
ENDTRY.
gr_prod_list_column->set_short_text( text-054 ).
gr_prod_list_column->set_medium_text( text-055 ).
gr_prod_list_column->set_long_text( text-055 ).
TRY.
gr_prod_list_column ?= gr_prod_list_columns->get_column( 'LGORT' ).
CATCH cx_salv_not_found INTO lr_oref.
lv_text = lr_oref->get_text( ).
ENDTRY.
gr_prod_list_column->set_short_text( text-006 ).
gr_prod_list_column->set_medium_text( text-007 ).
gr_prod_list_column->set_long_text( text-007 ).
TRY.
gr_prod_list_column ?= gr_prod_list_columns->get_column( 'HSDAT' ).
CATCH cx_salv_not_found INTO lr_oref.
lv_text = lr_oref->get_text( ).
ENDTRY.
gr_prod_list_column->set_short_text( text-008 ).
gr_prod_list_column->set_medium_text( text-009 ).
gr_prod_list_column->set_long_text( text-009 ).
TRY.
gr_prod_list_column ?= gr_prod_list_columns->get_column( 'VFDAT' ).
CATCH cx_salv_not_found INTO lr_oref.
lv_text = lr_oref->get_text( ).
ENDTRY.
gr_prod_list_column->set_short_text( text-030 ).
gr_prod_list_column->set_medium_text( text-031 ).
gr_prod_list_column->set_long_text( text-031 ).
TRY.
gr_prod_list_column ?= gr_prod_list_columns->get_column( 'VEMNG' ).
CATCH cx_salv_not_found INTO lr_oref.
lv_text = lr_oref->get_text( ).
ENDTRY.
gr_prod_list_column->set_short_text( text-032 ).
gr_prod_list_column->set_medium_text( text-033 ).
gr_prod_list_column->set_long_text( text-033 ).
TRY.
gr_prod_list_column ?= gr_prod_list_columns->get_column( 'LGTYP' ).
CATCH cx_salv_not_found INTO lr_oref.
lv_text = lr_oref->get_text( ).
ENDTRY.
gr_prod_list_column->set_visible( '' ).
TRY.
gr_prod_list_column ?= gr_prod_list_columns->get_column( 'LGPLA' ).
CATCH cx_salv_not_found INTO lr_oref.
lv_text = lr_oref->get_text( ).
ENDTRY.
gr_prod_list_column->set_visible( '' ).
ENDFORM. " SET_ERR_COLUMNS
Thank you,
Regards,
Amit Berku
2016 May 02 8:40 PM
By default the refresh mode is "soft", which is intended for a change in the layout, but not in the change of the internal table, i.e. the totals are not recalculated (soft mode in ALV grid (sorry couldn't find the equivalent chapter for SALV)). Instead, do ->refresh( refresh_mode = IF_SALV_C_REFRESH=>full ).
2016 May 02 8:40 PM
By default the refresh mode is "soft", which is intended for a change in the layout, but not in the change of the internal table, i.e. the totals are not recalculated (soft mode in ALV grid (sorry couldn't find the equivalent chapter for SALV)). Instead, do ->refresh( refresh_mode = IF_SALV_C_REFRESH=>full ).
2016 May 03 9:14 AM
Hi Sandra,
You won't believe how much you helped me !!!! Thank you very very much !!!
I used your suggestion with full refresh and added a remove aggregation method that
both fixes done the work.
The fixed code is :
DATA: lv_key TYPE salv_s_layout_key,
lo_aggrs TYPE REF TO cl_salv_aggregations.
DATA: lr_columns TYPE REF TO cl_salv_columns_table.
IF gt_hu IS INITIAL.
MESSAGE i334(zwm). " No pallets to show
CLEAR lv_show_list.
RETURN.
ENDIF.
IF p_show_list = 'X'.
gr_list->refresh( refresh_mode = if_salv_c_refresh=>full ).
lo_aggrs = gr_list->get_aggregations( ).
lo_aggrs->clear( ).
lo_aggrs->remove_aggregation( 'VEMNG' ).
RETURN.
ENDIF.
p_show_list = 'X'.
IF cl_salv_table=>is_offline( ) EQ if_salv_c_bool_sap=>false.
CREATE OBJECT g_cont_list
EXPORTING
container_name = 'CNTRL'.
ENDIF.
TRY.
cl_salv_table=>factory(
EXPORTING
r_container = g_cont_list
container_name = 'CNTRL'
IMPORTING
r_salv_table = gr_list
CHANGING
t_table = gt_hu ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
CLEAR gr_list_display.
gr_list_functions = gr_list->get_functions( ).
gr_list_functions->set_all( abap_true ).
gr_list_display = gr_list->get_display_settings( ).
gr_list_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_list_layout = gr_list->get_layout( ).
lv_key-report = sy-repid.
gr_list_layout->set_key( lv_key ).
gr_list_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
lr_columns = gr_list->get_columns( ).
lr_columns->set_optimize( 'X' ).
PERFORM set_hu_columns USING gr_list.
gr_list_selections = gr_list->get_selections( ).
gr_list_selections->set_selection_mode( if_salv_c_selection_mode=>single ).
SORT gt_hu BY exidv.
IF gv_list_flag IS INITIAL.
gr_list->display( ).
gr_list->refresh( refresh_mode = if_salv_c_refresh=>full ).
lo_aggrs = gr_list->get_aggregations( ).
lo_aggrs->clear( ).
lo_aggrs->remove_aggregation( 'VEMNG' ).
gv_list_flag = 'X'.
ELSE.
gr_list->refresh( refresh_mode = if_salv_c_refresh=>full ).
lo_aggrs = gr_list->get_aggregations( ).
lo_aggrs->clear( ).
lo_aggrs->remove_aggregation( 'VEMNG' ).
ENDIF.
I know that there is some code that is not realy neccessery but it's works.
Regards,
Amit Berku
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |