A similar Function Module to the previous post to get the list of all the Plants with their description for a given Material is given below.
SAP ABAP Function Module to extract Plant and Description for a given Material is given below.
CKBA_PLANT_GET_LIST
_______________________________________
Find the code below.REPORT ZEX_GETPLANT .
Parameter: p_matnr like CKMLMV001-MATNR.
Types:
BEGIN OF CKBA1_WERKS_STR,
WERKS LIKE CKMLMV001-WERKS,
NAME1 LIKE T001W-NAME1,
END OF CKBA1_WERKS_STR.
Data: CKBA1_WERKS_TBL TYPE CKBA1_WERKS_STR OCCURS 0.
CALL FUNCTION 'CKBA_PLANT_GET_LIST'
EXPORTING
I_MATNR = p_matnr
IMPORTING
E_WERKS_TBL = CKBA1_WERKS_TBL
EXCEPTIONS
NO_VALUES = 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 CKMLMV001-MATNR.
Types:
BEGIN OF CKBA1_WERKS_STR,
WERKS LIKE CKMLMV001-WERKS,
NAME1 LIKE T001W-NAME1,
END OF CKBA1_WERKS_STR.
Data: CKBA1_WERKS_TBL TYPE CKBA1_WERKS_STR OCCURS 0.
CALL FUNCTION 'CKBA_PLANT_GET_LIST'
EXPORTING
I_MATNR = p_matnr
IMPORTING
E_WERKS_TBL = CKBA1_WERKS_TBL
EXCEPTIONS
NO_VALUES = 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.