ABAP-创建客户
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-创建客户的更多相关文章
- 【ABAP系列】SAP ABAP 利用class创建客户/供应商主数据
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP ABAP 利用class创建 ...
- 批量创建客户主数据函数SD_CUSTOMER_MAINTAIN_ALL
分享一下批创建客户主数据函数:SD_CUSTOMER_MAINTAIN_ALL TABLES:T077D,ZCITY,T005S,BNKA,ADRC,KNA1. DATA: TMP_KTOKD(4) ...
- Java操作ElasticSearch之创建客户端连接
Java操作ElasticSearch之创建客户端连接 3 发布时间:『 2017-09-11 17:02』 博客类别:elasticsearch 阅读(3157) Java操作ElasticSe ...
- 【MM系列】SAP S/4 HANA BP创建客户/供应商的一点想法
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP S/4 HANA BP创建客 ...
- ABAP 创建和调用WebService
1.创建WebService ① SE37创建RFC函数 ② SE80创建企业服务-service provider-existing ABAP object 或SE37-实用程序-创建Web服务 ③ ...
- ABAP 创建function model 返回参数为内表类型
1:通过T-CODE se11 创建一个structure ZSTRU2. 2: 创建一个table type, 表名 ZTAB1. 3: 表的row type 选择 ZSTRU2 4: ...
- ABAP 创建测试文件
使用 CG3Y 下载,可以改成下载txt到本地. FORM CREATE_TESTFILE. ), L_OFF LIKE SY-TABIX, L_LEN LIKE SY-TABIX, L_SUM LI ...
- ABAP开发顾问必备:SAP ABAP开发技术总结
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- ABAP开发顾问必备:SAP ABAP开发技术总结[转载]
转载自SAP师太技术博客,原文链接:http://www.cnblogs.com/jiangzhengjun/p/4260224.html 在原文上增加了链接,此文及此文的链接版权都归SAP师太所有. ...
- SAP CRM 客户控制器与数据绑定
当用户从视图离开时,视图将失去它的数据.解决这个问题,需要引入客户控制器(Custom Controller)(译者注:SAP CRM客户端中,不同地方的Custom Controller会翻译为“客 ...
随机推荐
- UIView的任意圆角
今天在做项目的时候,遇到一个问题,grouped类型的tableview 怎么样才能让他们的一个view 其中一个角圆角? 如上图所示,其实我是用UILabel,但是箭头的位置总是尖的不太好看.设置l ...
- Oracle Form's Trigger Tutorial With Sample FMB
Created an Oracle Form to handle specific events / triggers like When-New-Form-Instance, Pre-Insert, ...
- js aop 拦载实现
var run = function(){ //is run } var aopBefore = function(){ //aopBefore } var tmpFn=run; run = func ...
- kohana nginx的配置
kohana nginx的配置 location / { if (!-e $request_filename) { rewrite ^/(.*)$ /index.php? kohana_uri=/$1 ...
- 重读金典------高质量C编程指南(林锐)-------第五章 常量
5.1 为什么需要常量 1)为了便于用户理解,增加程序的可读性. 2)在程序的很多地方都用到同一个常量,用某一个宏常量来定义可以减少错误. 规则:尽可能的使用含义直观明确的常量来表示程序中多次出现的 ...
- npm安装package.json
npm安装package.json时,直接转到当前项目目录下,用命令npm install 或npm install --save-dev安装即可,自动将package.json中的模块安装到node ...
- 【Android】内存卡图片读取器,图库app
上一篇<[Android]读取sdcard卡上的全部图片而且显示,读取的过程有进度条显示>(点击打开链接)在真机上測试非常有问题.常常遇到内存溢出.卡死的情况.由于如今真机上的内存上,2G ...
- layui-概念-入门-总结
layui教程:http://www.dosrun.com/layui/ 获得 Layui你可以在官网首页下载到 Layui 的最新版,也可以通过 GitHub得到Layui的开源包.目前只同步维护这 ...
- Java 嵌套类和内部类演示样例<二>
嵌套类(nested class)是一个在还有一个类或接口内部声明的类. 嵌套类分为两种:静态内部类(static inner class)和非静态嵌套类(non-static nested clas ...
- android 怎样加速./mk snod打包
mm命令高速编译一个模块之后,一般用adb push到手机看效果,假设环境不同意用adb push或模块不常常改.希望直接放到image里,则能够用./mk snod,这个命令只将system文件夹打 ...