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

SAP供应商和客户的创建

时间:2014-09-25 15:28:09      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   os   ar   数据   sp   art   cti   

【转自http://blog.csdn.net/lyb_yt/article/details/17962609】
进来遇到一个创建供应商的需求,由于在系统中关于供应商和客户的创建比较特殊,且没有相关函数进行创建,

找到一个类和方法来创建,类名: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.

SAP供应商和客户的创建

标签:blog   http   io   os   ar   数据   sp   art   cti   

原文地址:http://www.cnblogs.com/rainysblog/p/3992548.html

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