cancel
Showing results for 
Search instead for 
Did you mean: 

Read data from MDM For Lookup and Flat table using MDM ABAP API

Former Member
0 Kudos

Hi,

I have requriment to read data from MDM from FLAT and Lookup table using MDM ABAP API. My design is like this ,

I have one ITEMS (Main table in MDM) and inside that i have one Lookup flat table ITEM_TYPE , my requriment is to read Item number and its related Item type.

From ABAP.

Please help if any body has any idea.

Regards,

Shyam

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Shyam

1. You should install ABAP package the same version as your SAP MDM installation(for 5.5 or 7.1 SAP MDM)

2. SAP MDM Server and repository should be loaded before you start connect to repository

More about ABAP API abilities you can read from:

http://help.sap.com/saphelp_mdm550/helpdata/en/44/994332ac415da3e10000000a1553f6/frameset.htm

or

http://help.sap.com/saphelp_nwmdm71/helpdata/en/43/D7AED5058201B4E10000000A11466F/frameset.htm

Order of your programm:

1. Create connection to repository

2. Do something - Query for example (very important all repository fileds named by CODE not by Name)

3. Close connection to repository

Regards

Kanstantsin

Former Member
0 Kudos

Hi

I have already done all related configuration. I am able to retrieve data from MDM from MAIN table of MDM but i could not find out any way to retrieve data from FLAT or LOOKUP table associated with the main MDM table.

If you have any ides suggest.

Shyam.

Former Member
0 Kudos

HI Guys,

I found my solution by myself. Below is the solution , hope this will help others:-

Retrieve data from MDM using MDM ABAP API.

Step- 1. Create structure in SAP with the same name as that of MDM field code for MDM Main table.

Step-2. Create another structure in SAP having all lookup fields of MDM , fieldname in ECC must be same as that of MDM field

code.

Step-3.Create structure in SAP for individual lookup field(Single Field only) with the same name as MDM Field code.

Step-4.

DATA: IT_QUERY TYPE STANDARD TABLE OF MDM_QUERY, "MDM_QUERY_TABLE,

WA_QUERY TYPE MDM_QUERY,

WA_CDT_TEXT TYPE MDM_CDT_TEXT,

IT_RESULT_SET_KEY TYPE MDM_SEARCH_RESULT_TABLE,

WA_RESULT_SET_KEY TYPE MDM_SEARCH_RESULT,

WA_STRING TYPE STRING.

DATA:<Internal table> TYPE STANDARD TABLE OF <SAP Str Having all LOOKup Fields>

DATA: :<Internal table>TYPE STANDARD TABLE OF <SAP Str one LOOKup field>,

<Workarea> LIKE LINE OF :<Internal table>.

*PASS LOGICAL OBJECT NAME.

V_LOG_OBJECT_NAME = 'Logical object name defined in Customization'.

  • Define logon language, country & region for server

WA_LANGUAGE-LANGUAGE = 'eng'.

WA_LANGUAGE-COUNTRY = 'US'.

WA_LANGUAGE-REGION = 'USA'.

TRY.

CREATE OBJECT LR_API

EXPORTING

IV_LOG_OBJECT_NAME = V_LOG_OBJECT_NAME.

ENDTRY.

  • CONNECT to repository. Apply particular logon language info

*********************************************************************

CALL METHOD LR_API->MO_ACCESSOR->CONNECT

EXPORTING

IS_REPOSITORY_LANGUAGE = WA_LANGUAGE.

*NOW PASS ITEM NO AND GET KEY FROM MDM.

CLEAR WA_QUERY.

WA_QUERY-PARAMETER_CODE = <MDM FIELD CODE>. "Field code

WA_QUERY-OPERATOR = 'EQ'. "Contains

WA_QUERY-DIMENSION_TYPE = 1. "Field search

WA_QUERY-CONSTRAINT_TYPE = 8. "Text search

WA_STRING = <Field Value>.

GET REFERENCE OF WA_STRING INTO WA_QUERY-VALUE_LOW.

APPEND WA_QUERY TO IT_QUERY.

CLEAR WA_QUERY.

*PASS ITEM NUMBER AND GET RELATED KEY FROM MDM.

TRY.

CALL METHOD LR_API->MO_CORE_SERVICE->QUERY

EXPORTING

IV_OBJECT_TYPE_CODE = <MDM Main Table>

IT_QUERY = IT_QUERY

IMPORTING

ET_RESULT_SET = IT_RESULT_SET_KEY.

CATCH CX_MDM_COMMUNICATION_FAILURE .

CATCH CX_MDM_KERNEL .

CATCH CX_MDM_NOT_SUPPORTED .

CATCH CX_MDM_USAGE_ERROR .

CATCH CX_MDM_PROVIDER .

CATCH CX_MDM_SERVER_RC_CODE .

ENDTRY.

Pass record id into keys.

LOOP AT IT_RESULT_SET_KEY INTO WA_RESULT_SET_KEY.

WA_KEYS = WA_RESULT_SET_KEY-RECORD_IDS.

ENDLOOP.

WA_RESULT_SET_DEFINITION-FIELD_NAME = <Look field name>.

APPEND WA_RESULT_SET_DEFINITION TO IT_RESULT_SET_DEFINITION.

CALL METHOD LR_API->MO_CORE_SERVICE->RETRIEVE

EXPORTING

IV_OBJECT_TYPE_CODE = <MDM Main Table>

IT_RESULT_SET_DEFINITION = IT_RESULT_SET_DEFINITION

IT_KEYS = WA_KEYS

IMPORTING

ET_RESULT_SET = IT_RESULT_SET.

********************************************************************

LOOP AT IT_RESULT_SET INTO

WA_RESULT_SET.

*PASS KEYS INTO MAIN TABLE TO GET Structure for FALT or Look up Table

TRY.

CALL METHOD LR_API->MO_CORE_SERVICE->RETRIEVE_SIMPLE

EXPORTING

IV_OBJECT_TYPE_CODE = <MDM Main Table>

IT_KEYS = WA_KEYS

IMPORTING

ET_DDIC_STRUCTURE =<SAP Strct having all Look up fileds of MDM>

ENDTRY.

LOOP AT <SAP Strct having all Look up fileds of MDM> INTO <Work area>.

CLEAR WA_KEYS.

APPEND <Work area>-field name TO WA_KEYS.

CALL METHOD LR_API->MO_CORE_SERVICE->RETRIEVE_SIMPLE

EXPORTING

IV_OBJECT_TYPE_CODE = <MDM Lookup table name>

IT_KEYS = WA_KEYS

IMPORTING

ET_DDIC_STRUCTURE = <Single Structure in SAP For Lookup field>.

READ TABLE <Single Structure in SAP For Lookup field>. INTO <Work Area> INDEX 1.

Here you can get the value of realted lookup fields associated with main table data.

ENDLOOP.

ENDLOOP.

LR_API->MO_ACCESSOR->DISCONNECT( ).

Edited by: Shyam Babu Sah on Nov 24, 2009 4:52 AM