To obtain a list of PLANTS for a given MATERIAL you can use the following function module.
SAP Function Module for obtaining list of PLANTS for a given Material
K_VALID_PLANTS_OF_MATERIAL
_____________________________________________________
REPORT ZEX_VALIDPLANTFORMAT .
Parameter: p_matnr like MARA-MATNR.
Data: int_werks TYPE TABLE OF T001W.
CALL FUNCTION 'K_VALID_PLANTS_OF_MATERIAL'
EXPORTING
I_MATNR = p_matnr
I_DISPLAY = ' '
* IMPORTING
* E_PLANT =
TABLES
I_T001W = int_werks
EXCEPTIONS
NO_VALID_PLANTS = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Parameter: p_matnr like MARA-MATNR.
Data: int_werks TYPE TABLE OF T001W.
CALL FUNCTION 'K_VALID_PLANTS_OF_MATERIAL'
EXPORTING
I_MATNR = p_matnr
I_DISPLAY = ' '
* IMPORTING
* E_PLANT =
TABLES
I_T001W = int_werks
EXCEPTIONS
NO_VALID_PLANTS = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
See Also:
SAP Locating Plants for a Given Material
SAP get Plant Description For a given Material
SAP PLANT MATERIAL and STORAGE LOCATION
Plant for a Company Code