Use below steps to disable icons in ABAP ALV toolbar.
- Add a column to the internal table to hold the traffic lights value(i.e. 1 for RED, 2 for YELLOW and 3 for GREEN).
- Fetch data from database table and build field catalog.
- Assign different traffic lights to each row based on condition.
- To display traffic lights in the ALV, fill the lights field name in the LIGHTS_FIELDNAME of ALV layout.
- Pass field catalog to function module ‘REUSE_ALV_GRID_DISPLAY’.
TYPE-POOLS: slis. " SLIS contains all the ALV data types *&---------------------------------------------------------------------* *& Data Types *&---------------------------------------------------------------------* TYPES: BEGIN OF ty_sbook. INCLUDE STRUCTURE sbook. TYPES: icon TYPE c, " Add field to hold traffic light value END OF ty_sbook. *&---------------------------------------------------------------------* *& Data Declaration *&---------------------------------------------------------------------* DATA: it_sbook TYPE TABLE OF ty_sbook. DATA: wa_sbook TYPE ty_sbook. DATA: it_fieldcat TYPE slis_t_fieldcat_alv, wa_fieldcat TYPE slis_fieldcat_alv. DATA: is_layout TYPE slis_layout_alv. DATA: g_repid TYPE sy-repid. *&---------------------------------------------------------------------* *& START-OF-SELECTION *&---------------------------------------------------------------------* START-OF-SELECTION. g_repid = sy-repid. *Fetch data from the database SELECT * UP TO 20 ROWS FROM sbook INTO TABLE it_sbook. *Assign different traffic lights to each row based on condition LOOP AT it_sbook INTO wa_sbook. IF wa_sbook-luggweight LE 0. wa_sbook-icon = 1. " Red Traffic Light ELSEIF wa_sbook-luggweight LE 10. wa_sbook-icon = 2. " Yellow Traffic Light ELSE. wa_sbook-icon = 3. " Green Traffic Light ENDIF. MODIFY it_sbook FROM wa_sbook TRANSPORTING icon. CLEAR: wa_sbook. ENDLOOP. *Build field catalog wa_fieldcat-fieldname = 'CARRID'. " Fieldname in the data table wa_fieldcat-seltext_m = 'Airline'. " Column description in the output APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. wa_fieldcat-fieldname = 'CONNID'. wa_fieldcat-seltext_m = 'Con. No.'. APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. wa_fieldcat-fieldname = 'FLDATE'. wa_fieldcat-seltext_m = 'Date'. APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. wa_fieldcat-fieldname = 'BOOKID'. wa_fieldcat-seltext_m = 'Book. ID'. APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. wa_fieldcat-fieldname = 'FORCURAM'. wa_fieldcat-seltext_m = 'Price'. APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. wa_fieldcat-fieldname = 'FORCURKEY'. wa_fieldcat-seltext_m = 'Currency'. APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. wa_fieldcat-fieldname = 'LUGGWEIGHT'. wa_fieldcat-seltext_m = 'Weight'. APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. wa_fieldcat-fieldname = 'WUNIT'. wa_fieldcat-seltext_m = 'Unit'. APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. *Fill layout info. *Fill traffic lights field name in the ALV layout is_layout-lights_fieldname = 'ICON'. *Pass data and field catalog to ALV function module to display ALV list CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = g_repid is_layout = is_layout it_fieldcat = it_fieldcat TABLES t_outtab = it_sbook EXCEPTIONS program_error = 1 OTHERS = 2.
Output
thanks (:
Thanks a lot for this tutorial, it is easy to understand and very helpful.
screen painters or menu painter , can u explained about it?
Thank you very much . you provided really very good explanation. please provide more topic and complete abap and remind me for same.
helpful!