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_key-parvw = 'rs'.
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.