CALL METHOD CMD_EI_API=>MAINTAIN_BAPI

FUNCTION Z_CS_RFC_OA002 .
*"----------------------------------------------------------------------
*"*"本地接口:
*" EXPORTING
*" VALUE(EX_TYPE) TYPE CHAR1
*" VALUE(EX_MSG) TYPE STRING
*" VALUE(EX_VALUE) TYPE KUNNR
*" TABLES
*" IN_DATA STRUCTURE ZSCS_002
*"----------------------------------------------------------------------
DATA:G_LIN TYPE STRING.
DATA:LV_FLG.
DATA:G_PARNR TYPE PARNR.. DATA:LS_MAIN TYPE CMDS_EI_MAIN,
LS_MAIN1 TYPE CMDS_EI_MAIN,
LS_MAIN2 TYPE CMDS_EI_MAIN,
LS_MESG TYPE CVIS_MESSAGE,
LS_MESG1 TYPE CVIS_MESSAGE,
LT_MSG TYPE BAPIRET2_T,
LWA_MSG TYPE BAPIRET2,
LT_CUST TYPE CMDS_EI_EXTERN_T,
LWA_CUST TYPE CMDS_EI_EXTERN,
LWA_SALE TYPE CMDS_EI_SALES,
LT_SALE TYPE CMDS_EI_SALES_T,
LT_FUNCTIONS TYPE CMDS_EI_FUNCTIONS_T,
LWA_FUNCTIONS TYPE CMDS_EI_FUNCTIONS,
LT_COMPANY TYPE CMDS_EI_COMPANY_T,
LT_TEXT TYPE CVIS_EI_TEXT_T,
LWA_TEXT TYPE CVIS_EI_TEXT,
LT_CONTENT TYPE TLINE_TAB,
LWA_CONTENT TYPE TLINE,
LWA_TAX TYPE CMDS_EI_TAX_IND,
LT_TAX TYPE CMDS_EI_TAX_IND_T,
LT_REMARK TYPE CVIS_EI_REM_T,
LWA_REMARK TYPE CVIS_EI_REM,
LT_TEL TYPE CVIS_EI_TLX_T,
LWA_TEL TYPE CVIS_EI_TLX_STR,
LT_FAX TYPE CVIS_EI_FAX_T,
LWA_FAX TYPE CVIS_EI_FAX_STR,
LT_MAIL TYPE CVIS_EI_SMTP_T,
LWA_MAIL TYPE CVIS_EI_SMTP_STR,
LT_TEL01 TYPE CVIS_EI_TTX_T,
LWA_TEL01 TYPE CVIS_EI_TTX_STR,
LT_CONTACT TYPE CMDS_EI_CONTACTS_T,
LWA_CONTACT TYPE CMDS_EI_CONTACTS,
LT_VERSION TYPE CVI_EI_VERSION_TYPE1_T,
LWA_VERSION TYPE CVI_EI_VERSION_TYPE1,
LT_PHONE TYPE CVIS_EI_PHONE_T,
LWA_PHONE TYPE CVIS_EI_PHONE_STR,
LT_PHONE1 TYPE CVIS_EI_PHONE_T,
LWA_PHONE1 TYPE CVIS_EI_PHONE_STR,
LWA_COMPANY TYPE CMDS_EI_COMPANY,
LT_GET TYPE CMDS_EI_EXTERN_T,
LWA_GET TYPE CMDS_EI_EXTERN. CONSTANTS:CON_INSERT TYPE C VALUE 'I',
CON_UPDATE TYPE C VALUE 'M'.
*&--------------------------------------------------------------- *&S1.检查数据条目数
G_LIN = LINES( IN_DATA[] ).
IF G_LIN EQ .
EX_TYPE = 'E'.
EX_MSG = '没有数据!'.
ELSEIF G_LIN GT .
EX_TYPE = 'E'.
EX_MSG = '数据大于30条!'.
ENDIF. CHECK EX_TYPE NE 'E'. LOOP AT IN_DATA.
*&S2..主数据
LWA_CUST-HEADER-OBJECT_TASK = 'I'.
LWA_CUST-CENTRAL_DATA-CENTRAL-DATA-KTOKD = 'Z001'. "客户帐户组
*&sign
LWA_CUST-CENTRAL_DATA-CENTRAL-DATAX-KTOKD = 'X'.
*LWA_CUST-CENTRAL_DATA-CENTRAL-DATAX-CIVVE = 'X'.
*&S2..地址数据
LWA_CUST-CENTRAL_DATA-ADDRESS-TASK = 'I'.
LWA_CUST-CENTRAL_DATA-ADDRESS-POSTAL-DATA-TITLE = ''. "关键字 '3'公司
LWA_CUST-CENTRAL_DATA-ADDRESS-POSTAL-DATA-NAME = '重庆火锅客户'."客户名称
LWA_CUST-CENTRAL_DATA-ADDRESS-POSTAL-DATA-LANGU = SY-LANGU.
LWA_CUST-CENTRAL_DATA-ADDRESS-POSTAL-DATA-COUNTRY = 'CN'.
LWA_CUST-CENTRAL_DATA-ADDRESS-POSTAL-DATA-STREET = '重庆渝中区新华路123号'.
*&sign
LWA_CUST-CENTRAL_DATA-ADDRESS-POSTAL-DATAX-TITLE = 'X'.
LWA_CUST-CENTRAL_DATA-ADDRESS-POSTAL-DATAX-NAME = 'X'.
LWA_CUST-CENTRAL_DATA-ADDRESS-POSTAL-DATAX-LANGU = 'X'.
LWA_CUST-CENTRAL_DATA-ADDRESS-POSTAL-DATAX-COUNTRY = 'X'.
LWA_CUST-CENTRAL_DATA-ADDRESS-POSTAL-DATAX-STREET = 'X'.
*&S2.3电话
CLEAR:LWA_PHONE.
REFRESH LT_PHONE.
LWA_PHONE-CONTACT-TASK = CON_INSERT.
LWA_PHONE-CONTACT-DATA-TELEPHONE = ''."电话号码 W_BASIS-TEL.
LWA_PHONE-CONTACT-DATAX-TELEPHONE = 'X'.
APPEND LWA_PHONE TO LT_PHONE.
LWA_CUST-CENTRAL_DATA-ADDRESS-COMMUNICATION-PHONE-PHONE = LT_PHONE.
**S2.4联系人1
*CLEAR:G_PARNR.
*CALL FUNCTION 'NUMBER_GET_NEXT'
* EXPORTING
* NR_RANGE_NR = 'AP'
* OBJECT = 'PARTNER'
* QUANTITY = ''
* IMPORTING
* NUMBER = G_PARNR
* EXCEPTIONS
* INTERVAL_NOT_FOUND =
* NUMBER_RANGE_NOT_INTERN =
* OBJECT_NOT_FOUND =
* QUANTITY_IS_0 =
* QUANTITY_IS_NOT_1 =
* INTERVAL_OVERFLOW =
* BUFFER_OVERFLOW =
* OTHERS = .
*LWA_CONTACT-TASK = 'I'.
*LWA_CONTACT-ADDRESS_TYPE_3-TASK = 'I'.
*LWA_CONTACT-DATA_KEY-PARNR = G_PARNR.
*LWA_CONTACT-ADDRESS_TYPE_3-POSTAL-DATA-FIRSTNAME = 'aa'.
*LWA_CONTACT-ADDRESS_TYPE_3-POSTAL-DATA-LASTNAME = 'bb'.
*LWA_CONTACT-ADDRESS_TYPE_3-POSTAL-DATAX-FIRSTNAME = 'X'.
*LWA_CONTACT-ADDRESS_TYPE_3-POSTAL-DATAX-LASTNAME = 'X'.
*LWA_CONTACT-ADDRESS_TYPE_3-COMMUNICATION-PHONE-PHONE = LT_PHONE1.
*APPEND LWA_CONTACT TO LT_CONTACT.
*LWA_CUST-CENTRAL_DATA-CONTACT-CONTACTS = LT_CONTACT.
*&S2.5联系人电话
*lwa_phone1-contact-task = 'I'.
*lwa_phone1-contact-data-telephone = ''.
*lwa_phone1-contact-data-extension = ''.
*lwa_phone1-contact-datax-extension = 'X'.
*lwa_phone1-contact-datax-telephone = 'X'.
*APPEND lwa_phone1 TO lt_phone1. *&get in_data.
APPEND LWA_CUST TO LT_CUST.
LS_MAIN-CUSTOMERS = LT_CUST."客户 (Tab.) 的复杂外部接口
*&S3.Create custmer
CALL METHOD CMD_EI_API=>MAINTAIN_BAPI
EXPORTING
* IV_TEST_RUN = P_TEST
IV_COLLECT_MESSAGES = 'X'
IS_MASTER_DATA = LS_MAIN
IMPORTING
ES_MASTER_DATA_CORRECT = LS_MAIN1
ES_MESSAGE_CORRECT = LS_MESG1
ES_MASTER_DATA_DEFECTIVE = LS_MAIN2
ES_MESSAGE_DEFECTIVE = LS_MESG. *&S3.1get message
LT_MSG = LS_MESG-MESSAGES.
LT_GET[] = LS_MAIN1-CUSTOMERS.
*&S3..get return:
LOOP AT LT_MSG INTO LWA_MSG WHERE TYPE = 'E' OR TYPE = 'A'.
EX_TYPE = 'E'.
EX_MSG = LWA_MSG-MESSAGE.
ENDLOOP.
*&S3..成功commit work
IF EX_TYPE NE 'E'.
COMMIT WORK.
READ TABLE LT_GET INTO LWA_GET INDEX .
*&S3.3Get custmer
EX_VALUE = LWA_GET-HEADER-OBJECT_INSTANCE-KUNNR.
IN_DATA-KUNNR = LWA_GET-HEADER-OBJECT_INSTANCE-KUNNR.
EX_TYPE = 'S'.
EX_MSG = '新增客户成功!'.
*&bdc 写联系人
PERFORM BDC_DYNPRO USING 'SAPMF02D' ''.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RF02D-D0360'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RF02D-KUNNR'
IN_DATA-KUNNR.
PERFORM BDC_FIELD USING 'RF02D-D0360'
'X'. "RECORD-D0360_002.
PERFORM BDC_DYNPRO USING 'SAPMF02D' ''.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'KNVK-TELF1(01)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
* PERFORM BDC_FIELD USING 'KNVK-ANRED(01)'
* RECORD-ANRED_01_003.
* PERFORM BDC_FIELD USING 'KNVK-NAMEV(01)'
* RECORD-NAMEV_01_004.
PERFORM BDC_FIELD USING 'KNVK-NAME1(01)'
IN_DATA-NAME1."RECORD-NAME1_01_005.
PERFORM BDC_FIELD USING 'KNVK-TELF1(01)'
IN_DATA-TELF1."RECORD-TELF1_01_006.
PERFORM BDC_DYNPRO USING 'SAPMF02D' ''.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'KNVK-ABTNR(01)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING 'KNVK-ABTNR(01)'
'=ENTR'."RECORD-ABTNR_01_007.
PERFORM BDC_DYNPRO USING 'SAPMF02D' ''.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'KNVK-NAMEV(01)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=UPDA'.
* PERFORM BDC_TRANSACTION USING 'XD02'.
CALL TRANSACTION 'XD02' USING BDCDATA MODE 'N' MESSAGES INTO IT_MESSAGE.
CLEAR BDCDATA.
WAIT UP TO SECONDS. READ TABLE IT_MESSAGE WITH KEY MSGTYP = 'E'.
IF SY-SUBRC EQ .
EX_TYPE = 'W'.
EX_MSG = '供应商联系人信息创建失败!'.
ENDIF.
*&S3..error 则rollback.
ELSE.
ROLLBACK WORK.
ENDIF. ENDLOOP. ENDFUNCTION.

ABAP-创建客户的更多相关文章

  1. 【ABAP系列】SAP ABAP 利用class创建客户/供应商主数据

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP ABAP 利用class创建 ...

  2. 批量创建客户主数据函数SD_CUSTOMER_MAINTAIN_ALL

    分享一下批创建客户主数据函数:SD_CUSTOMER_MAINTAIN_ALL TABLES:T077D,ZCITY,T005S,BNKA,ADRC,KNA1.  DATA: TMP_KTOKD(4) ...

  3. Java操作ElasticSearch之创建客户端连接

    Java操作ElasticSearch之创建客户端连接 3 发布时间:『 2017-09-11 17:02』  博客类别:elasticsearch  阅读(3157) Java操作ElasticSe ...

  4. 【MM系列】SAP S/4 HANA BP创建客户/供应商的一点想法

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP S/4 HANA BP创建客 ...

  5. ABAP 创建和调用WebService

    1.创建WebService ① SE37创建RFC函数 ② SE80创建企业服务-service provider-existing ABAP object 或SE37-实用程序-创建Web服务 ③ ...

  6. ABAP 创建function model 返回参数为内表类型

    1:通过T-CODE  se11  创建一个structure   ZSTRU2. 2:   创建一个table type, 表名 ZTAB1. 3: 表的row type 选择 ZSTRU2 4: ...

  7. ABAP 创建测试文件

    使用 CG3Y 下载,可以改成下载txt到本地. FORM CREATE_TESTFILE. ), L_OFF LIKE SY-TABIX, L_LEN LIKE SY-TABIX, L_SUM LI ...

  8. ABAP开发顾问必备:SAP ABAP开发技术总结

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  9. ABAP开发顾问必备:SAP ABAP开发技术总结[转载]

    转载自SAP师太技术博客,原文链接:http://www.cnblogs.com/jiangzhengjun/p/4260224.html 在原文上增加了链接,此文及此文的链接版权都归SAP师太所有. ...

  10. SAP CRM 客户控制器与数据绑定

    当用户从视图离开时,视图将失去它的数据.解决这个问题,需要引入客户控制器(Custom Controller)(译者注:SAP CRM客户端中,不同地方的Custom Controller会翻译为“客 ...

随机推荐

  1. Android 控件架构与自定义控件详解

    架构: PhoneWindow 将一个 DecorView 设置为整个应用窗口的根 View,这里面所有 View 的监听事件,都通过 WindowManagerService 来接收.DecorVi ...

  2. php正则表达式取子字符串及替换

    最近在学习如何用php编写cms,想把文章中的第一个图片提取出来当做缩略图显示到前面,想到的方法就是把文章内容作为一个大字符串,然后用正则表达式找出匹配出第一次出现<img src=" ...

  3. python的安全插件

    1.PyFuzz (0.1.3)                                                         - Simple fuzz testing for u ...

  4. 谈谈ssrf

    一.ssrf,全称:Server-Side-Request-Forgery服务端请求伪造 二.我们正常发出的请求都是经过我们的浏览器,由我们自己的电脑发出的:而存在ssrf的目标网站,我们输入某个网址 ...

  5. 将输入流InputStream转换为String

    public static String convertStreamToString(InputStream is) { /* * To convert the InputStream to Stri ...

  6. 同步数据库数据到ES中代码

    多节点部署保证HA,分布式锁代码 public class DistributedLock implements Watcher,Runnable{ private static final Logg ...

  7. IntelliJ IDEA创建文件时自动填入作者时间 定制格式

    IntelliJ IDEA创建文件时自动填入作者时间 定制格式 学习了:https://blog.csdn.net/Hi_Boy_/article/details/78205483 学习了:http: ...

  8. AAuto无法关闭CMD窗口怎么办

    如下图所示,当执行了io.print函数之后,打开的CMD窗口无法使用关闭按钮关闭,其实只要点击左上角的控制台,把钩去掉,该窗口即可关闭.

  9. deeplearning.net 0.1 document - Multilayer Perceptron

    Multilayer Perceptron 以下我们使用Theano来介绍一下单隐藏层的多层感知机(MLP).MLP能够看成一个logistic回归分类器,它使用一个已经学习的非线性转换器处理输入.这 ...

  10. xml.etree.ElementTree模块的封装

    转载:https://www.cnblogs.com/hongten/p/hongten_python_xml_etree_elementtree.html 1 # -*- coding: utf-8 ...