Try REUSE_ALV_POPUP_TO_SELECT 

NEWS

0 Comments

The REUSE_ALV_POPUP_TO_SELECT function module in SAP ABAP is used to display a selection list or a popup window with a table containing multiple rows of data. Users can then select one or more rows from the list.

Here’s an example of how to use the REUSE_ALV_POPUP_TO_SELECT function module:

abapCopy codeDATA: lt_data TYPE TABLE OF mara,
      lt_fieldcat TYPE lvc_t_fcat,
      ls_fieldcat TYPE lvc_s_fcat,
      lt_selected_rows TYPE STANDARD TABLE OF mara.

SELECT * FROM mara INTO TABLE lt_data UP TO 10 ROWS.

ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-seltext_m = 'Material Number'.
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-seltext_m = 'Material Number'.
APPEND ls_fieldcat TO lt_fieldcat.

CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
  EXPORTING
    i_display = 'X'
    i_tabname = 'MARA'
    i_callback_program = sy-repid
  TABLES
    t_outtab = lt_data
    t_fieldcat = lt_fieldcat
    t_selected_rows = lt_selected_rows.

IF sy-subrc = 0.
  LOOP AT lt_selected_rows INTO DATA(ls_selected_row).
    WRITE: / 'Selected Material Number:', ls_selected_row-matnr.
  ENDLOOP.
ENDIF.

In this example, we first select some data from the MARA table into the lt_data internal table. Then, we define the field catalog (lt_fieldcat) with the necessary field information for display.

We call the REUSE_ALV_POPUP_TO_SELECT function module and pass the required parameters:

  • i_display is set to ‘X’ to immediately display the selection popup.
  • i_tabname specifies the database table name for the selection list.
  • i_callback_program contains the program name (in this case, we use sy-repid to refer to the current program).

The selected rows are returned in the t_selected_rows internal table. We then loop over the selected rows and display the material number in the output.

This example provides a basic usage of the REUSE_ALV_POPUP_TO_SELECT function module. You can modify the field catalog and further enhance the logic to suit your specific requirements.

Sponsored Ads

Leave a Comment