前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【SAP ABAP系列】DYNP_VALUES_UPDATE 更新屏幕字段的函数及用法

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

原创
作者头像
matinal
修改2020-11-16 09:59:01
1.2K0
修改2020-11-16 09:59:01
举报
文章被收录于专栏:SAP Technical

正文部分

代码语言:javascript
复制
​
用这两个函数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

​

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 正文部分
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档