2015年9月3日 星期四

ABAP/4 Use DYNP_VALUES_READ & DYNP_VALUES_UPDATE read/update current screen PARAMETER or SELECT-OPTIONS value

在 AT SELECTION-SCREEN ON VALUE-REQUEST FOR <Parameters or Select-Option> 要捉取畫面的變數時,會無法取得目前的值


使用 DYNP_VALUES_READ 即可取得目前畫面上的值


主要的程式是使用到 DYNP_VALUES_READ & DYNP_VALUES_UPDATE

  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.

SAMPLE CODE

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.

沒有留言:

張貼留言

How to install & specified python version or distreibtuion package version in google colab

在買了 RTX 3080 要來 挖礦...  嗯~是跑機器學習後,結果發現了 GOOGLE COLAB,其實之前在「GAN 對抗式生成網路」一書就有看到,但資訊人就是什麼都想自己安裝,在本機用 Anaconda + pyCharm 弄了 GPU 環境,結果有天從新竹回家發現家裡沒...