Thursday, June 26, 2008

SAP Get Plant Description for a Material

SAP Get Plant Description for a Material

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.



SAP Plants for a given Material

SAP Plants for a given Material

For extracting SAP PLANTS for a given MATERIAL the following function module can be used.

SAP ABAP FUNCTION MODULE for extracting all PLANTS in which the MATERIAL is maintained.

MATERIAL_READ_PLANTS
________________________________________


The import parameters for the above mentioned function module are as follows.

Material Number

All the PLANTS in which the above MATERIAL is maintained are extracted by the above mentioned function Module.

The fileds extracted are as follows.

MANDT       CLIENT
MATNR       Material Number
WERKS        Plant
PSTAT         Maintenance status
______________________________________________________

Find the code below.

REPORT ZEX_PLANTDETAILS .

parameter: p_matnr like mara-matnr.

data: int_plants TYPE TABLE OF MARC_WERK.

CALL FUNCTION 'MATERIAL_READ_PLANTS'
     EXPORTING
          MATNR  = p_matnr
     TABLES
          PLANTS = int_plants.

If sy-subrc = 0.

endif.