Kelvin Huynh
Kelvin Huynh

Reputation: 11

How to retrieve data from a popup window in ALV display report after user input in SAP ABAP?

I'm working on an SAP ABAP program where I have an ALV report with two custom buttons. When a user clicks one of the buttons, a popup window appears with two fields where the user needs to enter data.

After the user clicks "OK" to submit, I need to retrieve the data entered into these fields for further processing.

Here’s a summary of the scenario:

  1. After displaying the ALV report, I have two buttons.
  2. When either of the buttons is clicked, a popup window is displayed (using CALL SCREEN).
  3. The popup contains two fields where the user inputs data.

ABAP popup with two input fields

  1. After the user clicks "OK" to submit, I need to retrieve the data entered in the popup fields (LS_QUANTITY and PRPSS-POSID), but I am struggling to access these fields outside the screen.

The fields are defined in the popup screen layout (Screen 100 and Screen 200), but I can’t figure out how to retrieve the values entered by the user once they submit the popup.

Can anyone help me understand how to retrieve the values from these input fields in the popup after the user submits them?

Upvotes: 0

Views: 172

Answers (2)

Bach Cao
Bach Cao

Reputation: 5

see in this post: https://community.sap.com/t5/application-development-discussions/passing-data-between-selection-screens/td-p/9505731

Or you can try to export/import to memory

Upvotes: -2

mkysoft
mkysoft

Reputation: 5758

You need to use global variable for screen fields. For example you can access PRPSS-POSID in your code at screen PAU.

On the other hand, you can use exist FM for requesting data.

FORM popup_get_values CHANGING cv_posid    TYPE prpss-posid
                               cv_quantity TYPE prpss-usr04.

  DATA: lt_field TYPE TABLE OF sval,
        ls_field TYPE sval.

  ls_field-tabname = 'PRPSS'.
  ls_field-fieldname = 'POSID'.
  APPEND ls_field TO lt_field.

  CLEAR ls_field.
  ls_field-tabname = 'PRPSS'.
  ls_field-fieldname = 'USR04'.
  APPEND ls_field TO lt_field.

  "Call the popup function module
  CALL FUNCTION 'POPUP_GET_VALUES'
    EXPORTING
      popup_title     = 'Enter POS ID and Quantity'
    TABLES
      fields          = lt_field
    EXCEPTIONS
      error_in_fields = 1
      OTHERS          = 2.

  IF sy-subrc = 0.
    READ TABLE lt_field INTO ls_field WITH KEY fieldname = 'POSID'.
    IF sy-subrc = 0.
      cv_posid = ls_field-value.
    ENDIF.

    READ TABLE lt_field INTO ls_field WITH KEY fieldname = 'QUANTITY'.
    IF sy-subrc = 0.
      cv_quantity = ls_field-value.
    ENDIF.
  ELSE.
    MESSAGE 'Popup canceled' TYPE 'I'.
  ENDIF.

ENDFORM.

Upvotes: 0

Related Questions