bdoc extension

Upload: shreeramcrm

Post on 02-Jun-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/11/2019 Bdoc Extension

    1/19

    Description of Problem

    There are several fields in the Material Master of ECC that must be brought over to the ProductMaster in CRM. These fields are currently not supported by the BDOC. To include these fields in theBDOC use the following procedure. In this document Transportation relevant information is replicated

    from ECC to CRM.

    Configuration in ECC for triggering the CRM Middleware download of data

    Configuration Tables TBE24 and TPS34 in ECC must be maintained for triggering the CRMMiddleware download of data from ECC to CRM. In Table TPS34 the Process CRM0_200 containsthe entry for CRM Middleware download of data.

    Activate Customer Product by maintaining table TBE24 using transaction SM30

    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 moduleby maintaining table TPS34 using transactionSM30

  • 8/11/2019 Bdoc Extension

    2/19

    Create Function module for mapping. Function Module Z_SEND_PROD_TO_CRM handles mappingthe custom fields to be transferred to the CRM system. Here is an example of the code needed

    FM Attributes

  • 8/11/2019 Bdoc Extension

    3/19

    Import Parameters

    Export Parameters

  • 8/11/2019 Bdoc Extension

    4/19

    Changing Parameters

    Tables

  • 8/11/2019 Bdoc Extension

    5/19

    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 StructureDATA: BEGIN OF ls_com_key,

    struct(20),matnr(40),

    END OF ls_com_key.

    * Communication structure (additional MARA data)DATA: BEGIN OF ls_com_data1,

  • 8/11/2019 Bdoc Extension

    6/19

  • 8/11/2019 Bdoc Extension

    7/19

  • 8/11/2019 Bdoc Extension

    8/19

    * 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

    = ls_BAPISDCOND.

    ENDLOOP.

    ENDCASE.

    Configuration in CRM for triggering the CRM Middleware download of data

    In order to populate these fields in CRM there are a number of development objects which areneeded in CRM:

    1) Every additional field from the Material Master in ECC must be created as an Attribute inCRM. Use transaction COMM_ATTRSET to create the Attributes for the following fields:

  • 8/11/2019 Bdoc Extension

    9/19

  • 8/11/2019 Bdoc Extension

    10/19

    a. ZMARA_BRGEW - Gross weight - not neededb. ZMARA_NTGEW - Net weight - not neededc. ZMARA_VOLUM - Volume - not neededd. ZMARA_MFRGR - Material Freight Grp (Should be ZMARC_MFRGR)e. ZMARA_TRAGR - Transportation Groupf. ZMARC_LADGR - Loading Groupg. ZMARC_VBAMG - Base Qty. Shipping - not needed for nowh. ZMARC_VRVEZ - Shipping setup time - not needed for nowi. ZMARC_VBEAZ - Shipping processing time - not needed for now

    j. ZMARA_MAGRV - Material Group: Packaging Materials

    2) Set Types must be created to handle all of the Attributes created. Set types can only handle22 Attributes. Create multiple Set Types if needed to handle all of the Attributes. Use transactionCOMM_ATTRSET to create the Attributes for the following Set Types:

  • 8/11/2019 Bdoc Extension

    11/19

    a. ZPROD_XPORT

  • 8/11/2019 Bdoc Extension

    12/19

    This will be the ZZxxxx fields on the BDOC:

  • 8/11/2019 Bdoc Extension

    13/19

    a. ZMARA_BRGEW - Gross weight - ZZ0011

    b. ZMARA_NTGEW - Net weight - ZZ0013c. ZMARA_VOLUM - Volume - ZZ0015d. ZMARA_MFRGR - Material Freight Grp - ZZ0016 (Should be ZMARC_MFRGR)e. ZMARA_TRAGR - Transportation Group - ZZ0017f. ZMARC_LADGR - Loading Group - ZZ0018g. ZMARC_VBAMG - Base Qty. Shipping - ZZ0019h. ZMARC_VRVEZ - Shipping setup time - ZZ0021i. ZMARC_VBEAZ - Shipping processing time - ZZ0022

    j. ZMARA_MAGRV - Material Group: Packaging Materials - ZZ0023

    NOTE:

  • 8/11/2019 Bdoc Extension

    14/19

    If you make changes to the Set Type, then there is a possibility that the field mappingsin BADI PRODUCT_CUSTOMER2, method MAP_R3_TO_CRM_MATERIAL on the CRMside will have to be changed. Please check the mappings after a set type change to ensurethey 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 HierarchyCategory MAT_HALB using transaction COMM_HIERARCHY. See Figure below.

  • 8/11/2019 Bdoc Extension

    15/19

  • 8/11/2019 Bdoc Extension

    16/19

    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 tablesshould have the same field lengths as the table-fields in R/3.

    2) The BADI PRODUCT_CUSTOMER2, method MAP_R3_TO_CRM_MATERIAL willhave all of the code changes needed to map the additional fields to the Set Types inCRM. Use transaction SE18. An Implementation will be created calledZ_PRODUCT_EXT (Used to populate extended product data). We will need to addthe Category MAT_HALB to the Product Master. The Category MAT_HALB has all ofthe Set Types assigned to it which will map all of the custom fields from ECC into theProduct Master in CRM. See Code below.

    MAP_R3_TO_CRM_MATERIAL:METHOD if_ex_product_customer2~map_r3_to_crm_material .

    CONSTANTS:on TYPE comt_boolean VALUE 'X',

  • 8/11/2019 Bdoc Extension

    17/19

    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_guidiv_update_buffer = space

    IMPORTINGet_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_categoriesWITH KEY hierarchy_guid = ls_category-hierarchy_guidTRANSPORTING 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'EXPORTINGiv_category_guid = ls_category-category_guid

    IMPORTINGet_cat_frag_rel = lt_cat_settype_rel

    EXCEPTIONSwrong_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,

  • 8/11/2019 Bdoc Extension

    18/19

    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: TYPE 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'EXPORTINGiv_settype_guid = ls_cat_settype_rel-frgtype_guid

    IMPORTINGes_settype = ls_settype

    EXCEPTIONSnot_found = 1no_import_values = 2no_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 FieldsLOOP 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 CASTING.ASSIGN ls_com_mara TO CASTING.

    IF IS ASSIGNED AND IS ASSIGNED.

    = .

    ELSE.

    CONTINUE.

    ENDIF.

  • 8/11/2019 Bdoc Extension

    19/19

    ls_zprod_xport-data-zz0017 = ls_com_mara-ztragr.ls_zprod_xport-data-zz0023 = ls_com_mara-zmagrv.

    *Populate MARC FieldsASSIGN is_other_info-field3 TO CASTING.

    ASSIGN ls_com_marc TO CASTING.

    IF IS ASSIGNED AND IS ASSIGNED.

    = .

    ELSE.

    CONTINUE.

    ENDIF.

    ls_zprod_xport-data-zz0016 = ls_com_marc-zmfrgr.

    ls_zprod_xport-data-zz0018 = ls_com_marc-zladgr.

    ls_zprod_xport-data-zz0019 = ls_com_marc-zvbamg.ls_zprod_xport-data-zz0021 = ls_com_marc-zvrvez.ls_zprod_xport-data-zz0022 = ls_com_marc-zvbeaz.

    APPEND ls_zprod_xport TO cs_product_bdoc-data-zprod_xport.APPEND ls_settype-frgtype_id TO cs_product_bdoc-data-mnt_settype.

    ENDCASE.

    ENDLOOP.

    Description of how the User Exit is accessed via standard SAP:

    During the Create/Change of a Product Master the Method MAP_R3_TO_CRM_MATERIAL is called

    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.

    Related OSS Notes:

    495196

    Extending BDocs