码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-07-14 11:35:11      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:mob   代码   pen   函数   src   cep   关注   rip   img   

公众号:SAP Technical
本文作者:matinal
 

技术图片

 

前言部分

大家可以关注我的公众号,公众号里的排版更好,阅读更舒适。

正文部分

?
用这两个函数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

?

 

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

标签:mob   代码   pen   函数   src   cep   关注   rip   img   

原文地址:https://www.cnblogs.com/SAPmatinal/p/11183339.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!