Académique Documents
Professionnel Documents
Culture Documents
Master Data
Extending the Material Master BDoc (Word version of Robert Kuhn's
document)
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.
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
Create Function module for mapping. Function Module Z_SEND_PROD_TO_CRM handles mapping the
custom fields to be transferred to the CRM system. Here is an example of the code needed
FM Attributes
Import Parameters
Export Parameters
Changing Parameters
Tables
Sample Code
FUNCTION Z_SEND_PROD_TO_CRM.
*"---------------------------------------------------------------------*"*"Local Interface:
*" IMPORTING
*" REFERENCE(I_OBJ_CLASS) LIKE BAPICRMOBJ-OBJCLASS
* 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.
<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.
EXCEPTIONS
OTHERS = 5.
MOVE-CORRESPONDING ls_marc TO ls_com_data2.
t_other_info-field3 = ls_com_data2.
APPEND t_other_info.
ENDLOOP.
WHEN 'LEDELIVERY'.
*t_int_tables
LOOP AT T_BAPISTRUCT WHERE tabname = 'BAPISDCOND'.
ASSIGN T_BAPISTRUCT-data TO <ledsource_x> CASTING.
ASSIGN ls_BAPISDCOND TO <ledtarget_x> CASTING.
IF <ledsource_x> IS ASSIGNED AND
<ledtarget_x> IS ASSIGNED.
*Following will pass data from T_BAPISTRUCT-data to ls_BAPISDCOND
*Both are having separate memory areas.
<ledtarget_x> = <ledsource_x>.
ELSE.
CONTINUE.
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:
a.
b.
c.
d.
e.
f.
g.
h.
i.
j.
2)
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
a.
b.
c.
d.
e.
f.
g.
h.
i.
j.
NOTE:
If you make changes to the Set Type, then there is a possibility that the field mappings in BADI
PRODUCT_CUSTOMER2, method MAP_R3_TO_CRM_MATERIAL on the CRM side will have to
be changed. Please check the mappings after a set type change to ensure they are still correct.
Extend the complex data structure of the product master in CRM with the set type ZPORD_XPORT and
thus enable download from ECC into the CRM database.
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.
1)
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.
2)
MAP_R3_TO_CRM_MATERIAL:
METHOD if_ex_product_customer2~map_r3_to_crm_material .
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.
*Getting the info into the Set Types.
DATA: ls_zprod_xport TYPE zprod_xport_maintain,
lv_mara
TYPE bapimatmra,
lv_marc
TYPE bapimatmrc,
is_other_info
TYPE bapiextc,
ls_com_mara
TYPE zprod_struct_mara.
*
ls_com_marc
TYPE zprod_struct_marc.
DATA: BEGIN OF ls_com_marc,
zmfrgr(8),
zladgr(4),
zvbamg(13),
zvrvez(7),
zvbeaz(7),
END OF ls_com_marc.
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.
*Poputate MARA Fields
LOOP AT it_other_info INTO is_other_info
WHERE field1(20) = 'MARA'
AND field1+20(18) = is_mara-material.
ENDLOOP.
2.
3.