For determining the company code for a plant the following function module can be used.
SAP Function Module for determining company code for a Plant.
HRCA_PLANT_GET_COMPANYCODE
___________________________________________________
A PLANT can be assigned to only one COMPANY CODE.
A COMPANY CODE can have several PLANTS assigned to it.
You need to pass the PLANT to the above mentioned Function Module.
Find the code below.
REPORT ZEX_PLANTCOMPANYCODE .
Parameter: p_werk like HRCA_PLANT-PLANT.
Data: d_bukrs like HRCA_COMPANY-COMP_CODE.
CALL FUNCTION 'HRCA_PLANT_GET_COMPANYCODE'
EXPORTING
PLANT = p_werk
IMPORTING
COMPANYCODE = d_bukrs
EXCEPTIONS
NO_COMPANY_CODE_FOUND = 1
PLANT_NOT_FOUND = 2
OTHERS = 3
.
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_werk like HRCA_PLANT-PLANT.
Data: d_bukrs like HRCA_COMPANY-COMP_CODE.
CALL FUNCTION 'HRCA_PLANT_GET_COMPANYCODE'
EXPORTING
PLANT = p_werk
IMPORTING
COMPANYCODE = d_bukrs
EXCEPTIONS
NO_COMPANY_CODE_FOUND = 1
PLANT_NOT_FOUND = 2
OTHERS = 3
.
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
No comments:
Post a Comment