1 DATA:ls_data TYPE cvis_ei_extern,
2 lt_data TYPE cvis_ei_extern_t,
3 lt_return TYPE bapiretm,
4 ls_return TYPE bapireti,
5 ls_msg TYPE bapiretc.
6 DATA:ev_zmsg TYPE bapi_msg,
7 ev_ztype TYPE bapi_mtype,
8 lt_sales TYPE cmds_ei_sales_t,
9 ls_sales TYPE cmds_ei_sales,
10 lt_company TYPE cmds_ei_company_t,
11 ls_company TYPE cmds_ei_company,
12 ls_customer TYPE cmds_ei_extern,
13 ls_partner TYPE bus_ei_extern,
14 ls_sales_data TYPE cmds_ei_cmd_sales,
15 ls_company_data TYPE cmds_ei_cmd_company,
16 lt_functions TYPE cmds_ei_functions_t,
17 ls_functions TYPE cmds_ei_functions,
18 lv_partner_guid TYPE but000-partner_guid,
19 ls_header TYPE cmds_ei_header.
20
21 LOOP AT gt_data ASSIGNING FIELD-SYMBOL(<fs_data>).
22
23 SELECT SINGLE partner_guid FROM but000 INTO lv_partner_guid WHERE partner = <fs_data>-kunnr.
24
25 CHECK lv_partner_guid IS NOT INITIAL.
26 ls_partner-header-object_task = 'U'.
27 ls_partner-header-object_instance-bpartnerguid = lv_partner_guid.
28 ls_partner-header-object_instance-bpartner = <fs_data>-kunnr ."
29 ls_partner-central_data-common-data-bp_control-category = 2. "业务伙伴类别
30
31 ls_header-object_task = 'U'.
32
33 "销售视图
34 ls_sales-task = 'U'.
35 ls_sales-data_key-vkorg = <fs_data>-vkorg. " 销售组织
36 ls_sales-data_key-vtweg = '00'. " 分销渠道
37 ls_sales-data_key-spart = '00'. " 产品组
38 ls_sales-data-zterm = <fs_data>-zterm."付款条件
39 ls_sales-datax-zterm = 'X'.
40 APPEND ls_sales TO lt_sales.
41
42 "公司视图
43 ls_company-task = 'U' .
44 SELECT SINGLE bukrs
45 INTO ls_company-data_key-bukrs
46 FROM tvko
47 WHERE vkorg = <fs_data>-vkorg.
48 ls_company-data-zterm = <fs_data>-zterm."付款条件
49 ls_company-datax-zterm = 'X' .
50 APPEND ls_company TO lt_company .
51
52 ls_sales_data-sales = lt_sales.
53 ls_customer-header = ls_header.
54 ls_customer-sales_data = ls_sales_data.
55 ls_data-partner = ls_partner.
56 ls_data-customer = ls_customer.
57 REFRESH lt_data.
58 APPEND ls_data TO lt_data.
59
60 CALL FUNCTION 'CVI_EI_INBOUND_MAIN'
61 EXPORTING
62 i_data = lt_data
63 IMPORTING
64 e_return = lt_return.
65
66 CLEAR ev_zmsg.
67 LOOP AT lt_return INTO ls_return.
68 LOOP AT ls_return-object_msg INTO ls_msg WHERE type = 'E' OR type = 'A' .
69 CONCATENATE ev_zmsg ls_msg-message INTO ev_zmsg.
70 ENDLOOP.
71 ENDLOOP.
72
73 IF ev_zmsg IS INITIAL.
74 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
75 EXPORTING
76 wait = 'X'.
77 ELSE.
78 CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK' .
79 ENDIF.
80
81 ENDLOOP .