DATA : L_FIELD TYPE DYNPREAD OCCURS 0 WITH HEADER LINE
把目前的值寫回 Screen 變數
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = L_FIELD.
把目前的值寫回 Screen 變數
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = L_FIELD.
REPORT Z_EX_GET_SCREEN_VAR_VALUE.
TABLES: BKPF.
DATA: L_FIELD TYPE DYNPREAD OCCURS 0 WITH HEADER LINE.
PARAMETERS: P_BUKRS LIKE BKPF-BUKRS.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_BUKRS.
MESSAGE P_BUKRS TYPE 'I'.
L_FIELD-FIELDNAME = 'P_BUKRS'.
APPEND L_FIELD.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = L_FIELD.
IF SY-SUBRC EQ 0.
READ TABLE L_FIELD INDEX 1.
MESSAGE L_FIELD-FIELDVALUE TYPE 'I'.
ENDIF.
另外 DYNP_VALUES_UPDATE 主要是把目前的值寫回畫面
SAMPLE CODE
REPORT Z_EX_GET_SCREEN_VAR_VALUE2.
TABLES: BKPF.
DATA: L_FIELD TYPE DYNPREAD OCCURS 0 WITH HEADER LINE.
PARAMETERS: P_BUKRS LIKE BKPF-BUKRS.
PARAMETERS: P_BUKRS2 LIKE BKPF-BUKRS.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_BUKRS.
L_FIELD-FIELDNAME = 'P_BUKRS'.
APPEND L_FIELD.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = L_FIELD.
IF SY-SUBRC EQ 0.
READ TABLE L_FIELD INDEX 1.
L_FIELD-FIELDNAME = 'P_BUKRS2'.
MODIFY L_FIELD INDEX 1.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = L_FIELD.
ENDIF.
沒有留言:
張貼留言