SALV Report with Checkbox Selection and Designation Based Toolbar Buttons in SAP ABAP

Estimated read time 19 min read

Introduction 

In many SAP reporting scenarios, there is a need to control available user actions dynamically, rather than defining all functions statically upfront. Instead of displaying a fixed set of toolbar buttons in an SALV report, we can adjust them at runtime based on various conditions — such as user designation (e.g., a Manager may need buttons like “Approve” and “Reject”, while a Sales Executive may only need a “Detail View” button), record status (e.g., if a sales order is already approved, the “Approve” button should be hidden or disabled ), or business logic(eg.,showing a “Reschedule” button only if the delivery date is today). 

This blog demonstrates how to: 

Display sales order data in a SALV report, Add checkbox selection for line-level actions, Implement custom toolbar buttons (Approve, Reject, Detail View ), Dynamically control toolbar buttons using Designation (via radio buttons). 

Business Requirement 

We are writing an SALV report that displays Sales Order details. Depending on the designation selected by the user, the SALV should display different function buttons: 

Designation 

Visible Buttons 

Manager 

Approve, Reject 

Sales Executive 

Detail View 

Additionally, users can select specific records using checkboxes, and based on button clicks, perform actions like updating statuses and navigating to VA03 (Display Sales Order). 

Step-by-Step Implementation  

Define Data Structures 

Define a custom structure for sales order data with an additional CHECK field for checkbox selection:  
Define Internal tables and Variables 

 

*– Define a structure for Sales Order data
TYPES : BEGIN OF ty_sales,
vbeln TYPE vbeln_va, “sales document
erdat TYPE erdat, “Created On
vkorg TYPE vkorg, “Sales Organization
kunnr TYPE kunnr, “customer
netwr TYPE netwr_ak, “Net value
status TYPE zch_de_status, “custom field Status
check TYPE char1, “For Checkbox selection
END OF ty_sales.

*– Declare required internal tables and variables
DATA : lv_vbeln TYPE vbak-vbeln,
lt_vbak TYPE TABLE OF ty_sales,
lo_salv TYPE REF TO cl_salv_table,
lo_toolbar TYPE REF TO cl_salv_functions_list,
lo_events TYPE REF TO cl_salv_events_table,
lo_columns TYPE REF TO cl_salv_columns,
lo_column TYPE REF TO cl_salv_column_list,
lo_column1 TYPE REF TO cl_salv_column.

Create Designation-Based Selection Screen 

Here, p_r1 = Manager and p_r2 = Sales Executive. 

*– Selection screen with sales document and designation selection
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME .
SELECT-OPTIONS : s_vbeln FOR lv_vbeln.
PARAMETERS : p_r1 TYPE c RADIOBUTTON GROUP r1,
p_r2 TYPE c RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK b1.

Fetch Sales Order Data Display using SALV Factory method 
The SALV object is created using the factory method and filled with data from the custom table zch_dt_vbak 

START-OF-SELECTION.
IF lt_vbak IS INITIAL.
SELECT FROM zch_dt_vbak FIELDS vbeln,
erdat,
vkorg,
kunnr,
netwr,
status
WHERE vbeln IN @s_vbeln
INTO TABLE _vbak.
ENDIF.

DATA: lx_msg TYPE REF TO cx_salv_msg.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = lo_alv
CHANGING
t_table = lt_vbak
).
CATCH cx_salv_msg. ” ALV: General Error Class with Message
ENDTRY.

Add Checkbox for selecting the rows 

To get the selectable (editable) checkbox, we need to get the specific column from the column object.  After this, we need to set the cell type as IF_SALV_C_CELL_TYPE=>CHECKBOX_HOTSPOT by using the method SET_CELL_TYPE.  To update the values in the checkbox, we need to handle the event LINK_CLICK.  This event LINK_CLICK is triggered when we click on the hotspot enabled checkbox.  In the event handler method, we need to change the value of the checkbox field and call the REFRESH method to refresh the value on the ALV. lo_salv->get_columns( RECEIVING value = lo_columns ).
lo_columns->set_optimize(‘X’).
TRY.
lo_column ?= lo_columns->get_column( ‘CHECK’ ).
lo_column->set_cell_type( if_salv_c_cell_type=>checkbox_hotspot ).
lo_column->set_output_length( 10 ).
CATCH cx_salv_not_found.
ENDTRY.

Set Column Position and Header (Optional) 

For better UI, position the checkbox as the first column by using SET_COLUMN_POSITION and rename the field by using SET_LONG_TEXT. 

lo_columns->set_column_position( columnname = ‘CHECK’ position = 1 ).
TRY.
CALL METHOD lo_columns->get_column
EXPORTING
columnname = ‘CHECK’
RECEIVING
value = lo_column1.
lo_column1->set_long_text( value = ‘Select’ ).
CATCH cx_salv_not_found.
ENDTRY.

Event Handler methods for handling toolbar and checkbox 

CLASS lcl_event DEFINITION.
PUBLIC SECTION.
METHODS handler FOR EVENT added_function OF cl_salv_events_table.
METHODS handle_click FOR EVENT link_click OF cl_salv_events_table IMPORTING row.
ENDCLASS.

Implementation for handle_click method 

METHOD handle_click.
READ TABLE lt_vbak ASSIGNING FIELD-SYMBOL(<ls_vbak>) INDEX row.
IF <ls_vbak>-check IS INITIAL.
<ls_vbak>-check = ‘X’.
ELSE.
CLEAR <ls_vbak>-check.
ENDIF.
lo_salv->refresh( ).
ENDMETHOD.

In SALV, we can add custom toolbar buttons using the SET_SCREEN_STATUS method and maintain the function codes and buttons using transaction SE41. 

IF p_r1 = ‘X’.
CALL METHOD lo_salv->set_screen_status
EXPORTING
report = sy-repid
pfstatus = ‘TOOLBAR’.
ELSE.
CALL METHOD lo_salv->set_screen_status
EXPORTING
report = sy-repid
pfstatus = ‘TOOLBAR2’.
ENDIF.

 

Handle User Actions Based on Selected Checkbox and Button  

METHOD handler.
DATA : lv_count TYPE i,
r_ucomm TYPE sy-ucomm.

LOOP AT lt_vbak ASSIGNING FIELD-SYMBOL(<fs_vbak>) WHERE check = ‘X’ .
CASE sy-ucomm.
WHEN ‘APPROVE’.
<fs_vbak>-status = ‘Approved’.
WHEN ‘REJECT’.
<fs_vbak>-status = ‘Rejected’.
WHEN ‘DET_VIEW’.
SET PARAMETER ID ‘AUN’ FIELD <fs_vbak>-vbeln.
CALL TRANSACTION ‘VA03’ AND SKIP FIRST SCREEN.
ENDCASE.
lv_count += 1.
ENDLOOP.
r_ucomm = sy-ucomm.
IF r_ucomm = ‘&SAVE’.
MODIFY zch_dt_vbak FROM TABLE lt_vbak.
IF sy-subrc = 0.
MESSAGE ‘Changes saved successfully.’ TYPE ‘S’.
ELSE.
MESSAGE ‘Error while saving changes to the database.’ TYPE ‘E’.
ENDIF.
ELSEIF lv_count = 0 AND p_r1 = ‘X’.
MESSAGE ‘Please select at least one Sales Order.’ TYPE ‘I’.
ENDIF.
lo_salv->refresh( ).

Full Implementation Code 

REPORT zch_rp_salv_report.
*– Define a structure for Sales Order data
TYPES : BEGIN OF ty_sales,
vbeln TYPE vbeln_va, “sales document
erdat TYPE erdat, “Created On
vkorg TYPE vkorg, “Sales Organization
kunnr TYPE kunnr, “customer
netwr TYPE netwr_ak, “Net value
status TYPE zch_de_status, “custom field Status
check TYPE char1, “For Checkbox selection
END OF ty_sales.

*– Declare required internal tables and variables
DATA : lv_vbeln TYPE vbak-vbeln,
lt_vbak TYPE TABLE OF ty_sales,
lo_salv TYPE REF TO cl_salv_table,
lo_toolbar TYPE REF TO cl_salv_functions_list,
lo_events TYPE REF TO cl_salv_events_table,
lo_columns TYPE REF TO cl_salv_columns,
lo_column TYPE REF TO cl_salv_column_list,
lo_column1 TYPE REF TO cl_salv_column.

*– Selection screen with sales document and role selection
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME .
SELECT-OPTIONS : s_vbeln FOR lv_vbeln.
PARAMETERS : p_r1 TYPE c RADIOBUTTON GROUP r1,
p_r2 TYPE c RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK b1.

CLASS lcl_event DEFINITION.
PUBLIC SECTION.
METHODS handler FOR EVENT added_function OF cl_salv_events_table.
METHODS handle_click FOR EVENT link_click OF cl_salv_events_table IMPORTING row.
ENDCLASS.
CLASS lcl_event IMPLEMENTATION.
METHOD handler.
DATA : lv_count TYPE i,
r_ucomm TYPE sy-ucomm.

LOOP AT lt_vbak ASSIGNING FIELD-SYMBOL(<fs_vbak>) WHERE check = ‘X’ .
CASE sy-ucomm.
WHEN ‘APPROVE’.
<fs_vbak>-status = ‘Approved’.
WHEN ‘REJECT’.
<fs_vbak>-status = ‘Rejected’.
WHEN ‘DET_VIEW’.
SET PARAMETER ID ‘AUN’ FIELD <fs_vbak>-vbeln.
CALL TRANSACTION ‘VA03’ AND SKIP FIRST SCREEN.
ENDCASE.
lv_count += 1.
ENDLOOP.
r_ucomm = sy-ucomm.
IF r_ucomm = ‘&SAVE’.
MODIFY zch_dt_vbak FROM TABLE lt_vbak.
IF sy-subrc = 0.
MESSAGE ‘Changes saved successfully.’ TYPE ‘S’.
ELSE.
MESSAGE ‘Error while saving changes to the database.’ TYPE ‘E’.
ENDIF.
ELSEIF lv_count = 0 AND p_r1 = ‘X’.
MESSAGE ‘Please select at least one Sales Order.’ TYPE ‘I’.
ENDIF.
lo_salv->refresh( ).
ENDMETHOD.
METHOD handle_click.
READ TABLE lt_vbak ASSIGNING FIELD-SYMBOL(<ls_vbak>) INDEX row.
IF <ls_vbak>-check IS INITIAL.
<ls_vbak>-check = ‘X’.
ELSE.
CLEAR <ls_vbak>-check.
ENDIF.
lo_salv->refresh( ).
ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
IF lt_vbak IS INITIAL.
SELECT FROM zch_dt_vbak FIELDS vbeln,
erdat,
vkorg,
kunnr,
netwr,
status
WHERE vbeln IN @s_vbeln
INTO TABLE _vbak.
ENDIF.

DATA: lx_msg TYPE REF TO cx_salv_msg.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = lo_salv ” Basis Class Simple ALV Tables
CHANGING
t_table = lt_vbak
).
CATCH cx_salv_msg. ” ALV: General Error Class with Message
ENDTRY.

lo_salv->get_columns( RECEIVING value = lo_columns ).

lo_columns->set_optimize(‘X’).
TRY.
lo_column ?= lo_columns->get_column( ‘CHECK’ ).
lo_column->set_cell_type( if_salv_c_cell_type=>checkbox_hotspot ).
lo_column->set_output_length( 10 ).
CATCH cx_salv_not_found.
ENDTRY.

lo_columns->set_column_position( columnname = ‘CHECK’ position = 1 ).
TRY.
CALL METHOD lo_columns->get_column
EXPORTING
columnname = ‘CHECK’
RECEIVING
value = lo_column1.
lo_column1->set_long_text( value = ‘Select’ ).
CATCH cx_salv_not_found.
ENDTRY.

IF p_r1 = ‘X’.
CALL METHOD lo_salv->set_screen_status
EXPORTING
report = sy-repid
pfstatus = ‘TOOLBAR’.
ELSE.
CALL METHOD lo_salv->set_screen_status
EXPORTING
report = sy-repid
pfstatus = ‘TOOLBAR2’.
ENDIF.
CALL METHOD lo_salv->get_event
RECEIVING
value = lo_events.

DATA(lo_handler) = NEW lcl_event( ).
DATA(lo_handle_click) = NEW lcl_event( ).
SET HANDLER lo_handler->handler FOR lo_events.
SET HANDLER lo_handle_click->handle_click FOR lo_events.

CALL METHOD lo_salv->display( ).

Output : 

When I select Manager, then ‘Approve’ and ‘Reject’ Button will appear 

When user Selects the sales order using checkbox and click on Approve or Reject, the Status field will be updated and when clicked on SAVE it saves in the database table along with status. 

Database: 

If the user selects the Sales Executive radio button, then only the Detail view button will be visible when the user can navigate to VA03 getting detail info of that sales order. 

 

I selected sales order 20, so when user clicks on Detail View, it displays detail information of that specific record. 

Conclusion: 
This approach of integrating checkbox selection with designation-based dynamic toolbar control in SALV reports significantly improves both user experience and operational accuracy. By tailoring available actions based on user designation, we not only reduce clutter and potential errors but also promote better decision-making aligned with business roles. 

Leveraging the flexibility of OOABAP and SALV, this solution modernizes classic ALV interactions in a clean, maintainable way. 

I hope this blog helps you implement similar logic in your own SALV reports. 

 

​ Introduction In many SAP reporting scenarios, there is a need to control available user actions dynamically, rather than defining all functions statically upfront. Instead of displaying a fixed set of toolbar buttons in an SALV report, we can adjust them at runtime based on various conditions — such as user designation (e.g., a Manager may need buttons like “Approve” and “Reject”, while a Sales Executive may only need a “Detail View” button), record status (e.g., if a sales order is already approved, the “Approve” button should be hidden or disabled ), or business logic(eg.,showing a “Reschedule” button only if the delivery date is today). This blog demonstrates how to: Display sales order data in a SALV report, Add checkbox selection for line-level actions, Implement custom toolbar buttons (Approve, Reject, Detail View ), Dynamically control toolbar buttons using Designation (via radio buttons). Business Requirement We are writing an SALV report that displays Sales Order details. Depending on the designation selected by the user, the SALV should display different function buttons: Designation Visible Buttons Manager Approve, Reject Sales Executive Detail View Additionally, users can select specific records using checkboxes, and based on button clicks, perform actions like updating statuses and navigating to VA03 (Display Sales Order). Step-by-Step Implementation  Define Data Structures Define a custom structure for sales order data with an additional CHECK field for checkbox selection:  Define Internal tables and Variables  *– Define a structure for Sales Order data
TYPES : BEGIN OF ty_sales,
vbeln TYPE vbeln_va, “sales document
erdat TYPE erdat, “Created On
vkorg TYPE vkorg, “Sales Organization
kunnr TYPE kunnr, “customer
netwr TYPE netwr_ak, “Net value
status TYPE zch_de_status, “custom field Status
check TYPE char1, “For Checkbox selection
END OF ty_sales.

*– Declare required internal tables and variables
DATA : lv_vbeln TYPE vbak-vbeln,
lt_vbak TYPE TABLE OF ty_sales,
lo_salv TYPE REF TO cl_salv_table,
lo_toolbar TYPE REF TO cl_salv_functions_list,
lo_events TYPE REF TO cl_salv_events_table,
lo_columns TYPE REF TO cl_salv_columns,
lo_column TYPE REF TO cl_salv_column_list,
lo_column1 TYPE REF TO cl_salv_column. Create Designation-Based Selection Screen Here, p_r1 = Manager and p_r2 = Sales Executive. *– Selection screen with sales document and designation selection
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME .
SELECT-OPTIONS : s_vbeln FOR lv_vbeln.
PARAMETERS : p_r1 TYPE c RADIOBUTTON GROUP r1,
p_r2 TYPE c RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK b1. Fetch Sales Order Data Display using SALV Factory method The SALV object is created using the factory method and filled with data from the custom table zch_dt_vbak START-OF-SELECTION.
IF lt_vbak IS INITIAL.
SELECT FROM zch_dt_vbak FIELDS vbeln,
erdat,
vkorg,
kunnr,
netwr,
status
WHERE vbeln IN @s_vbeln
INTO TABLE _vbak.
ENDIF.

DATA: lx_msg TYPE REF TO cx_salv_msg.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = lo_alv
CHANGING
t_table = lt_vbak
).
CATCH cx_salv_msg. ” ALV: General Error Class with Message
ENDTRY. Add Checkbox for selecting the rows To get the selectable (editable) checkbox, we need to get the specific column from the column object.  After this, we need to set the cell type as IF_SALV_C_CELL_TYPE=>CHECKBOX_HOTSPOT by using the method SET_CELL_TYPE.  To update the values in the checkbox, we need to handle the event LINK_CLICK.  This event LINK_CLICK is triggered when we click on the hotspot enabled checkbox.  In the event handler method, we need to change the value of the checkbox field and call the REFRESH method to refresh the value on the ALV. lo_salv->get_columns( RECEIVING value = lo_columns ).
lo_columns->set_optimize(‘X’).
TRY.
lo_column ?= lo_columns->get_column( ‘CHECK’ ).
lo_column->set_cell_type( if_salv_c_cell_type=>checkbox_hotspot ).
lo_column->set_output_length( 10 ).
CATCH cx_salv_not_found.
ENDTRY. Set Column Position and Header (Optional) For better UI, position the checkbox as the first column by using SET_COLUMN_POSITION and rename the field by using SET_LONG_TEXT. lo_columns->set_column_position( columnname = ‘CHECK’ position = 1 ).
TRY.
CALL METHOD lo_columns->get_column
EXPORTING
columnname = ‘CHECK’
RECEIVING
value = lo_column1.
lo_column1->set_long_text( value = ‘Select’ ).
CATCH cx_salv_not_found.
ENDTRY.Event Handler methods for handling toolbar and checkbox CLASS lcl_event DEFINITION.
PUBLIC SECTION.
METHODS handler FOR EVENT added_function OF cl_salv_events_table.
METHODS handle_click FOR EVENT link_click OF cl_salv_events_table IMPORTING row.
ENDCLASS. Implementation for ‘handle_click’ method METHOD handle_click.
READ TABLE lt_vbak ASSIGNING FIELD-SYMBOL(<ls_vbak>) INDEX row.
IF <ls_vbak>-check IS INITIAL.
<ls_vbak>-check = ‘X’.
ELSE.
CLEAR <ls_vbak>-check.
ENDIF.
lo_salv->refresh( ).
ENDMETHOD. In SALV, we can add custom toolbar buttons using the SET_SCREEN_STATUS method and maintain the function codes and buttons using transaction SE41. IF p_r1 = ‘X’.
CALL METHOD lo_salv->set_screen_status
EXPORTING
report = sy-repid
pfstatus = ‘TOOLBAR’.
ELSE.
CALL METHOD lo_salv->set_screen_status
EXPORTING
report = sy-repid
pfstatus = ‘TOOLBAR2’.
ENDIF.  Handle User Actions Based on Selected Checkbox and Button   METHOD handler.
DATA : lv_count TYPE i,
r_ucomm TYPE sy-ucomm.

LOOP AT lt_vbak ASSIGNING FIELD-SYMBOL(<fs_vbak>) WHERE check = ‘X’ .
CASE sy-ucomm.
WHEN ‘APPROVE’.
<fs_vbak>-status = ‘Approved’.
WHEN ‘REJECT’.
<fs_vbak>-status = ‘Rejected’.
WHEN ‘DET_VIEW’.
SET PARAMETER ID ‘AUN’ FIELD <fs_vbak>-vbeln.
CALL TRANSACTION ‘VA03’ AND SKIP FIRST SCREEN.
ENDCASE.
lv_count += 1.
ENDLOOP.
r_ucomm = sy-ucomm.
IF r_ucomm = ‘&SAVE’.
MODIFY zch_dt_vbak FROM TABLE lt_vbak.
IF sy-subrc = 0.
MESSAGE ‘Changes saved successfully.’ TYPE ‘S’.
ELSE.
MESSAGE ‘Error while saving changes to the database.’ TYPE ‘E’.
ENDIF.
ELSEIF lv_count = 0 AND p_r1 = ‘X’.
MESSAGE ‘Please select at least one Sales Order.’ TYPE ‘I’.
ENDIF.
lo_salv->refresh( ).Full Implementation Code REPORT zch_rp_salv_report.
*– Define a structure for Sales Order data
TYPES : BEGIN OF ty_sales,
vbeln TYPE vbeln_va, “sales document
erdat TYPE erdat, “Created On
vkorg TYPE vkorg, “Sales Organization
kunnr TYPE kunnr, “customer
netwr TYPE netwr_ak, “Net value
status TYPE zch_de_status, “custom field Status
check TYPE char1, “For Checkbox selection
END OF ty_sales.

*– Declare required internal tables and variables
DATA : lv_vbeln TYPE vbak-vbeln,
lt_vbak TYPE TABLE OF ty_sales,
lo_salv TYPE REF TO cl_salv_table,
lo_toolbar TYPE REF TO cl_salv_functions_list,
lo_events TYPE REF TO cl_salv_events_table,
lo_columns TYPE REF TO cl_salv_columns,
lo_column TYPE REF TO cl_salv_column_list,
lo_column1 TYPE REF TO cl_salv_column.

*– Selection screen with sales document and role selection
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME .
SELECT-OPTIONS : s_vbeln FOR lv_vbeln.
PARAMETERS : p_r1 TYPE c RADIOBUTTON GROUP r1,
p_r2 TYPE c RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK b1.

CLASS lcl_event DEFINITION.
PUBLIC SECTION.
METHODS handler FOR EVENT added_function OF cl_salv_events_table.
METHODS handle_click FOR EVENT link_click OF cl_salv_events_table IMPORTING row.
ENDCLASS.
CLASS lcl_event IMPLEMENTATION.
METHOD handler.
DATA : lv_count TYPE i,
r_ucomm TYPE sy-ucomm.

LOOP AT lt_vbak ASSIGNING FIELD-SYMBOL(<fs_vbak>) WHERE check = ‘X’ .
CASE sy-ucomm.
WHEN ‘APPROVE’.
<fs_vbak>-status = ‘Approved’.
WHEN ‘REJECT’.
<fs_vbak>-status = ‘Rejected’.
WHEN ‘DET_VIEW’.
SET PARAMETER ID ‘AUN’ FIELD <fs_vbak>-vbeln.
CALL TRANSACTION ‘VA03’ AND SKIP FIRST SCREEN.
ENDCASE.
lv_count += 1.
ENDLOOP.
r_ucomm = sy-ucomm.
IF r_ucomm = ‘&SAVE’.
MODIFY zch_dt_vbak FROM TABLE lt_vbak.
IF sy-subrc = 0.
MESSAGE ‘Changes saved successfully.’ TYPE ‘S’.
ELSE.
MESSAGE ‘Error while saving changes to the database.’ TYPE ‘E’.
ENDIF.
ELSEIF lv_count = 0 AND p_r1 = ‘X’.
MESSAGE ‘Please select at least one Sales Order.’ TYPE ‘I’.
ENDIF.
lo_salv->refresh( ).
ENDMETHOD.
METHOD handle_click.
READ TABLE lt_vbak ASSIGNING FIELD-SYMBOL(<ls_vbak>) INDEX row.
IF <ls_vbak>-check IS INITIAL.
<ls_vbak>-check = ‘X’.
ELSE.
CLEAR <ls_vbak>-check.
ENDIF.
lo_salv->refresh( ).
ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
IF lt_vbak IS INITIAL.
SELECT FROM zch_dt_vbak FIELDS vbeln,
erdat,
vkorg,
kunnr,
netwr,
status
WHERE vbeln IN @s_vbeln
INTO TABLE _vbak.
ENDIF.

DATA: lx_msg TYPE REF TO cx_salv_msg.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = lo_salv ” Basis Class Simple ALV Tables
CHANGING
t_table = lt_vbak
).
CATCH cx_salv_msg. ” ALV: General Error Class with Message
ENDTRY.

lo_salv->get_columns( RECEIVING value = lo_columns ).

lo_columns->set_optimize(‘X’).
TRY.
lo_column ?= lo_columns->get_column( ‘CHECK’ ).
lo_column->set_cell_type( if_salv_c_cell_type=>checkbox_hotspot ).
lo_column->set_output_length( 10 ).
CATCH cx_salv_not_found.
ENDTRY.

lo_columns->set_column_position( columnname = ‘CHECK’ position = 1 ).
TRY.
CALL METHOD lo_columns->get_column
EXPORTING
columnname = ‘CHECK’
RECEIVING
value = lo_column1.
lo_column1->set_long_text( value = ‘Select’ ).
CATCH cx_salv_not_found.
ENDTRY.

IF p_r1 = ‘X’.
CALL METHOD lo_salv->set_screen_status
EXPORTING
report = sy-repid
pfstatus = ‘TOOLBAR’.
ELSE.
CALL METHOD lo_salv->set_screen_status
EXPORTING
report = sy-repid
pfstatus = ‘TOOLBAR2’.
ENDIF.
CALL METHOD lo_salv->get_event
RECEIVING
value = lo_events.

DATA(lo_handler) = NEW lcl_event( ).
DATA(lo_handle_click) = NEW lcl_event( ).
SET HANDLER lo_handler->handler FOR lo_events.
SET HANDLER lo_handle_click->handle_click FOR lo_events.

CALL METHOD lo_salv->display( ).Output : When I select Manager, then ‘Approve’ and ‘Reject’ Button will appear When user Selects the sales order using checkbox and click on Approve or Reject, the Status field will be updated and when clicked on SAVE it saves in the database table along with status. Database: If the user selects the Sales Executive radio button, then only the Detail view button will be visible when the user can navigate to VA03 getting detail info of that sales order.  I selected sales order 20, so when user clicks on Detail View, it displays detail information of that specific record. Conclusion: This approach of integrating checkbox selection with designation-based dynamic toolbar control in SALV reports significantly improves both user experience and operational accuracy. By tailoring available actions based on user designation, we not only reduce clutter and potential errors but also promote better decision-making aligned with business roles. Leveraging the flexibility of OOABAP and SALV, this solution modernizes classic ALV interactions in a clean, maintainable way. I hope this blog helps you implement similar logic in your own SALV reports.    Read More Application Development and Automation Blog Posts articles 

#SAP

You May Also Like

More From Author