Show TOC

How to validate the functional area in a user exit

Example: How to validate the functional area in a user exit

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:

a) Checks only take place when creating or changing an order and not when displaying (I_ACTVT <> '03') one.
b) The system checks whether a functional area has been created in the order type (table T0030)
If yes, the system checks whether the functional area of the order (I_AUFK-FUNC_AREA) matches the order type (LS_T0030-FUNC_AREA).
c) If no functional area has be created in the order type and a cost center was entered (I_AUFK-KOSTV) in the order, the system checks whether the functional area of the order matches the responsible cost center (LS_CSKSV-FUNC_AREA).
Since cost centers are time dependent, a functional module (RK_KOSTL_READ) is used to read the master record of the cost center and to provide the current date (SY-DATUM) of the valid master record.

Example of code for include ZXAUFU01:

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.