Skip to Content
Technical Articles
Author's profile photo Kallol Chakraborty

Easy way to overcome standard hierarchy lock of the Cost Center during mass creation



I had a situation where there is a need to create multiple cost centers from a flat file. For that, I have come across 1 BAPI named BAPI_COSTCENTER_CREATEMULTIPLE. But there were several issues while creating the Cost Centers.

Firstly, there was a limitation of records in the RFC.

Secondly, there are several locks that take time to get unlock. Which makes the whole process very time-consuming.

There are also SAP notes for the same namely 1628315,  970300 & 111752.

The SAP notes are complex to implement & time taking. So, did a small change & passed one cost center at a time to the above-mentioned BAPIs & it worked.




The solution is to create an implicit enhancement in the include program: FKMAXF03(Main Program: SAPLKMA1). There is a variable called gd_bapi_testrun within the form SET_ENQUEUE_HIERARCHY.

Based on the variable the program: SAPLKMA1(called by the BAPI) understands whether the Standard Hierarchy of the Cost Centers needs to be locked or not. I have just changed it to always test mode when called through my program at the beginning and at the end reinstated the value to its original one.

N.B: In the test mode no lock occurs.

Please check below the sample code snippet of the enhancement for further reference(Code differs from the original one due to company policy).

  DATA lt_stacktable TYPE ABAP_CALLSTACK. 
     CALLSTACK          = lt_stacktable.
  IF line_exists( lt_stacktable[ mainprogram = 'ZREPORT_NAME' ] ). 
    DATA(lv_testrun) = gd_bapi_testrun.
    gd_bapi_testrun = COND #( WHEN gd_bapi_testrun IS INITIAL
                              THEN 'X'
                              ELSE gd_bapi_testrun ).
  REFRESH lt_stacktable.


IF line_exists( lt_callstack[ mainprogram = 'PROGRAM_NAME' ] ).
    lv_testrun = gd_bapi_testrun.

CLEAR lv_testrun.
REFRESH lt_callstack.


That’s it. 🙂

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Syambabu Allu
      Syambabu Allu

      Hi Kallol,

      Good Catch.Thanks for sharing!

      Thank you,