Академический Документы
Профессиональный Документы
Культура Документы
Robert Kuhn
Project:
Status:
Initial Document
Updated
2/24/2011
Description of Problem:
There are several fields in the Material Master of ECC that must be brought over to the Product Master in CRM.
These fields are currently not supported by the BDOC. To include these fields in the BDOC use the following
procedure. In this document Transportation relevant information is replicated from ECC to CRM.
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 1
Add the function module that the OPEN_FI function module can find for a Business Transaction Event (BTE) as
an alternative to a standard function module by maintaining table TPS34 using transaction SM30
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 2
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 3
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 4
SAMPLE CODE:
FUNCTION Z_SEND_PROD_TO_CRM.
*"---------------------------------------------------------------------*"*"Local Interface:
*" IMPORTING
*"
REFERENCE(I_OBJ_CLASS) LIKE BAPICRMOBJ-OBJCLASS
*"
REFERENCE(I_OBJ_NAME) LIKE BAPICRMOBJ-OBJ_NAME
*"
REFERENCE(I_BAPICRMDH2) LIKE BAPICRMDH2 STRUCTURE BAPICRMDH2
*"
OPTIONAL
*"
REFERENCE(I_KEYWORD_IN) LIKE CRM_PARA-KEYWORD_IN
*"
REFERENCE(I_CRMRFCPAR) LIKE CRMRFCPAR STRUCTURE CRMRFCPAR
*" EXPORTING
*"
REFERENCE(E_DO_NOT_SEND) LIKE CRM_PARA-XFELD
*" TABLES
*"
T_INT_TABLES STRUCTURE BAPIMTCS
*"
T_BAPISTRUCT STRUCTURE BAPIMTCS
*"
T_MESSAGES STRUCTURE BAPICRMMSG
*"
T_KEY_INFO STRUCTURE BAPICRMKEY
*"
T_BAPIIDLIST STRUCTURE BAPIIDLIST
*"
T_OTHER_INFO STRUCTURE BAPIEXTC
*" CHANGING
*"
REFERENCE(C_BAPICRMDH2) LIKE BAPICRMDH2 STRUCTURE BAPICRMDH2
*"
REFERENCE(C_RFCDEST) LIKE CRMRFCPAR STRUCTURE CRMRFCPAR
*"
REFERENCE(C_OBJNAME) LIKE BAPICRMOBJ-OBJ_NAME
*"---------------------------------------------------------------------DATA: ls_mara
TYPE mara,
ls_marc
TYPE marc.
* Communication Structure
DATA: BEGIN OF ls_com_key,
struct(20),
matnr(40),
END OF ls_com_key.
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 5
* DATA:
*** BEGIN **************************************************************
** ATTENTION: This declaration is needed, to get the right offset for
**
a later assign (to prevent alignment error at statement
**
ASSIGN ... CASTING ...)
* lv_casting
TYPE f,
"#EC NEEDED
**
Never insert a new definition between LV_CASTING and
**
and LS_BAPIMTCS !!!
* ct_bapimtcs
TYPE bapimtcs.
*** END ****************************************************************
**
*
FIELD-SYMBOLS:
<ledsource_x> TYPE BAPISDCOND,
<ledtarget_x> TYPE BAPISDCOND,
<lfs_data> type any.
DATA: gc_condition TYPE tabname30 VALUE 'BAPISDCOND'.
CASE i_obj_name.
WHEN 'MATERIAL'.
* We want to pick up the additional fields from MARA
* Mapping of MARA fields into table t_other_info
LOOP AT t_int_tables WHERE tabname = 'MARA'.
ASSIGN t_int_tables-data TO <source_x> CASTING.
ASSIGN ls_mara TO <target_x> CASTING.
IF <source_x> IS ASSIGNED AND
<target_x> IS ASSIGNED.
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 6
<target_x> = <source_x>.
ELSE.
CONTINUE.
ENDIF.
ls_com_key-struct = 'MARA'.
ls_com_key-matnr = ls_mara-matnr.
MOVE-CORRESPONDING ls_mara TO ls_com_data1.
t_other_info-field1 = ls_com_key.
t_other_info-field2 = ls_com_data1.
APPEND t_other_info.
ENDIF.
ORIGNAL_COST = ls_BAPISDCOND-COND_VALUE.
*As <ledtarget_x> refers to ls_BAPISDCOND memory,
*in debugging, you can see <ledtarget_x>-con_value becomes 5000.
ls_BAPISDCOND-COND_VALUE = '5000'.
*<ledsource_x> refers to data field of header line (workline) of
*internal table T_BAPISTRUCT
*So following will change data field of header line of T_BAPISTRUCT
<ledsource_x> = ls_BAPISDCOND.
ENDLOOP.
ENDCASE.
Every additional field from the Material Master in ECC must be created as an Attribute in CRM. Use
transaction COMM_ATTRSET to create the Attributes for the following fields:
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 8
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 9
2)
i.
j.
Set Types must be created to handle all of the Attributes created. Set types can only handle 22
Attributes. Create multiple Set Types if needed to handle all of the Attributes. Use transaction
COMM_ATTRSET to create the Attributes for the following Set Types:
a. ZPROD_XPORT
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 10
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 11
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 12
j.
Assign all of the Attributes to the Set Types created. Assign each Set Type to the Hierarchy Category
MAT_HALB using transaction COMM_HIERARCHY. See Figure below.
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 13
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 14
3)
If you defined custom fields in ECC you need to create additional structure tables called in CRM. These
tables will match the same table names in ECC. The tables should have the same field lengths as the
table-fields in R/3.
4)
The BADI PRODUCT_CUSTOMER2, method MAP_R3_TO_CRM_MATERIAL will have all of the code
changes needed to map the additional fields to the Set Types in CRM. Use transaction SE18. An
Implementation will be created called Z_PRODUCT_EXT (Used to populate extended product data). We
will need to add the Category MAT_HALB to the Product Master. The Category MAT_HALB has all of the
Set Types assigned to it which will map all of the custom fields from ECC into the Product Master in
CRM. See Code below.
MAP_R3_TO_CRM_MATERIAL:
METHOD if_ex_product_customer2~map_r3_to_crm_material .
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 15
CONSTANTS:
on TYPE comt_boolean VALUE 'X',
off TYPE comt_boolean VALUE ' ',
gc_org_scenario_sales TYPE om_attrscn VALUE 'SALE'.
DATA:
ls_category_bdoc
TYPE comt_prod_cat_rel_maintain,
ls_category
TYPE comt_prod_cat_rel,
lt_categories
TYPE comt_prod_cat_rel_tab,
ls_settype
TYPE comt_settype_ext,
ls_cat_settype_rel
TYPE comt_cat_frag_rel,
lt_cat_settype_rel
TYPE comt_cat_frag_rel_tab,
lt_cat_settype_rel_all TYPE comt_cat_frag_rel_tab.
DATA: ls_marc TYPE /1crmg0/plant_object01,
ls_mvke TYPE /1crmg0/sales_area01.
DATA: ls_comm_category TYPE comm_category,
ls_comm_prprdcatr TYPE comm_prprdcatr.
*- get all categories related to the product from CRM online:
CALL FUNCTION 'COM_PROD_CAT_REL_READ_WITH_PR'
EXPORTING
iv_product_guid = cs_product_bdoc-header-com_product-product_guid
iv_update_buffer = space
IMPORTING
et_set
= lt_categories.
*- add all categories related to the product from BDOC:
LOOP AT cs_product_bdoc-header-categories INTO ls_category_bdoc.
MOVE-CORRESPONDING ls_category_bdoc-data TO ls_category.
READ TABLE lt_categories
WITH KEY hierarchy_guid = ls_category-hierarchy_guid
TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
MODIFY lt_categories FROM ls_category INDEX sy-tabix.
ELSE.
APPEND ls_category TO lt_categories.
ENDIF.
ENDLOOP.
LOOP AT lt_categories INTO ls_category.
*- get category set type relations:
CALL FUNCTION 'COM_CAT_FRAG_REL_READ'
EXPORTING
iv_category_guid = ls_category-category_guid
IMPORTING
et_cat_frag_rel = lt_cat_settype_rel
EXCEPTIONS
wrong_call
=1
OTHERS
= 2.
IF sy-subrc = 0.
APPEND LINES OF lt_cat_settype_rel TO lt_cat_settype_rel_all.
ENDIF.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM lt_cat_settype_rel_all.
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 16
FIELD-SYMBOLS:
<source_x> TYPE x,
<target_x> TYPE x.
LOOP AT lt_cat_settype_rel_all INTO ls_cat_settype_rel.
* - read comc_settype record
CALL FUNCTION 'COM_SETTYPE_READ_SINGLE'
EXPORTING
iv_settype_guid = ls_cat_settype_rel-frgtype_guid
IMPORTING
es_settype
= ls_settype
EXCEPTIONS
not_found
=1
no_import_values = 2
no_text_found = 3.
IF sy-subrc NE 0 .
* - some message would go here...
CONTINUE.
ENDIF.
CASE ls_settype-frgtype_id.
WHEN 'ZPROD_XPORT'.
ls_zprod_xport-relation-owner = on.
ls_zprod_xport-relation-logsys =
cs_product_bdoc-header-com_product-logsys.
*Polutate MARA Fields
LOOP AT it_other_info INTO is_other_info
WHERE field1(20) = 'MARA'
AND field1+20(18) = is_mara-material.
ENDLOOP.
ASSIGN is_other_info-field2 TO <source_x> CASTING.
ASSIGN ls_com_mara
TO <target_x> CASTING.
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 17
=
=
=
=
=
ls_com_marc-zmfrgr.
ls_com_marc-zladgr.
ls_com_marc-zvbamg.
ls_com_marc-zvrvez.
ls_com_marc-zvbeaz.
Testing:
1. Create a new material in ECC.
2. BDOC is automatically created at time of save and sent to CRM.
3. Product is automatically created in CRM from BDOC.
495196
/var/www/apps/conversion/tmp/scratch_1/325980299.doc
Page 19