Skip to end of metadata
Go to start of metadata

During Process On Value-Request event, it is not possible to change the value of another field by a single field assignment. You must use DYNP_VALUES_UPDATE function module to achieve this. It is valid for both selection screens (example below) and screens.

*-------------------------------------------------------*
*    report
*------------------------------------------------------* 
REPORT zhelp_value .
*-------------------------------------------------------*
*       database tables used
*------------------------------------------------------*
TABLES tcurt.
*-------------------------------------------------------*
*    data declarations
*------------------------------------------------------*
DATA:  dyfields LIKE dynpread OCCURS 0 WITH HEADER LINE.
*-------------------------------------------------------*
*   selection screen design
*------------------------------------------------------*
PARAMETERS: p_waers LIKE tcurt-waers, "Currency
p_ltext LIKE tcurt-ltext, "Long Text
p_ktext LIKE tcurt-ktext. "Short Text
*-------------------------------------------------------*
*  at selection screen on field
*------------------------------------------------------*
*--- Example of updating value of another field on the screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_waers.
CLEAR: dyfields[],
dyfields.
*--- select currency
CALL FUNCTION 'HELP_VALUES_GET'
EXPORTING
fieldname = 'WAERS'
tabname = 'TCURT'
IMPORTING
select_value = p_waers.
*--- get long text for the selected currency
SELECT SINGLE ltext
FROM tcurt
INTO dyfields-fieldvalue
WHERE spras = sy-langu
AND waers = p_waers.
IF sy-subrc <> 0.
CLEAR dyfields-fieldvalue.
ENDIF.
*--- update another field
dyfields-fieldname = 'P_LTEXT'.
APPEND dyfields.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = sy-cprog
dynumb = sy-dynnr
TABLES
dynpfields = dyfields.
start-of-selection .