Chinaunix首页 | 论坛 | 博客
  • 博客访问: 308533
  • 博文数量: 33
  • 博客积分: 1512
  • 博客等级: 上尉
  • 技术积分: 408
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-29 08:47
个人简介

SAP CRM

文章存档

2015年(6)

2013年(1)

2011年(6)

2009年(5)

2008年(13)

2007年(2)

分类:

2008-04-21 09:01:37

对BP进行增强后(字段扩充)后,如何通过BAPI创建BP

示例代码:

*&---------------------------------------------------------------------*
*& Report  Y_ERIC_CREATE_BP
*&
*&---------------------------------------------------------------------*

REPORT  y_eric_create_bp.

DATA: it_header TYPE bapibus1006_head OCCURS 0 WITH HEADER LINE.
DATA: it_centr  TYPE bapibus1006_central OCCURS 0 WITH HEADER LINE.
DATA: g_bp      LIKE bapibus1006_head-bpartner.
DATA: g_cat     LIKE bapibus1006_head-partn_cat VALUE '1'.
DATA: it_guid   LIKE bus000___i OCCURS 0 WITH HEADER LINE.
DATA: it_custo  LIKE bus000_eew OCCURS 0 WITH HEADER LINE.

DATA: i_centraldataperson LIKE bapibus1006_central_person OCCURS 0 WITH HEADER LINE.
DATA: t_centraldataperson LIKE bapibus1006_central_person OCCURS 0 WITH HEADER LINE.
DATA: i_times             TYPE n LENGTH 3 VALUE 1.

DO 10 TIMES.
  i_centraldataperson-firstname = 'xxxxxxxxxx'.
  CONCATENATE i_centraldataperson-firstname i_times INTO i_centraldataperson-firstname.
  i_centraldataperson-lastname = 'yyyyyyyy'.
  CONCATENATE i_centraldataperson-lastname i_times INTO i_centraldataperson-lastname.
  APPEND i_centraldataperson.
  i_times = i_times + 1.
ENDDO.

LOOP AT i_centraldataperson.
  CLEAR t_centraldataperson.
  REFRESH t_centraldataperson.
  MOVE-CORRESPONDING i_centraldataperson TO t_centraldataperson.
  APPEND t_centraldataperson.

  CALL FUNCTION 'BAPI_BUPA_CREATE_FROM_DATA'
    EXPORTING
      partnercategory   = g_cat
      centraldata       = it_centr
      centraldataperson = t_centraldataperson
    IMPORTING
      businesspartner   = g_bp.

  CALL FUNCTION 'BUP_MEMORY_BUT000_GET'
    EXPORTING
      iv_partner = g_bp
    IMPORTING
      es_but000  = it_guid.

  READ TABLE it_guid INDEX 1.

  CLEAR it_custo.
  REFRESH it_custo.
  it_custo-partnr_guid = it_guid-partner_guid.
  it_custo-zzdate = '20070819'.

  it_custo-zztstfd = '1'.
  APPEND it_custo.


  CALL FUNCTION 'BUPA_CENTRAL_CI_CHANGE'
    EXPORTING
      is_bus000_eew         =  it_custo
*   IS_BUS000_EEW_X       =
*   IV_XSAVE              = 'X'
* IMPORTING
*   ET_RETURN             =
            .


  WRITE: / g_bp.
ENDLOOP.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.  "可以写在loop里面

  • 09:11
  • 浏览 (953)
  • 评论 (1)
  • 分类:
评论
2007-05-22
BAPI的字段对照:
*&---------------------------------------------------------------------*
*& Report Z_R_CREATE_BP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT z_r_create_bp.

DATA: it_header TYPE bapibus1006_head OCCURS 0 WITH HEADER LINE.
DATA: it_centr TYPE bapibus1006_central OCCURS 0 WITH HEADER LINE.
DATA: g_bp LIKE bapibus1006_head-bpartner.
DATA: g_cat LIKE bapibus1006_head-partn_cat VALUE '1'.
DATA: it_guid LIKE bus000___i OCCURS 0 WITH HEADER LINE.
DATA: it_custo LIKE bus000_eew OCCURS 0 WITH HEADER LINE.
DATA: it_addr LIKE bapibus1006_address OCCURS 0 WITH HEADER LINE.
DATA: i_telefondata LIKE bapiadtel OCCURS 0 WITH HEADER LINE.
DATA: i_faxdata LIKE bapiadfax OCCURS 0 WITH HEADER LINE.
DATA: i_e_maildata LIKE bapiadsmtp OCCURS 0 WITH HEADER LINE.
DATA: i_communicationnotes LIKE bapicomrem OCCURS 0 WITH HEADER LINE.


DATA: i_centraldataperson LIKE bapibus1006_central_person OCCURS 0 WITH
HEADER LINE.
DATA: t_centraldataperson LIKE bapibus1006_central_person OCCURS 0 WITH
HEADER LINE.
DATA: i_times TYPE n LENGTH 3 VALUE 1.

DO 1 TIMES.
i_centraldataperson-firstname = 'RXXXXXXXX'.
CONCATENATE i_centraldataperson-firstname i_times INTO
i_centraldataperson-firstname.
i_centraldataperson-lastname = 'RYYYYYYYY'.
CONCATENATE i_centraldataperson-lastname i_times INTO
i_centraldataperson-lastname.
i_centraldataperson-birthname = 'BirthName' . "Birth Name
i_centraldataperson-birthdate = '19890101' . "Birth date
i_centraldataperson-birthplace = 'Shanghai'. "Birth Place
i_centraldataperson-maritalstatus = '1'. "Marital Status
i_centraldataperson-countryorigin = 'CN'. "Country of Origin
* i_centraldataperson-DEATHDATE = '20991231'. "death date
i_centraldataperson-nationality = 'CN'. "NATIONALITY
i_centraldataperson-sex = '2'. "Sex: 0-unknown; 1-female; 2-male
i_centraldataperson-occupation = 'CEO'.
i_centraldataperson-middlename = 'middlename' . "Middle Name
i_centraldataperson-secondname = 'other last name' . "Other Last Name
i_centraldataperson-prefix1 = '0001'. "Name Affix 1 (Key)
i_centraldataperson-prefix2 = '0002'. "Name Affix 2 (Key)
i_centraldataperson-title_aca1 = '0001' . "Academic Title1 (key)
i_centraldataperson-title_aca2 = '0002' . "Academic Title2 (key)
i_centraldataperson-title_sppl = '0001' . "Name supplement (Key)
i_centraldataperson-initials = 'initials'. "Initials
i_centraldataperson-fullname = 'fullname' . "Full Name
i_centraldataperson-namcountry = 'US' . "Country for format
i_centraldataperson-nameformat = '01' . "Special Format
i_centraldataperson-correspondlanguage = 'E' . "Correspondence lang. :E-English ; 1-Chinese

it_centr-partnerlanguage = '1' . "Language: E-English ; 1-Chinese
it_centr-searchterm1 = 'Search1'. "Search Term 1
it_centr-searchterm2 = 'Search2'. "Search Term 2


it_addr-street = 'hubinlu' . "Street
it_addr-house_no = '567878' . "House Number
it_addr-house_no2 = '12345'. "Suppl.
it_addr-city = 'Shanghaici' . "City
it_addr-country = 'CN' . "country
it_addr-region = '020' . " Region
it_addr-postl_cod1 = '123456'. "Postcode
it_addr-building = 'building' . "Building
it_addr-room_no = '1106'. "Room
it_addr-floor = '9' . "Floor
it_addr-c_o_name = 'c/o name'. "c/o
it_addr-str_suppl1 = 'Street2'. "Street2
it_addr-str_suppl2 = 'Street3'. "Street3
it_addr-str_suppl3 = 'Street4'. "Street4
it_addr-location = 'Street5'. "Street 5
it_addr-district = 'District'. "District
it_addr-taxjurcode = ''. "Taxjurcode
it_addr-dont_use_s = '0001'. "Street Address Undeliverale
* it_addr-TRANSPZONE = ''. "Transportation zone
* it_addr-REGIOGROUP = ''. "REGIOGROUP
it_addr-po_box = 'pobox'. "PO Box
it_addr-po_w_o_no = ' '. "PO w/o number flag
it_addr-postl_cod2 = '12345'. "Postal Code
it_addr-po_box_cit = 'new york'. "other city
it_addr-pobox_ctry = 'US'. "Other Country
it_addr-po_box_reg = 'NY'. "Other region
it_addr-dont_use_p = '0001'. "PO Box Address Undeliverable
APPEND it_addr.

APPEND it_centr.
APPEND i_centraldataperson.
i_times = i_times + 1.
ENDDO.

************************************************************************
*telephone number *
************************************************************************
i_telefondata-country = ''.
i_telefondata-telephone = '1234567'.
i_telefondata-extension = '110'.
i_telefondata-flg_nouse = ''. "no use flag
APPEND i_telefondata.
************************************************************************
*mobilephone number *
************************************************************************
i_telefondata-country = ''.
i_telefondata-std_no = 'X'.
i_telefondata-r_3_user = 'X'.
i_telefondata-telephone = '12345678'.
i_telefondata-flg_nouse = ''. "no use flag
APPEND i_telefondata.
************************************************************************
*fax number *
************************************************************************
i_faxdata-country = ''.
i_faxdata-fax = '1234567'.
i_faxdata-extension = '119'.
i_faxdata-flg_nouse = ''. "no use flag
APPEND i_faxdata.
************************************************************************
*E-mail Address
**
************************************************************************
i_e_maildata-e_mail = 'abc@abc.com'.
i_e_maildata-flg_nouse = ''. "no use flag
APPEND i_e_maildata.
************************************************************************
*communicationnotes
**
************************************************************************
i_communicationnotes-comm_type = 'INT'.
i_communicationnotes-langu = 'E'.
APPEND i_communicationnotes.

LOOP AT i_centraldataperson.
CLEAR t_centraldataperson.
REFRESH t_centraldataperson.
MOVE-CORRESPONDING i_centraldataperson TO t_centraldataperson.
APPEND t_centraldataperson.

CALL FUNCTION 'BAPI_BUPA_CREATE_FROM_DATA'
EXPORTING
partnercategory = g_cat
centraldata = it_centr
centraldataperson = t_centraldataperson
addressdata = it_addr
IMPORTING
businesspartner = g_bp
TABLES
telefondata = i_telefondata
faxdata = i_faxdata
e_maildata = i_e_maildata
communicationnotes = i_communicationnotes.

CALL FUNCTION 'BUP_MEMORY_BUT000_GET'
EXPORTING
iv_partner = g_bp
IMPORTING
es_but000 = it_guid.

READ TABLE it_guid INDEX 1.

CLEAR it_custo.
REFRESH it_custo.
it_custo-partnr_guid = it_guid-partner_guid.
it_custo-zzdate = '20070819'.

it_custo-zztstfd = '1'.
APPEND it_custo.


CALL FUNCTION 'BUPA_CENTRAL_CI_CHANGE'
EXPORTING
is_bus000_eew = it_custo
* IS_BUS000_EEW_X =
* IV_XSAVE = 'X'
* IMPORTING
* ET_RETURN =
.
*如果要再增加一个address
CALL FUNCTION 'BUPA_ADDRESS_ADD'
EXPORTING
* IV_PARTNER =
iv_partner_guid = it_guid-partner_guid
is_address = it_addr.
* IV_DUPLICATE_MESSAGE_TYPE =
* IV_ACCEPT_ERROR = ' '
* IV_ADDRGUID =
* IV_X_SAVE = 'X'
* IV_CONSIDER_CONSNUMBER_FOR_INS = ' '
* IV_CHECK_ADDRESS = 'X'
* IMPORTING
* EV_ADDRNUMBER =
* EV_ADDRGUID =
* TABLES
* IT_ADTEL =
* IT_ADFAX =
* IT_ADTTX =
* IT_ADTLX =
* IT_ADSMTP =
* IT_ADRML =
* IT_ADX400 =
* IT_ADRFC =
* IT_ADPRT =
* IT_ADSSF =
* IT_ADURI =
* IT_ADPAG =
* IT_ADREM =
* IT_ADCOMREM =
* IT_ADUSE =
* IT_ADDR_COMM_USE =
* ET_ADDR_DUPLICATES =
* ET_RETURN =
.


WRITE: / g_bp.
ENDLOOP.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
阅读(6471) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2008-04-21 09:17:48

1. Call BAPI_BUPA_CREATE_FROM_DATA. It will return you a partner number. Do not commit here. 2. Call BUP_MEMORY_BUT000_GET to get the partner_guid from the buffer memory. Pass the partner number to this function module. It will return you a structure es_but000 which has the partner guid. Do not commit anything. 3. Populate all the custom fields to be passed to the function module BUPA_CENTRAL_CI_CHANGE. Pass the partner guid in the is_bus000_eew-partnr_guid. 4. Call BAPI_TRANSACTION_COM