Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
kallolathome
Active Participant
1,796

Introduction


 

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.

 

Solution


 


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. 
CALL FUNCTION 'SYSTEM_CALLSTACK'
IMPORTING
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 ).
ENDIF.
REFRESH lt_stacktable.

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

CLEAR lv_testrun.
REFRESH lt_callstack.

 


That’s it. 🙂
1 Comment
Labels in this area