• SAP供应商和客户的创建


    进来遇到一个创建供应商的需求,由于在系统中关于供应商和客户的创建比较特殊,且没有相关函数进行创建,

    找到一个类和方法来创建,类名:VMD_EI_API  方法名:MAINTAIN_DIRECT_INPUT,类似的

    * 供应商表头
      ls_vendors-header-object_instance-lifnr = lv_vendor.  "供应商
      ls_vendors-header-object_task 'M'.              "创建/更改
    * 通用数据
      ls_vendors-central_data-central-data-stceg       = stceg.      "增值税登记号
      ls_vendors-central_data-central-data-ktokk       '0001'.     "账户组
      ls_vendors-central_data-central-data-j_1kfrepre  = j_1kfrepre"代表名称
      ls_vendors-central_data-central-datax-stceg      'X'.        "增值税登记号
      ls_vendors-central_data-central-datax-ktokk      'X'.        "账户组
      ls_vendors-central_data-central-datax-j_1kfrepre 'X'.        "代表名称
    * 电话
      ls_phone-contact-data-telephone = phone.
      APPEND ls_phone TO ls_vendors-central_data-address-communication-phone-phone.
      CLEAR ls_phone.
    * 邮箱
      ls_smtp-contact-data-e_mail      = smtp.
      APPEND ls_smtp TO ls_vendors-central_data-address-communication-smtp-smtp.
      CLEAR ls_smtp.

      ls_vendors-central_data-address-postal-data-name         = name.       "名称
      ls_vendors-central_data-address-postal-data-name_2       = name.       "名称
      ls_vendors-central_data-address-postal-data-sort1        = sort1.      "属性(SAP为搜索项 1)
      ls_vendors-central_data-address-postal-data-street       = street.     "街道/门牌号
      ls_vendors-central_data-address-postal-data-postl_cod1   = postl_cod1"邮政编码
      ls_vendors-central_data-address-postal-data-city         = city.       "城市
      ls_vendors-central_data-address-postal-data-country      country.    "国家
      ls_vendors-central_data-address-postal-data-region       = region.     "地区
      ls_vendors-central_data-address-postal-data-langu        '1'.        "语言
      ls_vendors-central_data-address-postal-datax-name        'X'.
      ls_vendors-central_data-address-postal-datax-name_2      'X'.
      ls_vendors-central_data-address-postal-datax-sort1       'X'.
      ls_vendors-central_data-address-postal-datax-street      'X'.
      ls_vendors-central_data-address-postal-datax-postl_cod1  'X'.
      ls_vendors-central_data-address-postal-datax-city        'X'.
      ls_vendors-central_data-address-postal-datax-country     'X'.
      ls_vendors-central_data-address-postal-datax-region      'X'.
      ls_vendors-central_data-address-postal-datax-langu       'X'.
    * 采购组织数据
      ls_purchasing-task 'M'.
      ls_purchasing-data_key-ekorg '1000'.
      ls_purchasing-data-waers = waers.
      ls_purchasing-data-verkf = verkf.
      ls_purchasing-data-telf1 = telf1.
      ls_purchasing-data-eikto = eikto.
      ls_purchasing-data-webre  'X'.
      ls_purchasing-datax-waers 'X'.
      ls_purchasing-datax-verkf 'X'.
      ls_purchasing-datax-telf1 'X'.
      ls_purchasing-datax-webre 'X'.
      ls_purchasing-datax-eikto 'X'.

      IF requesttype 'CREATE'.
        ls_functions-task 'I'.
        ls_functions-data_key-parvw 'BA'.
        ls_functions-data-defpa ''.
        ls_functions-data-partner = lv_vendor.
        ls_functions-datax-defpa 'X'.
        ls_functions-datax-partner 'X'.
        APPEND ls_functions TO lt_functions.
        ls_functions-data_key-parvw 'LF'.
        ls_functions-data-defpa ''.
        ls_functions-data-partner = lv_vendor.
        ls_functions-datax-defpa 'X'.
        ls_functions-datax-partner 'X'.
        APPEND ls_functions TO lt_functions.
        ls_functions-data_key-parvw 'RS'.
        ls_functions-data-defpa ''.
        ls_functions-data-partner = lv_vendor.
        ls_functions-datax-defpa 'X'.
        ls_functions-datax-partner 'X'.
        APPEND ls_functions TO lt_functions.
        ls_purchasing-functions-functions = lt_functions.
      ENDIF.
      APPEND ls_purchasing TO ls_vendors-purchasing_data-purchasing.
      CLEAR ls_purchasing.

      APPEND ls_vendors TO lt_vendors.
      CLEAR ls_vendors.
      ls_main-vendors = lt_vendors.

    * 创建或者更新供应商
      CALL METHOD vmd_ei_api=>maintain_direct_input
        EXPORTING
          is_master_data           = ls_main
        IMPORTING
          es_master_data_correct   = l1
          es_message_correct       = l2
          es_master_data_defective = l3
          es_message_defective     = l4.
      IF l4-is_error ''.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait 'X'.
        return_status 'S'.
        IF requesttype 'CREATE'.
          return_value '供应商创建成功!'.
        ELSEIF requesttype 'UPDATE'.
          return_value '供应商更新成功!'.
        ENDIF.
        sapcode = lv_vendor.
      ELSE.
        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
        return_status 'F'.
        CLEAR ls_message.
        READ TABLE l4-messages INTO ls_message WITH KEY type 'E'.
        IF sy-subrc 0.
          MESSAGE ID ls_message-id              
    TYPE ls_message-type              
    NUMBER ls_message-number              
    WITH  ls_message-message_v1                    ls_message
    -message_v2                    ls_message
    -message_v3                    ls_message
    -message_v4              
    INTO return_value.    
    ENDIF.  
    ENDIF.

     
     
  • 相关阅读:
    HEOI2017游记
    uoj228:基础数据结构练习题
    bzoj1494【Noi2007】生成树计数
    bzoj1975【Sdoi2010】魔法猪学院
    bzoj2957:楼房重建
    uoj169:元旦老人与数列
    bzoj2178:圆的面积并
    一道好题
    Codeforces Round #440(Div.2)
    Codeforces Round #439 (Div. 2)
  • 原文地址:https://www.cnblogs.com/zfswff/p/5691975.html
Copyright © 2020-2023  润新知