SAP Availability Control: Define exceptions based on parameters other than cost element
This blog posting deals with enhancements related to management accounting budgeting and availability control. For a broader overview of this functionality please visit the following links:
- Create Budget profile and Activate Availability Control
- SAP PS – Configure Budget Availability Control
- Budget Management for Projects – Costs – SAP Library
- Availability Control – SAP Library
The availability control functionality of the SAP System provides the possibility of defining exceptions for certain cost elements. That means that for the customized cost elements the CO object budget would not be checked against the posted actual. This is useful in many cases and typical examples are postings from settlement or interest or credit memos for services rendered within a joint venture.
In many cases nevertheless it is not possible to determine the values that should be excluded from the availability control based solely on the cost element. Other parameters like partner object, value type, business transaction and object number would significantly increase the determination possibilities.
SAP Note 2238793
SAP has released in November 2015 the note 2238793 containing a BAdI that significantly increases the flexibility on the selection of values that should be excluded from the availability check. The BAdI name is AVC_EXCL and it is located inside function module BP_COST_ELEMENT_CHECK. This function module is in turn called inside form CHECK_KSTAR located in include LBPFCFC1. The BAdI contains as import parameters the CO key sub number, the controlling area, the cost element, the object number, the fiscal year, the value type, the business transaction, the debit/credit indicator and the partner object. Note 2238793 can be implemented in versions from 600 to 618 via transaction SNOTE. Nevertheless a couple easy of manual changes are also necessary.
Note 2239872 is referenced inside note 2238793 and provides some examples of implementation. One example that is not provided and that is perhaps useful is a selection based on budget profile and cost element. For that a code like the one below could be used:
* assumption: there is already in the system a customer table called ZTBPFK. This table is a copy of standard table TBPFK, but contains an additional key field called PROFIL with data element BP_BPROFIL.
* For illustration simplicity the code below is written in continuous lines of code.
METHOD if_avc_excl~check. DATA: ls_proj TYPE proj. DATA: ls_prps TYPE prps. DATA: ls_t003o TYPE t003o. DATA: ls_ztbpfk TYPE ztbpfk. DATA: l_profil TYPE tbp1c-profil. DATA: l_hrkft_grp TYPE char4. DATA: l_obart TYPE ionra-obart. DATA: l_aufnr TYPE aufk-aufnr. DATA: l_auart TYPE aufk-auart. DATA: l_logsys TYPE aufk-logsystem. CLEAR l_obart. CALL FUNCTION 'OBJECT_NUMBER_TYPE_GET' EXPORTING objnr = objnr IMPORTING obart = l_obart. CASE l_obart. WHEN 'PR'. CLEAR ls_prps. CALL FUNCTION 'CJPN_GET_WBS_ELEMENT' EXPORTING i_objnr = objnr IMPORTING e_prps = ls_prps. CLEAR ls_proj. CALL FUNCTION 'CJPN_GET_PROJECT_DEFINITION' EXPORTING i_pspnr = ls_prps-psphi IMPORTING e_proj = ls_proj. MOVE ls_proj-bprof TO l_profil. WHEN 'OR'. CLEAR l_aufnr. CALL FUNCTION 'OBJECT_KEY_GET_OR' EXPORTING objnr = objnr IMPORTING aufnr = l_aufnr. CLEAR: l_logsys, l_auart. CALL FUNCTION 'K_ORDER_READ' EXPORTING aufnr = l_aufnr IMPORTING logsystem = l_logsys auart = l_auart. CLEAR ls_t003o. IF l_logsys IS INITIAL. CALL FUNCTION 'READ_T003O' EXPORTING i_auart = l_auart IMPORTING e_t003o = ls_t003o. ELSE. CALL FUNCTION 'READ_T003O' EXPORTING i_auart = l_auart IMPORTING e_t003o = ls_t003o EXCEPTIONS not_found = 1 OTHERS = 2. IF sy-subrc 0. CLEAR ls_t003o. ENDIF. ENDIF. MOVE ls_t003o-bprof TO l_profil. ENDCASE. l_hrkft_grp = hrkft(4). CHECK NOT kokrs IS INITIAL. CHECK NOT kstar IS INITIAL. SELECT SINGLE * INTO ls_ztbpfk FROM ztbpfk WHERE kokrs = kokrs AND profil = l_profil AND kstar = kstar AND hrkft = l_hrkft_grp. IF sy-subrc = 0. RAISE excluded_by_badi. ENDIF. CHECK NOT l_hrkft_grp IS INITIAL. SELECT SINGLE * INTO ls_ztbpfk FROM ztbpfk WHERE kokrs = kokrs AND profil = l_profil AND kstar = '*' AND hrkft = l_hrkft_grp. IF sy-subrc = 0. RAISE excluded_by_badi. ENDIF. SELECT SINGLE * INTO ls_ztbpfk FROM ztbpfk WHERE kokrs = kokrs AND profil = l_profil AND kstar = kstar AND hrkft = '*'. IF sy-subrc = 0. RAISE excluded_by_badi. ENDIF. ENDMETHOD.
Old systems in which note with BAdI cannot be implemented
In systems in which the note with the BAdI cannot be implemented an implicit enhancement implementation could be created at the end of form CHECK_KSTAR (include LBPFCFC1). In this case the variable SUBRC should be changed to any number different than zero in case the value should be excluded from the availability control check.