Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

MVKE Material Hierarchy

Former Member
0 Kudos

In reference to PRODH

I need to extract the material hierarchy codes (5 levels) from PRODH field in MVKE. If I test using se16 on MVKE the table displays all 5 levels correctly in the PRODH field. However when I repeat the process using a query in a RFC only the first level is returned. The code for the RFC query is provided below.

My question is how to get the 5 hierarchy levels via ABAP. thanks

FUNCTION ZSD_MM_MVKE .

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  IMPORTING

*"     VALUE(MATERIAL) TYPE  MATNR

*"  EXPORTING

*"     VALUE(HIERARCHY) TYPE  PRODH

*"  EXCEPTIONS

*"      NOVALUE

*"----------------------------------------------------------------------

select prodh from mvke into hierarchy

   where matnr EQ material.

   endselect.

ENDFUNCTION.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello Kevin,

Try making your target a table with key fields.  For example:

TYPES: BEGIN OF type_hierarchy,

                matnr TYPE matnr,

               vkorg  TYPE vkorg,

               vtweg  TYPE vtweg,

               prodh  TYPE prodh_d,

             END OF type_hierarchy.

DATA: t_hierarchy TYPE STANDARD TABLE OF type_hierarchy.

SELECT matnr vkorg vtweg prodh INTO TABLE t_hierarchy

  WHERE matnr = material.

Regards,

Kim

2 REPLIES 2

Former Member
0 Kudos

Hello Kevin,

Try making your target a table with key fields.  For example:

TYPES: BEGIN OF type_hierarchy,

                matnr TYPE matnr,

               vkorg  TYPE vkorg,

               vtweg  TYPE vtweg,

               prodh  TYPE prodh_d,

             END OF type_hierarchy.

DATA: t_hierarchy TYPE STANDARD TABLE OF type_hierarchy.

SELECT matnr vkorg vtweg prodh INTO TABLE t_hierarchy

  WHERE matnr = material.

Regards,

Kim

0 Kudos

Kim,

thanks for your tremendous help. It is working great now

Kevin