This simple ABAP code will show you how to display all the plants associated with a given material, the function module we will use is called MATERIAL_READ_PLANTS that will return the plants value into an internal table, after that we will list all the plants that has the material.
Report Z_List_All_Plants_For_Material.
“ABAP Code to list all the plants for a
“Given material
“Given material
parameter: p_matnr like mara-matnr.
data: t_plants TYPE TABLE OF MARC_WERK WITH HEADER LINE.
CALL FUNCTION ‘MATERIAL_READ_PLANTS’
EXPORTING
MATNR = p_matnr
TABLES
PLANTS = t_plants.
EXPORTING
MATNR = p_matnr
TABLES
PLANTS = t_plants.
“If found the list all the plants associated
“with the given material
“with the given material
If sy-subrc = 0.
LOOP AT t_plants.
WRITE:/ t_plants-werks.
ENDLOOP.
endif.
Now run the program (F8), enter the material name you want to look.
Click on Execute (F8)
After that you will see the plant(s) associated with this material number.
Post a Comment