Skip to Content

This blog will give an overview of moving standard ECC fields such as rev level , military indicator etc   to SRM (  as custom fields ) .

1.Configuration in ECC for triggering the SRM MIDDLEWARE download of data

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

     Activate Customer Product by maintaining table TBE24 using transaction SM30

TBE24.png

TBE24 entry.png

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


TPS34.png


TPS34 entry.png

Create Function module for mapping

Function Module Z_CUSTOMAEOI handles mapping the custom fields to be transferred to the SRM system.

Sample code:

TYPES: BEGIN OF ty_aeoi,

             revlv TYPE cc_revlv,

             andat TYPE cc_andat,

          END OF ty_aeoi.

   DATA  loc_objkt      TYPE aeobjekt.

   DATA: loc_revlv      TYPE cc_revlv,

         int_aeoi       TYPE TABLE OF ty_aeoi,

         fs_aeoi        TYPE ty_aeoi.

   FIELD-SYMBOLS: <fs_mara>    TYPE mara.

   CONSTANTS: wl_material      TYPE  obj_name  VALUE ‘MATERIAL’,

              wl_mara          TYPE  tabname   VALUE ‘MARA’,

              wl_zsr_addldata  TYPE  strng250  VALUE ‘ZSR_ADDLDATA’,

              wl_41            TYPE  aetyp     VALUE ’41’.

   CASE i_obj_name.

     WHEN wl_material.

       LOOP AT t_int_tables WHERE tabname = wl_mara.

         ASSIGN t_int_tablesdata TO <fs_mara> CASTING.

         loc_objkt = <fs_mara>matnr.

         SELECT aeoi~revlv aenr~datuv

            INTO TABLE int_aeoi

           FROM aeoi

           INNER JOIN aenr

           ON aeoi~aennr = aenr~aennr

           WHERE aeoi~aetyp = wl_41

            AND aeoi~objkt = loc_objkt

            AND aeoi~revlv NE space.

         IF sysubrc = 0.

           SORT int_aeoi BY andat DESCENDING.

           READ TABLE int_aeoi INTO fs_aeoi INDEX 1.

           loc_revlv = fs_aeoirevlv.

         ENDIF.

         IF <fs_mara> IS ASSIGNED.

           t_other_infofield1       = wl_zsr_addldata.

           t_other_infofield2       = <fs_mara>matnr.

           t_other_infofield3       = loc_revlv.

           APPEND t_other_info.

         ENDIF.

       ENDLOOP.

   ENDCASE.

Configuration in CRM for triggering the CRM Middleware download of data

  1. Create a SETTYPE in Tcode COMM_ATTRSET.

Name: ZSR_ADDLDATA

   2. Add material master custom fields as attributes.

Attribute Names:

ZDEPRDHA               Product Code

ZDEITARK                 Military Goods

ZDEREVLV               Revision Level

Include the set type ZSR_ADDLDATA in a transport request as give in the below screen shot.


set type.png

  • Make sure the create API APPEND flag is set to generate the API methods by the system.

3. Create Implementation for BADI to update the custom fields of SRM with material master fields.

BADI Name: PRODUCT_CUSTOMER2

Implementation Name: ZNSRE_PRODUCT_CUST

Method: MAP_R3_TO_CRM_MATERIAL

This BADI is used to update the custom fields of a material master in SRM.

Sample code:

DATA:

         int_categories            TYPE comt_prod_cat_rel_tab,

         int_cat_settype_rel       TYPE comt_cat_frag_rel_tab,

         int_cat_settype_rel_all   TYPE comt_cat_frag_rel_tab,

         fs_other_info             TYPE bapiextc,

         fs_marc                   LIKE LINE OF it_marc,

         fs_cat_settype_rel        TYPE comt_cat_frag_rel,

         fs_settype                TYPE comt_settype_ext,

         fs_category               TYPE comt_prod_cat_rel,

         fs_category_bdoc          TYPE comt_prod_cat_rel_maintain,

         fs_zcustdata              TYPE zsr_addldata_maintain,

         loc_matnr                 TYPE strng250.

   CONSTANTS: wl_zsr_addldata      TYPE  comt_frgtype_id       VALUE ‘ZSR_ADDLDATA’,

              wl_0000000000        TYPE  comt_pr_key_type      VALUE ‘0000000000’.

   CALL FUNCTION ‘COM_PROD_CAT_REL_READ_WITH_PR’

     EXPORTING

       iv_product_guid  = cs_product_bdocheadercom_productproduct_guid

       iv_update_buffer = space

     IMPORTING

       et_set           = int_categories.

   LOOP AT cs_product_bdocheadercategories INTO fs_category_bdoc.

     MOVE-CORRESPONDING fs_category_bdocdata TO fs_category.

     READ TABLE int_categories WITH KEY hierarchy_guid = fs_categoryhierarchy_guid TRANSPORTING NO FIELDS.

     IF sysubrc = 0.

       MODIFY int_categories FROM fs_category INDEX sytabix.

     ELSE.

       APPEND fs_category TO int_categories.

     ENDIF.

   ENDLOOP.

   LOOP AT int_categories INTO fs_category.

     CALL FUNCTION ‘COM_CAT_FRAG_REL_READ’

       EXPORTING

         iv_category_guid = fs_categorycategory_guid

       IMPORTING

         et_cat_frag_rel  = int_cat_settype_rel

       EXCEPTIONS

         wrong_call       = 1

         OTHERS           = 2.

     IF sysubrc = 0.

       APPEND LINES OF int_cat_settype_rel TO int_cat_settype_rel_all.

     ENDIF.

   ENDLOOP.

   DELETE ADJACENT DUPLICATES FROM int_cat_settype_rel_all.

   LOOP AT int_cat_settype_rel_all INTO fs_cat_settype_rel.

     CALL FUNCTION ‘COM_SETTYPE_READ_SINGLE’

       EXPORTING

         iv_settype_guid  = fs_cat_settype_relfrgtype_guid

       IMPORTING

         es_settype       = fs_settype

       EXCEPTIONS

         not_found        = 1

         no_import_values = 2

         no_text_found    = 3

         OTHERS           = 4.

     IF sysubrc <> 0.

* Implement suitable error handling here

     ENDIF.

     CASE fs_settypefrgtype_id.

       WHEN wl_zsr_addldata.

         SELECT SINGLE guid

           INTO fs_zcustdatarelationkey_guid

           FROM mdm_pr0000000000

           WHERE key_type = wl_0000000000.

         fs_zcustdatarelationowner    = zcl_constants=>gc_x.

         fs_zcustdatarelationlogsys   = cs_product_bdocheadercom_productlogsys.

         fs_zcustdatadatafrg_guid     = fs_settypefrgtype_guid.

         fs_zcustdatadatazz0010       = is_maraprod_hier.

         fs_zcustdatadata_xzz0010     = zcl_constants=>gc_x.

*       update the military flag for the material

         READ TABLE it_marc INTO fs_marc WITH KEY material = is_maramaterial milit_id = zcl_constants=>gc_x.

         IF sysubrc = 0.

           fs_zcustdatadatazz0011     = zcl_constants=>gc_x.

           fs_zcustdatadata_xzz0011   = zcl_constants=>gc_x.

         ELSE.

           fs_zcustdatadatazz0011     = space.

           fs_zcustdatadata_xzz0011   = zcl_constants=>gc_x.

         ENDIF.

*       Update Revision level for the material

         loc_matnr = is_maramaterial.

         READ TABLE it_other_info INTO fs_other_info WITH KEY field1 = wl_zsr_addldata

                                                              field2 = loc_matnr.

         IF sysubrc = 0.

           fs_zcustdatadatazz0012     = fs_other_infofield3+0(2).

           fs_zcustdatadata_xzz0012   = zcl_constants=>gc_x.

         ENDIF.

         APPEND fs_zcustdata TO cs_product_bdocdatazsr_addldata.

         APPEND fs_settypefrgtype_id TO cs_product_bdocdatamnt_settype.

     ENDCASE.

   ENDLOOP.

Please feel free to comment or ask questions and as usual I shall try my best to answer them.

Naveen



To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. K P

    Good one.

    (( Though I don’t see a business case for transferring custom attributes of material master to SRM. If you provide a example business case in your future blogs, that will be great ))

    (0) 

Leave a Reply