Displaying Status Icons in Each Row of SALV ABAP
Share

[[{“value”:”

Introduction 

SALV ABAP provides a simple and efficient way to create ALV reports with minimal coding and configuration.
Status icons help visually represent business conditions such as success, warning, and error in reports.
Using icons improves user experience and report readability by reducing dependency on text-based status fields.
SALV supports row-wise icon display using the ICON_D data type, which is widely used in real-time business reporting scenarios.

Scenario

This requirement focuses on visually representing the delivery status of orders in an ALV report using status icons. A green icon indicates full delivery when the delivered quantity matches the ordered quantity, while a yellow icon represents partial delivery. A red icon is displayed for orders with no delivery completed. Using row-wise status symbols improves report readability and helps users make faster business decisions.

Program.

REPORT znp_rp_scn.

TYPES: BEGIN OF ty_so,

so_id TYPE vbeln_va,

customer TYPE kunnr,

order_qty TYPE i,

delivered_qty TYPE i,

status_icon TYPE icon_d,

status_text TYPE char20,

END OF ty_so.

DATA: gt_so TYPE STANDARD TABLE OF ty_so,

gs_so TYPE ty_so.

FORM fill_data.

gs_so-so_id = ‘500001’.

gs_so-customer = ‘C100’.

gs_so-order_qty = 10.

gs_so-delivered_qty = 10.

PERFORM set_status USING gs_so.

APPEND gs_so TO gt_so.

gs_so-so_id = ‘500002’.

gs_so-customer = ‘C200’.

gs_so-order_qty = 10.

gs_so-delivered_qty = 5.

PERFORM set_status USING gs_so.

APPEND gs_so TO gt_so.

gs_so-so_id = ‘500003’.

gs_so-customer = ‘C300’.

gs_so-order_qty = 10.

gs_so-delivered_qty = 0.

PERFORM set_status USING gs_so.

APPEND gs_so TO gt_so.

ENDFORM.

*Step 3: Set Icon Based on Condition

FORM set_status USING ps_so TYPE ty_so.

IF ps_so-delivered_qty = ps_so-order_qty.

ps_so-status_icon = icon_green_light.

ps_so-status_text = ‘Fully Delivered’.

ELSEIF ps_so-delivered_qty > 0.

ps_so-status_icon = icon_yellow_light.

ps_so-status_text = ‘Partially Delivered’.

ELSE.

ps_so-status_icon = icon_red_light.

ps_so-status_text = ‘Not Delivered’.

ENDIF.

gs_so = ps_so.

ENDFORM.

**Standard SAP icons** come from `ICON` include.
*Step 4: OO ALV Display (OALV)

DATA: go_alv TYPE REF TO cl_salv_table.

START-OF-SELECTION.

PERFORM fill_data.

PERFORM display_alv.

* Step 5: ALV Display Logic

FORM display_alv.

cl_salv_table=>factory(

IMPORTING

r_salv_table = go_alv

CHANGING

t_table = gt_so ).

DATA(lo_columns) = go_alv->get_columns( ).

lo_columns->set_optimize( abap_true ).

” Enable Icon display

DATA(lo_column) = lo_columns->get_column( ‘STATUS_ICON’ ).

lo_column->set_short_text( ‘Status’ ).
lo_column->set_medium_text( ‘Delivery Status’ ).
lo_column->set_long_text( ‘Delivery Status Icon’ ).

go_alv->display( ).

ENDFORM.

Output.

Nayanakumar_0-1767616553152.png

Conclusion.

 
Displaying Icons in each SALV row improves report readability and provides a clear visual representation of data status. Using conditional logic, icons can be dynamically assigned based on business rules, helping users quickly understand each record. SALV automatically renders these icons when the correct data types are used.
 
 

“}]] 

  Read More Technology Blog Posts by Members articles 

#abap

By ali

Leave a Reply