cancel
Showing results for 
Search instead for 
Did you mean: 

SRM - R3 item position mapping

matteo_montalto
Contributor
0 Kudos

Hi all experts,

the question is quite tricky; basically I have a report that, given a Purchase Order Number, must get the PO from SRM AND from the backend and do a comparison at item granularity.

From the SRM side, the task is quite simple; I can use the BBP_PD_PO_GETDETAIL FM to retrieve all the data I need about the PO.

The problem is: how to get a mapping (R3 <---> SRM) for every single item position ?

Thanks in advance

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thank you very much, Matteo.

Kind regards,

Federico.

Former Member
0 Kudos

Hi pal, could you please tell me how did you solve that issue?

Thanks in advance,

Federico.

matteo_montalto
Contributor
0 Kudos

Hi Federico,

well the question is quite complex, in the sense that you must take into account eventual customizations that are strictly related to you SAP installation.

Anyway... in my case: a PO have a "quite" standard header, so I assume I can skip the mapping process for this item; I just considered that only the PO number is sufficient to retrieve the order from both backend and SRM.

How: in SRM --> BBP_PD_PO_GETDETAIL.

In R3 --> BAPI_PO_GETDETAIL.

My question was about items mapping so here's the solution I found... First of all; in my R3 and SRM system I can have 3 kind of items, say:

- material items;

- service items, that can be organized in hierarchies, so:

- a father in a hierarchy;

- a son in the hierarchy.

I did as follows; I simply translated the R3 PO into SRM-like data structure, in order to work on the same fields. Then I simply proceeded with some mapping rule that, I must remember, are valid in my system, it's not an absolute mapping that works anywhere. In particular: my SRM system is really old and doesn't support natively service hierarchies, so that it has been implemented in a "custom" way. Anyway...

Looping of the SRM_item table:

How to see it's a material item? Field PRODUCT_TYPE is set to '01'.

How to find the related R3 item? READ TABLE R3_item with key: PRODUCT_TYPE = '01' and SRM_item-EXT_DEM_SUBPOSID = R3_item-ZZXNUMBER.

(here ZZXNUMBER is a custom field; in my system it represents the ordering number of the item in the purchase order... It's related anyway to the kind of item we're considering).

Quite the same thing for a father in a service hierarchy:

How to see it's a service item (father)? Field PRODUCT_TYPE is set to '02' and ITM_TYPE = 'HIER'.

How to find the related R3 item? READ TABLE R3_item with key: PRODUCT_TYPE = '02' and SRM_item-ITM_TYPE = 'HIER' and EXT_DEM_SUBPOSID = R3_item-ZZXNUMBER.

(here ZZXNUMBER is a custom field; in my system it represents the ordering number of the item in the purchase order... It's related anyway to the kind of item we're considering).

Quite complex mapping for a child in a service hierarchy... A child in my SRM system can be seen as an item which has PRODUCT-TYPE = '02' and ITM_TYPE = BLANK. There's however any way to map it directly to the corrispective R3 item... Moreover, my specs tell that not all the SRM items in a PO MUST be present in the corrispective R3 PO... this is indeed, a report to allineate both sys.

This is a schema in pseudo-code:

- if the SRM_item considered is a child...

- find the father of the hierarchy in which the SRM_item is involved;

- find the corrispective element in R3_item set;

- go for an exact mapping using the mapping-between-position based on the fields ZZXNUMBER.

Well, I know it is quite complex, also because of the fact these systems are really customized. Maybe the code that follows can help you understanding what I've done.

Bye,

Matteo

LOOP AT srm_item INTO wa_srm_item.
    CLEAR wa_rowmap. " maptable that keeps index from the SRM_item and corrisp. ITM_item
    wa_rowmap-index_SRM = sy-tabix.
* consider item position type
    IF wa_srm_item-PRODUCT_TYPE EQ '01'.
* case 1: material
      READ TABLE r3_item INTO wa_r3_item WITH KEY PRODUCT_TYPE = '01' zzxnum = wa_srm_item-ext_dem_subposid.
      if sy-subrc = 0.
        wa_rowmap-index_R3 = sy-tabix.
      else. "if no pos. is found, it isn't present in R3 -> must be cancelled in SRM
        wa_rowmap-index_R3 = SPACE.
      endif.
    ELSEIF wa_srm_item-PRODUCT_TYPE EQ '02' AND wa_srm_item-ITM_TYPE EQ 'HIER'.
* case 2: father in a service hierarchy
      READ TABLE r3_item INTO wa_r3_item WITH KEY PRODUCT_TYPE = '02' zzxnum = wa_srm_item-ext_dem_subposid.
      if sy-subrc = 0.
        wa_rowmap-index_R3 = sy-tabix.
      else. "if no pos. is found, it isn't present in R3 -> must be cancelled in SRM
        wa_rowmap-index_R3 = SPACE.
      endif.
    ELSEIF wa_srm_item-PRODUCT_TYPE EQ '02' AND wa_srm_item-ITM_TYPE EQ SPACE.
* case 3: son in a service hierarchy
*   look for the father in SRM
      READ TABLE srm_item INTO wa_srm_father WITH KEY NUMBER_INT = wa_srm_item-ZZXHIER ITM_TYPE = 'HIER'. "child refers to the corrisp. father thru the number_int field
*   look for the father in R3
      READ TABLE r3_item INTO wa_r3_father WITH KEY PRODUCT_TYPE = '02' ITM_TYPE = 'HIER' ZZXNUM = wa_srm_father-ext_dem_subposid.
      if sy-subrc <> 0. "father's not on R3 anymore -> the son will not be on R3 too
        wa_rowmap-index_R3 = SPACE.
      else.
*   go for the service item thru the father.
        READ TABLE r3_item INTO wa_r3_item WITH KEY ZZXHPOS = wa_r3_father-NUMBER_INT ZZXNUM = wa_srm_item-ZZXNUM.
        if sy-subrc = 0.
          wa_rowmap-index_R3 = sy-tabix.
        else. "the service item is not on R3 anymore
          wa_rowmap-index_R3 = SPACE.
        endif.
      ENDIF.
    ENDIF.
    APPEND wa_rowmap TO tbl_SRMmapR3.
  ENDLOOP.

matteo_montalto
Contributor
0 Kudos

Nvrmind, I found a working mapping procedure