CRM创建BP(END USER)详解编程语言

FUNCTION ZCRM_BP_CRT. 
*"---------------------------------------------------------------------- 
*"*"Local Interface: 
*"  IMPORTING 
*"     REFERENCE(PHONE) TYPE  BAPIADTEL-TELEPHONE OPTIONAL 
*"     REFERENCE(MOBIL) TYPE  BAPIADTEL-TELEPHONE OPTIONAL 
*"     REFERENCE(FIRSTNAME) TYPE  BAPIBUS1006_CENTRAL_PERSON-FIRSTNAME 
*"       OPTIONAL 
*"     REFERENCE(LASTNAME) TYPE  BAPIBUS1006_CENTRAL_PERSON-LASTNAME 
*"       OPTIONAL 
*"     REFERENCE(CITY) TYPE  BAPIBUS1006_ADDRESS-CITY OPTIONAL 
*"     REFERENCE(COUNTRY) TYPE  BAPIBUS1006_ADDRESS-COUNTRY OPTIONAL 
*"     REFERENCE(DISTRICT) TYPE  AD_CITY2 OPTIONAL 
*"     REFERENCE(STREET) TYPE  BAPIBUS1006_ADDRESS-STREET OPTIONAL 
*"     REFERENCE(HOUSE_NO) TYPE  BAPIBUS1006_ADDRESS-HOUSE_NO OPTIONAL 
*"     REFERENCE(POSTCODE) TYPE  BAPIBUS1006_ADDRESS-POSTL_COD1 
*"       OPTIONAL 
*"     REFERENCE(REGION) TYPE  BAPIBUS1006_ADDRESS-REGION OPTIONAL 
*"     REFERENCE(TEL_EXTENS) TYPE  AD_TLXTNS OPTIONAL 
*"     REFERENCE(FAX_NUMBER) TYPE  AD_FXNMBR OPTIONAL 
*"     REFERENCE(FAX_EXTENS) TYPE  AD_FXXTNS OPTIONAL 
*"     REFERENCE(DEFLT_COMM) TYPE  AD_COMM OPTIONAL 
*"     REFERENCE(TITLE_LET) TYPE  BU_TITLE_LET OPTIONAL 
*"     REFERENCE(SMTP_ADDR) TYPE  AD_SMTPADR OPTIONAL 
*"     REFERENCE(BU_TYPE) TYPE  BU_TYPE DEFAULT '1' 
*"     REFERENCE(TITLE) TYPE  AD_TITLE OPTIONAL 
*"     REFERENCE(BU_SORT1) TYPE  BU_SORT1 OPTIONAL 
*"     REFERENCE(TIME_ZONE) TYPE  AD_TZONE OPTIONAL 
*"     REFERENCE(IV_ZA_FLAG) TYPE  ZCORDER_GENERAL-ZA_FLAG OPTIONAL 
*"     REFERENCE(IV_LAND) TYPE  LAND1 OPTIONAL 
*"     REFERENCE(IV_STR_SUPPL1) TYPE  AD_STRSPP1 OPTIONAL 
*"     REFERENCE(IV_STR_SUPPL2) TYPE  AD_STRSPP2 OPTIONAL 
*"     REFERENCE(IV_ZZBUILDING_TYPE) TYPE  ZBUILDING_TYPE_E OPTIONAL 
*"     REFERENCE(IV_ZZMKT_USAGE) TYPE  ZMKT_USAGE_E OPTIONAL 
*"     REFERENCE(IV_FLOOR) TYPE  AD_FLOOR OPTIONAL 
*"     REFERENCE(IV_ZZACCESS_CODE) TYPE  ZACCESS_CODE_E OPTIONAL 
*"     REFERENCE(IV_NAMEORG1) TYPE  BU_NAMEOR1 OPTIONAL 
*"     REFERENCE(SALES_ORG) TYPE  CRMT_SALES_ORG OPTIONAL 
*"  EXPORTING 
*"     REFERENCE(BP_NUMBER) TYPE  BU_PARTNER 
*"  TABLES 
*"      RETURN STRUCTURE  BAPIRET2 
*"---------------------------------------------------------------------- 
TYPES:BEGIN OF TY_BP_DATA, 
PARTNER              TYPE BUT000-PARTNER,                          "0. 
SEQNO                TYPE NUM10, 
PARTNERCATEGORY      TYPE BAPIBUS1006_HEAD-PARTN_CAT,      "-1 
PARTNERROLE          TYPE BAPIBUS1006_BPROLES-PARTNERROLE,    "角色 
PARTN_GRP            TYPE BAPIBUS1006_HEAD-PARTN_GRP, 
TITLE_KEY            TYPE BAPIBUS1006_CENTRAL-TITLE_KEY, 
FIRSTNAME            TYPE BAPIBUS1006_CENTRAL_PERSON-FIRSTNAME, 
LASTNAME             TYPE BAPIBUS1006_CENTRAL_PERSON-LASTNAME, 
CITY                 TYPE BAPIBUS1006_ADDRESS-CITY, 
COUNTRY              TYPE BAPIBUS1006_ADDRESS-COUNTRY,       " 4.注册地址-国家 
REGION               TYPE BAPIBUS1006_ADDRESS-REGION,               " 5.注册地址-地区 
TELEPHONE            TYPE BAPIADTEL-TELEPHONE,                   "15.电话 
MOBIL                TYPE BAPIADTEL-TELEPHONE, 
E_MAIL               TYPE BAPIADSMTP-E_MAIL, 
NAME1                TYPE BAPIBUS1006_CENTRAL_ORGAN-NAME1, 
NAME2                TYPE BAPIBUS1006_CENTRAL_ORGAN-NAME2, 
STREET               TYPE BAPIBUS1006_ADDRESS-STREET, 
LANGU                TYPE BAPIBUS1006_ADDRESS-LANGU, 
SALES_ORGANIZATION   TYPE BAPIBUS1006_SALES_AREA-SALES_ORGANIZATION, " 19.销售组织标识 
DISTRIBUTION_CHANNEL TYPE BAPIBUS1006_SALES_AREA-DISTRIBUTION_CHANNEL, " 20.分销渠道 
DIVISION             TYPE BAPIBUS1006_SALES_AREA-DIVISION,        " 21.部门 
SALES_OFFICE         TYPE BAPIBUS1006140_ORG-SALES_OFFICE,    " 22.销售部门 
SALES_GROUP          TYPE BAPIBUS1006140_ORG-SALES_GROUP,      " 23.销售组 
CUST_PRIC_PROC       TYPE BAPIBUS1006030_PRICING-CUST_PRIC_PROC, "客户定价程序 
END OF TY_BP_DATA. 
DATA:T_BP_DATA TYPE TABLE OF TY_BP_DATA, 
W_BP_DATA LIKE LINE OF T_BP_DATA. 
DATA: 
LT_BAPIRET2     TYPE TABLE OF BAPIRET2, 
LV_PARTNER_GUID TYPE  BU_PARTNER_GUID, 
LS_EEWB         TYPE          BUS000_EEW, 
LS_EEWB_X       TYPE          BUS000_EEW_X. 
DATA LW_CENTRALDATA TYPE BAPIBUS1006_CENTRAL. 
DATA LW_CENTRALDATAPERSON TYPE BAPIBUS1006_CENTRAL_PERSON. 
DATA LW_ADDRESSDATA TYPE BAPIBUS1006_ADDRESS. 
DATA LT_TELEFONDATA TYPE STANDARD TABLE OF BAPIADTEL WITH HEADER LINE. 
DATA LT_FAXDATA TYPE STANDARD TABLE OF BAPIADFAX WITH HEADER LINE. 
DATA LT_E_MAILDATA  TYPE STANDARD TABLE OF BAPIADSMTP WITH HEADER LINE. 
DATA LT_BUSINESSPARTNERROLE TYPE STANDARD TABLE OF BAPIBUS1006_BPROLES WITH HEADER LINE. 
DATA LT_RETURN TYPE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE. 
DATA: L_FAIL TYPE C. 
DATA LW_CENTRALDATAORGANIZATION TYPE BAPIBUS1006_CENTRAL_ORGAN. 
DATA LW_SALES_AREA  TYPE BAPIBUS1006_SALES_AREA. 
DATA LW_SALES_ORG   TYPE BAPIBUS1006140_ORG. 
DATA LW_SALES_CLASS TYPE BAPIBUS1006040_SALESCLASS. 
DATA LW_SALES_CLASSX TYPE BAPIBUS1006040_SALESCLASSX. 
DATA LW_SALES_BILL  TYPE BAPIBUS1006030_PRICING. 
DATA LW_SALES_SHIPPING TYPE BAPIBUS1006020_SHIPPING. 
W_BP_DATA-FIRSTNAME       = FIRSTNAME. 
W_BP_DATA-LASTNAME        = LASTNAME. 
W_BP_DATA-TELEPHONE       = PHONE. 
W_BP_DATA-MOBIL           = MOBIL. 
W_BP_DATA-CITY            = CITY. 
W_BP_DATA-COUNTRY         = COUNTRY. 
LW_CENTRALDATA-TITLELETTER     = TITLE_LET. 
LW_CENTRALDATA-TITLE_KEY       = TITLE."add by dq-yuw 20170920 
IF BU_TYPE = '1'. 
LW_CENTRALDATAPERSON-LASTNAME  = W_BP_DATA-LASTNAME. 
LW_CENTRALDATAPERSON-FIRSTNAME = W_BP_DATA-FIRSTNAME. 
LW_CENTRALDATAPERSON-CORRESPONDLANGUAGE = 'E'. 
*    lw_centraldata-title_key       = title."change by dq-yuw:这里应该是个BUG,创建公司客户也可以有tittle,这里把他放到上面去 
ELSEIF  BU_TYPE = '2'. 
"add by dq-yuw 之前本来就错的吧,写反了应该,法国和日本先给他改过来 
IF COUNTRY EQ 'JP'"日本创建客户时name org1就是页面上lastname字段 
OR COUNTRY EQ 'FR'." 
      LW_CENTRALDATAORGANIZATION-NAME1 = W_BP_DATA-LASTNAME. 
LW_CENTRALDATAORGANIZATION-NAME2 = W_BP_DATA-FIRSTNAME. 
ELSE. 
LW_CENTRALDATAORGANIZATION-NAME1 = W_BP_DATA-FIRSTNAME. 
LW_CENTRALDATAORGANIZATION-NAME2 = W_BP_DATA-LASTNAME. 
ENDIF. 
"法国创建公司客户的时候用页面上的company name 
IF COUNTRY EQ 'FR' OR ZCL_CRM_BUFFER=>GV_UI_LOGIN_ORG EQ 'O 50000297'."法国 
*      CLEAR: lw_centraldataorganization-name1,lw_centraldataorganization-name2. 20171019 需求 取消该逻辑 
LW_CENTRALDATAORGANIZATION-NAME1 = IV_NAMEORG1. 
LW_CENTRALDATAORGANIZATION-NAME3 = W_BP_DATA-LASTNAME."20171019 需求 Last Name 借用 Org3 字段 
ENDIF. 
LW_ADDRESSDATA-LANGU  = 'E'. 
LW_CENTRALDATA-SEARCHTERM1  = BU_SORT1. 
ENDIF. 
LW_ADDRESSDATA-COUNTRY = W_BP_DATA-COUNTRY. 
LW_ADDRESSDATA-CITY    = W_BP_DATA-CITY. 
LW_ADDRESSDATA-STREET    = STREET. 
LW_ADDRESSDATA-STR_SUPPL1    = IV_STR_SUPPL1."add by dq-yuw for japan 
LW_ADDRESSDATA-STR_SUPPL2    = IV_STR_SUPPL2."add by dq-yuw for FRANCE 
LW_ADDRESSDATA-DISTRICT  = DISTRICT. 
LW_ADDRESSDATA-HOUSE_NO    = HOUSE_NO. 
LW_ADDRESSDATA-POSTL_COD1    = POSTCODE. 
LW_ADDRESSDATA-REGION    = REGION. 
LW_ADDRESSDATA-FLOOR = IV_FLOOR."20170718 Add Chenguoguang 
LW_ADDRESSDATA-COMM_TYPE = DEFLT_COMM. 
LW_ADDRESSDATA-TIME_ZONE = TIME_ZONE. 
IF W_BP_DATA-TELEPHONE IS NOT INITIAL. 
CLEAR LT_TELEFONDATA. 
LT_TELEFONDATA-COUNTRY = W_BP_DATA-COUNTRY. 
LT_TELEFONDATA-TELEPHONE = W_BP_DATA-TELEPHONE. 
LT_TELEFONDATA-R_3_USER = '1'. 
LT_TELEFONDATA-EXTENSION = TEL_EXTENS. 
APPEND LT_TELEFONDATA. 
ENDIF. 
IF W_BP_DATA-MOBIL IS NOT INITIAL. 
CLEAR LT_TELEFONDATA. 
LT_TELEFONDATA-COUNTRY = W_BP_DATA-COUNTRY. 
LT_TELEFONDATA-TELEPHONE = W_BP_DATA-MOBIL. 
LT_TELEFONDATA-R_3_USER = '3'. 
APPEND LT_TELEFONDATA. 
ENDIF. 
IF FAX_NUMBER IS NOT INITIAL. 
LT_FAXDATA-FAX       = FAX_NUMBER. 
LT_FAXDATA-EXTENSION = FAX_EXTENS. 
APPEND LT_FAXDATA. 
ENDIF. 
IF SMTP_ADDR IS NOT INITIAL. 
LT_E_MAILDATA-E_MAIL = SMTP_ADDR. 
APPEND LT_E_MAILDATA. 
ENDIF. 
*默认为客户 
LW_SALES_CLASS-IS_CUSTOMER = 'X'. 
LW_SALES_CLASSX-IS_CUSTOMER = 'X'. 
*装运 
IF COUNTRY = 'ES'. 
LW_SALES_SHIPPING-SHIPPING_COND = '03'. 
ELSE. 
LW_SALES_SHIPPING-SHIPPING_COND = '01'. 
ENDIF. 
LW_SALES_SHIPPING-DLV_PRIORITY = 1. 
*根据国家信息在表ZBP_SALES里取出相关信息 
DATA: IT_BP_SALES TYPE STANDARD TABLE OF ZBP_SALES, 
WA_BP_SALES TYPE ZBP_SALES. 
SELECT SINGLE * 
FROM ZBP_SALES 
INTO WA_BP_SALES 
WHERE COUNTRY = COUNTRY. 
*  ENDIF. 
IF sales_org IS NOT INITIAL."add by ly 20180803 
SELECT SINGLE * 
FROM ZBP_SALES 
INTO WA_BP_SALES 
WHERE COUNTRY = COUNTRY 
AND SALES_ORG = SALES_ORG. 
ENDIF. 
"add by dq-yuw request by zhangchi 
"集中建单平台创建客户时,根据客户地址中的国家 = ZBP_SALES-COUNTRY & 当前登录用户的销售组织 = ZBP_SALES-SALES_ORG,来查找ZBP_SALES表中的数据, 
"以确定创建客户的BP分组和销售组织等数据。 
IF ZCL_CRM_ATTRIBUTES=>GV_WEB_UI_LOGON = ABAP_TRUE.. 
DATA LV_SALES_ORG TYPE CRMT_SALES_ORG. 
CALL FUNCTION 'Z_GET_SALESORG_BY_USER' 
EXPORTING 
IV_USER      = SY-UNAME 
IMPORTING 
EV_SALES_ORG = LV_SALES_ORG 
*       EV_COUNTRY   = 
*       EV_HQ        = 
      . 
IF LV_SALES_ORG <> 'O 50000192' AND LV_SALES_ORG <> 'O 50000194'. 
SELECT SINGLE * 
FROM ZBP_SALES 
INTO WA_BP_SALES 
WHERE COUNTRY = COUNTRY 
AND SALES_ORG = LV_SALES_ORG. 
ENDIF. 
ENDIF. 
* 销售视图 
LW_SALES_AREA-SALES_ORGANIZATION   = WA_BP_SALES-SALES_ORG. 
LW_SALES_AREA-DISTRIBUTION_CHANNEL = WA_BP_SALES-CHANNEL. 
*    lw_sales_area-division             = wa_bp_sales-division. 
LW_SALES_ORG-SALES_OFFICE          = WA_BP_SALES-SALES_OFFICE. 
*    lw_sales_org-sales_group           = wa_bp_sales-sales_group. 
* 定价程序 
LW_SALES_BILL-PRICE_GROUP = WA_BP_SALES-PRICE_GROUP. 
LW_SALES_BILL-CURRENCY    = WA_BP_SALES-CURRENCY. 
LW_SALES_BILL-CUST_PRIC_PROC = 'X'. 
CLEAR:L_FAIL. 
CALL FUNCTION 'BAPI_BUPA_CREATE_FROM_DATA' 
EXPORTING 
PARTNERCATEGORY         = BU_TYPE 
PARTNERGROUP            = WA_BP_SALES-BU_GROUP 
*     partnergroup            = w_bp_data-partn_grp 
CENTRALDATAORGANIZATION = LW_CENTRALDATAORGANIZATION 
CENTRALDATA             = LW_CENTRALDATA 
CENTRALDATAPERSON       = LW_CENTRALDATAPERSON 
ADDRESSDATA             = LW_ADDRESSDATA 
IMPORTING 
BUSINESSPARTNER         = W_BP_DATA-PARTNER 
TABLES 
TELEFONDATA             = LT_TELEFONDATA 
FAXDATA                 = LT_FAXDATA 
E_MAILDATA              = LT_E_MAILDATA 
RETURN                  = LT_RETURN. 
LOOP AT LT_RETURN WHERE TYPE = 'A' OR TYPE = 'E'. 
L_FAIL = 'X'. 
APPEND LT_RETURN TO RETURN[]. 
CLEAR LT_RETURN. 
ENDLOOP. 
IF L_FAIL = 'X'. 
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. 
ELSE. 
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' 
EXPORTING 
WAIT = 'X'. 
ENDIF. 
CHECK L_FAIL IS INITIAL. 
CHECK W_BP_DATA-PARTNER IS NOT INITIAL. 
BP_NUMBER = W_BP_DATA-PARTNER. 
*返回创建好的bp号码 
CLEAR LT_RETURN. 
LT_RETURN-TYPE = 'S'. 
LT_RETURN-MESSAGE = W_BP_DATA-PARTNER. 
APPEND LT_RETURN TO RETURN[]. 
*角色 
CALL FUNCTION 'BAPI_BUPA_ROLE_ADD_2' 
EXPORTING 
BUSINESSPARTNER     = W_BP_DATA-PARTNER 
BUSINESSPARTNERROLE = 'CRM000' 
VALIDFROMDATE       = '00010101' 
VALIDUNTILDATE      = '99991231' 
TABLES 
RETURN              = LT_RETURN. 
LOOP AT LT_RETURN WHERE TYPE = 'E' OR TYPE = 'A' . 
L_FAIL = 'X'. 
ENDLOOP. 
IF L_FAIL = 'X'. 
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. 
ELSE. 
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' 
EXPORTING 
WAIT = 'X'. 
ENDIF. 
CHECK L_FAIL IS INITIAL. 
*税分类 
IF  WA_BP_SALES-COUNTRY IS NOT INITIAL AND 
WA_BP_SALES-TAX_TYPE IS NOT INITIAL AND 
WA_BP_SALES-TAX_GROUP IS NOT INITIAL. 
CLEAR L_FAIL. 
DATA: L_TAXREGION TYPE BAPIBUS1006_TAX_CLASS-TAXREGION. 
CALL FUNCTION 'BAPI_BUTX_FRG0010_ADD' 
EXPORTING 
BUSINESSPARTNER = W_BP_DATA-PARTNER 
TAXCOUNTRY      = WA_BP_SALES-COUNTRY 
TAXREGION       = L_TAXREGION 
TAXTYPE         = WA_BP_SALES-TAX_TYPE 
DATA            = WA_BP_SALES-TAX_GROUP 
TABLES 
RETURN          = LT_RETURN. 
ENDIF . 
LOOP AT LT_RETURN WHERE TYPE = 'E' OR TYPE = 'A' . 
L_FAIL = 'X'. 
ENDLOOP. 
IF L_FAIL = 'X'. 
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. 
ELSE. 
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' 
EXPORTING 
WAIT = 'X'. 
ENDIF. 
CLEAR L_FAIL. 
*销售范围 
CALL FUNCTION 'BAPI_BUPA_FRG0010_ADD' 
EXPORTING 
BUSINESSPARTNER = W_BP_DATA-PARTNER 
SALES_AREA      = LW_SALES_AREA 
*     DATA            = 
TABLES 
RETURN          = LT_RETURN. 
LOOP AT LT_RETURN WHERE TYPE = 'E' OR TYPE = 'A' . 
L_FAIL = 'X'. 
APPEND LT_RETURN TO RETURN[]. 
CLEAR LT_RETURN. 
ENDLOOP. 
IF L_FAIL = 'X'. 
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. 
ELSE. 
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' 
EXPORTING 
WAIT = 'X'. 
ENDIF. 
CLEAR L_FAIL. 
*组织 
CALL FUNCTION 'BAPI_BUPA_FRG0140_ADD' 
EXPORTING 
BUSINESSPARTNER = W_BP_DATA-PARTNER 
SALES_AREA      = LW_SALES_AREA 
DATA            = LW_SALES_ORG 
*     DATAX           = 
TABLES 
RETURN          = LT_RETURN. 
LOOP AT LT_RETURN WHERE TYPE = 'E' OR TYPE = 'A' . 
L_FAIL = 'X'. 
APPEND LT_RETURN TO RETURN[]. 
CLEAR LT_RETURN. 
ENDLOOP. 
IF L_FAIL = 'X'. 
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK' . 
ELSE. 
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' 
EXPORTING 
WAIT = 'X'. 
ENDIF. 
CLEAR L_FAIL. 
*开票中的客户定价程序 
CALL FUNCTION 'BAPI_BUPA_FRG0030_ADD' 
EXPORTING 
BUSINESSPARTNER = W_BP_DATA-PARTNER 
SALES_AREA      = LW_SALES_AREA 
DATA            = LW_SALES_BILL 
TABLES 
RETURN          = LT_RETURN. 
LOOP AT LT_RETURN WHERE TYPE = 'E' OR TYPE = 'A' . 
L_FAIL = 'X'. 
APPEND LT_RETURN TO RETURN[]. 
CLEAR LT_RETURN. 
*      WAIT UP TO '0.5' SECONDS. 
ENDLOOP. 
IF L_FAIL = 'X'. 
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. 
ELSE. 
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' 
EXPORTING 
WAIT = 'X'. 
ENDIF. 
CLEAR L_FAIL. 
CALL FUNCTION 'BAPI_BUPA_FRG0040_CREATE' 
EXPORTING 
BUSINESSPARTNER = W_BP_DATA-PARTNER 
DATA            = LW_SALES_CLASS 
*     datax           = lw_sales_classx 
TABLES 
RETURN          = LT_RETURN. 
LOOP AT LT_RETURN WHERE TYPE = 'E' OR TYPE = 'A' . 
L_FAIL = 'X'. 
APPEND LT_RETURN TO RETURN[]. 
CLEAR LT_RETURN. 
*      WAIT UP TO '0.5' SECONDS. 
ENDLOOP. 
IF L_FAIL = 'X'. 
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. 
*    CONTINUE. 
ELSE. 
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' 
EXPORTING 
WAIT = 'X'. 
ENDIF. 
CLEAR L_FAIL. 
CALL FUNCTION 'BAPI_BUPA_FRG0020_ADD' 
EXPORTING 
BUSINESSPARTNER = W_BP_DATA-PARTNER 
SALES_AREA      = LW_SALES_AREA 
DATA            = LW_SALES_SHIPPING 
*     datax           = lw_sales_classx 
TABLES 
RETURN          = LT_RETURN. 
LOOP AT LT_RETURN WHERE TYPE = 'E' OR TYPE = 'A' . 
L_FAIL = 'X'. 
APPEND LT_RETURN TO RETURN[]. 
CLEAR LT_RETURN. 
*      WAIT UP TO '0.5' SECONDS. 
ENDLOOP. 
IF L_FAIL = 'X'. 
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. 
*    CONTINUE. 
ELSE. 
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' 
EXPORTING 
WAIT = 'X'. 
ENDIF. 
DEFINE EEW. 
IF &1 is NOT INITIAL. 
&2 = &1. 
&3 = 'X'. 
ENDIF. 
END-OF-DEFINITION. 
**&----增强字段(网点) 
CLEAR:LS_EEWB_X,LS_EEWB. 
SELECT SINGLE PARTNER_GUID 
INTO LV_PARTNER_GUID 
FROM BUT000 
WHERE PARTNER =  W_BP_DATA-PARTNER. 
IF SY-SUBRC = 0. 
LS_EEWB-PARTNR_GUID = LV_PARTNER_GUID. 
EEW IV_ZZBUILDING_TYPE LS_EEWB-ZZBUILDING_TYPE LS_EEWB_X-ZZBUILDING_TYPE. 
EEW IV_ZZMKT_USAGE LS_EEWB-ZZMKT_USAGE LS_EEWB_X-ZZMKT_USAGE. 
EEW IV_ZZACCESS_CODE LS_EEWB-ZZACCESS_CODE LS_EEWB_X-ZZACCESS_CODE. 
REFRESH:LT_RETURN, LT_BAPIRET2. 
CALL FUNCTION 'BUPA_CENTRAL_CI_CHANGE' 
EXPORTING 
IS_BUS000_EEW   = LS_EEWB 
IS_BUS000_EEW_X = LS_EEWB_X 
IMPORTING 
ET_RETURN       = LT_BAPIRET2. 
APPEND LINES OF LT_BAPIRET2 TO LT_RETURN. 
LOOP AT LT_RETURN WHERE TYPE = 'E' OR TYPE = 'A' . 
L_FAIL = 'X'. 
APPEND LT_RETURN TO RETURN[]. 
CLEAR LT_RETURN. 
*      WAIT UP TO '0.5' SECONDS. 
ENDLOOP. 
IF L_FAIL = 'X'. 
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. 
*    CONTINUE. 
ELSE. 
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' 
EXPORTING 
WAIT = 'X'. 
ENDIF. 
ENDIF. 
ENDFUNCTION.

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/18691.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论