【ABAP】DYNP_VALUES_UPDATE 更新屏幕字段的函数及用法

​
用这两个函数Function DYNP_VALUES_READ, DYNP_VALUES_UPDATE
参考代码:
MODULE ztmdno_dr_help INPUT.
  DATA:
    l_lifnr   TYPE ztmt018-lifnr,
    l_zvehtab TYPE ztmt018-zvehtab,
    l_zvehid  TYPE ztmt018-zvehid.

  CLEAR: gt_dynfields,gh_dynfields,it_return[],it_ztmdno[],ih_ztmdno.

  gh_dynfields-fieldname = 'PRE_DATA-LIFNR'.
  APPEND gh_dynfields TO gt_dynfields.
  CLEAR gh_dynfields.
  gh_dynfields-fieldname = 'PRE_DATA-ZVEHTAB'.
  APPEND gh_dynfields TO gt_dynfields.
----------------------获取屏幕的值
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname               = sy-repid
      dynumb               = sy-dynnr
      translate_to_upper   = 'X'
    TABLES
      dynpfields           = gt_dynfields
    EXCEPTIONS
      invalid_abapworkarea = 1
      invalid_dynprofield  = 2
      invalid_dynproname   = 3
      invalid_dynpronummer = 4
      invalid_request      = 5
      no_fielddescription  = 6
      invalid_parameter    = 7
      undefind_error       = 8
      double_conversion    = 9
      stepl_not_found      = 10
      OTHERS               = 11.
  IF sy-subrc <> 0.
    MESSAGE '函数DYNP_VALUES_READ,未能取值' TYPE 'E'.
    EXIT.
  ENDIF.
  READ TABLE gt_dynfields INTO gh_dynfields WITH KEY fieldname = 'PRE_DATA-LIFNR'.
  IF sy-subrc = 0.
    l_lifnr = gh_dynfields-fieldvalue.
  ENDIF.

  READ TABLE gt_dynfields INTO gh_dynfields WITH KEY fieldname = 'PRE_DATA-ZVEHTAB'.
  IF sy-subrc = 0.
    IF gh_dynfields-fieldvalue IS INITIAL.
      MESSAGE '请先输入车牌号' TYPE 'I'.
      EXIT.
    ENDIF.
    l_zvehtab = gh_dynfields-fieldvalue.
  ENDIF.

  SELECT SINGLE zvehid
    INTO l_zvehid
    FROM ztmt018
   WHERE lifnr = l_lifnr
     AND zvehtab = l_zvehtab.

  SELECT ztmdno
         ztmdname
         ztmmob
         zvehid
    INTO TABLE it_ztmdno
    FROM ztmt025
   WHERE zvehid = l_zvehid.
  IF it_ztmdno[] IS NOT INITIAL.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
        retfield        = 'ZTMDNO_DR'
        dynpprog        = sy-repid
        dynpnr          = sy-dynnr
        value_org       = 'S'
      TABLES
        value_tab       = it_ztmdno[]
        return_tab      = it_return[]
      EXCEPTIONS
        parameter_error = 1
        no_values_found = 2
        OTHERS          = 3.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

    READ TABLE it_return INDEX 1.
    IF sy-subrc = 0.
      pre_data-ztmdno_dr = it_return-fieldval.
      READ TABLE it_ztmdno INTO ih_ztmdno WITH KEY zvehid = l_zvehid.
      IF sy-subrc = 0.
        CLEAR gh_dynfields.
        gh_dynfields-fieldname = 'PRE_DATA-ZTMDNAME_DR'.
        gh_dynfields-fieldvalue = ih_ztmdno-ztmdname_dr.
        APPEND gh_dynfields TO gt_dynfields.
        CLEAR gh_dynfields.
        gh_dynfields-fieldname = 'PRE_DATA-ZTMMOB'.
        gh_dynfields-fieldvalue = ih_ztmdno-ztmmob.
        APPEND gh_dynfields TO gt_dynfields.
---------------------更新屏幕的值
        CALL FUNCTION 'DYNP_VALUES_UPDATE'
          EXPORTING
            dyname               = sy-repid
            dynumb               = sy-dynnr
          TABLES
            dynpfields           = gt_dynfields
          EXCEPTIONS
            invalid_abapworkarea = 1
            invalid_dynprofield  = 2
            invalid_dynproname   = 3
            invalid_dynpronummer = 4
            invalid_request      = 5
            no_fielddescription  = 6
            undefind_error       = 7
            OTHERS               = 8.
        IF sy-subrc <> 0.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDIF.
ENDMODULE.                 " ZTMDNO_DR_HELP  INPUT

​

给TA买糖
共{{data.count}}人
人已赞赏
ABAPSAP

【ABAP】通过消息号定位标准程序报错位置

2021-8-16 13:24:15

精品软件

【软件】万兴数据恢复 Wondershare

2020-3-16 15:12:03

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索