2009 Jan 29 10:22 PM
Hi experts,
I have a column icon in my alv oo and when i change the iconname, the alv doesnt refresh to the new icon!
Com you help me???
Tks in advance
2009 Jan 30 3:32 AM
Hi,
Data : grid2 type ref to cl_gui_alv_grid,
call method grid2->refresh_table_display.
Check the demo program BCALV_GRID_02
2009 Jan 30 3:32 AM
Hi,
Data : grid2 type ref to cl_gui_alv_grid,
call method grid2->refresh_table_display.
Check the demo program BCALV_GRID_02
2009 Jan 30 3:34 AM
Hi,
For refreshing the ALV grid using OO use code:-
*&---------------------------------------------------------------------*
* TABLES
*&---------------------------------------------------------------------*
TABLES : ekpo.
*&---------------------------------------------------------------------*
* PARAMETERS DECLARATION
*&---------------------------------------------------------------------*
PARAMETERS : z_ebeln TYPE ekpo-ebeln.
*&---------------------------------------------------------------------*
* TYPE DECLARATION
*&---------------------------------------------------------------------*
TYPES : BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
menge TYPE ekpo-menge,
END OF t_ekpo.
*&---------------------------------------------------------------------*
* DATA DECLARATION
*&---------------------------------------------------------------------*
DATA : rep_name TYPE sy-repid,
check(1),
rep(25),
ok_code TYPE sy-ucomm.
*INTERNAL TABLE
DATA : it_ekpo TYPE STANDARD TABLE OF t_ekpo.
*NAME OF CUSTOM CONTAINER ADDED ON SCREEN
DATA : z_container TYPE scrfname VALUE 'PO_CONTAINER'. "name of container on screen
DATA : z_custom_container TYPE REF TO cl_gui_custom_container.
*ALV GRID CONTAINER
DATA : z_grid TYPE REF TO cl_gui_alv_grid.
*FIELD CATALOG
DATA : it_fieldcat TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.
*LAYOUT
DATA : wa_layout TYPE lvc_s_layo.
*&---------------------------------------------------------------------*
* INITIALIZATION
*&---------------------------------------------------------------------*
INITIALIZATION.
rep_name = sy-repid.
check = 'X'.
CONCATENATE text-001 rep_name INTO rep SEPARATED BY space.
*----------------------------------------------------------------------*
* CLASS lcl_oo_alv DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_oo_alv DEFINITION.
PUBLIC SECTION.
METHODS populate_itab IMPORTING ebeln TYPE zekpo-ebeln.
METHODS create_field_catalog.
METHODS create_layout.
METHODS display_alv.
METHODS refresh_alv.
PRIVATE SECTION.
DATA : po TYPE ekpo-ebeln.
ENDCLASS. "lcl_oo_alv DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_oo_alv IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_oo_alv IMPLEMENTATION.
METHOD populate_itab.
me->po = ebeln.
SELECT ebeln
ebelp
matnr
werks
menge
FROM ekpo
INTO TABLE it_ekpo
WHERE ebeln EQ po.
ENDMETHOD. "populate_itab
METHOD create_field_catalog.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-coltext = 'PO #'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-coltext = 'Item'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-coltext = 'Material'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-coltext = 'Plant'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-coltext = 'Qty.'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDMETHOD. "create_field_catalog
METHOD create_layout.
wa_layout-grid_title = rep.
wa_layout-zebra = check.
ENDMETHOD. "create_layout
METHOD display_alv.
CALL METHOD z_grid->set_table_for_first_display
EXPORTING
* i_buffer_active =
* i_bypassing_buffer =
* i_consistency_check =
* i_structure_name =
* is_variant =
* i_save =
* i_default = 'X'
is_layout = wa_layout
* is_print =
* it_special_groups =
* it_toolbar_excluding =
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
CHANGING
it_outtab = it_ekpo
it_fieldcatalog = it_fieldcat
* 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.
ENDMETHOD. "display_alv
METHOD refresh_alv.
REFRESH it_ekpo.
SELECT ebeln
ebelp
matnr
werks
menge
FROM ekpo
INTO TABLE it_ekpo.
CALL METHOD z_grid->refresh_table_display
* EXPORTING
* is_stable =
* i_soft_refresh =
* EXCEPTIONS
* finished = 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.
ENDMETHOD. "refresh_alv
ENDCLASS. "lcl_oo_alv IMPLEMENTATION
*&---------------------------------------------------------------------*
* CLASS INSTANCE VARIABLE
*&---------------------------------------------------------------------*
DATA : obj1 TYPE REF TO lcl_oo_alv.
*&---------------------------------------------------------------------*
* START OF SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
*CREATE OBJECT
CREATE OBJECT : obj1.
CALL METHOD obj1->populate_itab
EXPORTING
ebeln = z_ebeln.
*&---------------------------------------------------------------------*
* CALL SCREEN
*&---------------------------------------------------------------------*
CALL SCREEN 1011.
*&---------------------------------------------------------------------*
*& Module STATUS_1010 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_1011 OUTPUT.
SET PF-STATUS '1011'.
* SET TITLEBAR 'xxx'.
*CUSTOM CONTAINER INSTANCE
CREATE OBJECT z_custom_container
EXPORTING
* parent =
container_name = z_container
* 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.
*ALV GRID INSTANCE
CREATE OBJECT z_grid
EXPORTING
* i_shellstyle = 0
* i_lifetime =
i_parent = z_custom_container
* 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.
CALL METHOD obj1->create_field_catalog.
CALL METHOD obj1->create_layout.
CALL METHOD obj1->display_alv.
ENDMODULE. " STATUS_1010 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_1010 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_1011 INPUT.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'REFRESH'.
CALL METHOD obj1->refresh_alv.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_1010 INPUT
Hope this solves your problem.
Thanks & Regards,
Tarun Gambhir