cancel
Showing results for 
Search instead for 
Did you mean: 

How to get data from hierachy lookup table using MDM ABAP API

0 Kudos

Hi,

I have 'Categories' as Hierarchy lookup table. When I see this table in MDM Data Manager Client. It shows me the tree like structure of categories (categories with sub-categories).

Can I fetch these different level entries shown in the tree (categories and sub-categories) separately from this Hierarchy Lookup table using MDM ABAP API.

Thanks & Regards,

Gaurav

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

got myself

former_member189719
Participant
0 Kudos

Hi Raheja,

When I read a flat look up field from the main table I get the record position from the lookup table and not the exact field data, have you had this problem with ABAP APIs?

Could you tell me how I can get the look up field values and not the index of the field in the table.

Thanks

Dilip

0 Kudos

Hi Dilip,

Below is the snippet of code to retrieve data from flat table. Here 'Products' is the main table and 'SHRTDESC' is the lookup field. Here I am using 'Retrieve' instead of 'Retrievesimple'.

DATA lt_model_set TYPE mdm_result_set_table.

DATA lt_result_set_definition TYPE mdm_field_list_table.

DATA ls_result_set_definition LIKE LINE OF lt_result_set_definition.

ls_result_set_definition-field_name = 'shrtdesc'.

APPEND ls_result_set_definition TO lt_result_set_definition.

CALL METHOD lr_api->mo_core_service->retrieve

EXPORTING

iv_object_type_code = 'Products'

it_result_set_definition = lt_result_set_definition

it_keys = lt_keys

IMPORTING

et_result_set = lt_model_set.

DATA ls_pair LIKE LINE OF ls_model_set-name_value_pairs.

FIELD-SYMBOLS <shrt_desc> TYPE data.

LOOP AT lt_model_set INTO ls_model_set.

READ TABLE ls_model_set-name_value_pairs WITH KEY code = 'SHRTDESC' INTO ls_pair.

IF ls_pair-value IS NOT INITIAL.

ASSIGN ls_pair-value->* TO <shrt_desc>.

ENDIF.

CLEAR ls_pair.

ENDLOOP.

Now the required value is in <shrt_desc>.

Let me know if you still have any issues.

Regards,

Gaurav

Former Member
0 Kudos

Hi Gaurav,

Can you explain how you got your answer. I have a similar issue in which I would like to retrieve all fields in a hierarchy table as well as their parent child relationships.

Thanks.

michael_theis
Active Contributor
0 Kudos

Hi Gaurav,

yes this is possible. Check the ABAP API how-to guides available on <a href="http://service.sap.com/installmdm">MDM Documentation Center</a>. How-to number 11 contains a description including some sample source coding how-to retrieve hierarchies. Having the ABAP API installed in your SAP system, you can check package "MDE_API_SAMPLES" for all how-to reports, or report "MDE_API_HOW_TO_11" for the source code as well!

BR Michael

0 Kudos

Hi Michael,

Thanks for quick response but I have already gone through these how-to guides.

Yeah you are right how-to 11 tells how to read the category for particular product in the products table. But My issue is different - I just want to read all the categories from the categories table so that I can populate my dropdown list with these categories. This is possible by just using retrive_simple on 'categories' table but this category table also contains subcategories which I can see in taxonomy mode or hierarchical mode. I want to get these subcategories also for my another dropdown. So I want both categories and subcategories separately, which are stored in a single table category - I cant see any identifier which tells that the particular entry is category or subcategory.

Hope I am not confusing you.

Gaurav