This example uses the SAP enhancement COOPA_01 to demonstrate how to carry out your own test of the functional area.
Important:
SAP enhancements must be activated using transaction CMOD.
The code shown below is only valid for SAP enhancement COOPA_01.
SAP enhancement COOPA_01 is only valid for internal orders.
Function module "EXIT_SAPLRKIO_001" is
available in SAP enhancement COOPA_01.
You enter your own include using the name ZXAUFU01.
The following example of code can be used in include ZXAUFU01. This code does the following:
TABLES:
T003O.
DATA:
LS_CSKSV LIKE CSKSV. "master data of responsible cost center
* do the following checks not in display
mode:
CHECK ( I_ACTVT <> '03' ).
* read order type from database:
SELECT SINGLE * FROM T003O WHERE AUART = I_AUFK-AUART.
* check whether selection was successful:
IF ( SY-SUBRC <> 0 ).
* order type not found:
MESSAGE E001(K5) WITH 'ORDER TYPE' I_AUFK-AUART 'NOT FOUND' ''.
endif.
IF ( T003O-FUNC_AREA <> SPACE ).
* functional area is given in order type:
IF ( I_AUFK-FUNC_AREA <> T003O-FUNC_AREA ).
* functional area in order and order type do not match:
MESSAGE E001(K5) WITH 'WRONG FUNCTIONAL AREA'
'IN ORDER. USE'
T003O-FUNC_AREA 'INSTEAD'.
ENDIF.
ELSE.
* no functional area in order type:
IF ( I_AUFK-KOSTV <> SPACE ).
* responsible cost center given:
CALL FUNCTION 'RK_KOSTL_READ'
EXPORTING
DATUM = SY-DATUM
KOKRS = I_AUFK-KOKRS
KOSTL = I_AUFK-KOSTV
IMPORTING
XCSKSV = LS_CSKSV.
IF ( I_AUFK-FUNC_AREA <> LS_CSKSV-FUNC_AREA ).
* functional area in order and responsible cost center
* do not match:
MESSAGE E001(K5) WITH 'WRONG FUNCTIONAL AREA'
'IN ORDER. USE'
T003O-FUNC_AREA 'INSTEAD'.
ENDIF.
ENDIF.
ENDIF.