Application of Shared Memory
Running CJ45 Server Group option with custom code in Background mode
Most of you working in SAP ECC 6.0 version would have heard about “Shared Objects” and its wonderful features. You can get a nice materials and blogs about this topic in SDN.SAP.com.
- In this BLOG I am going to explain how we can execute the transaction CJ45 in Background mode with Server Group option which will also include custom code logic implemented in the user exit
I got a tricky requirement; as I need to execute my set of enhanced code by this option and my enhanced code is exists in the user exit EXIT_SAPLKASC_001.
It’s quite normal to choose this option but it’s tricky to execute any enhanced code in this CJ45 Tcode by selecting this Server Group option as below screen shot, because whenever we go by this option SAP will execute our enhancement for execution via CJ45 for every execution whether its foreground or background it does not matter.
CJ45 TCODE with execution in Background mode and Server Group option
Before going to explain the actual requirement solution I like to give brief explanation about the Server Group option .
To achieve a balanced distribution of the system load, you can use destination additions to execute function modules in parallel tasks in any application server or in a predefined application server group of an SAP system.
In my custom code implementation part (User Exit) I had conditions as below in the user exit.
CHECK (SY-tcode EQ ‘CJ44’ OR sy- tcode EQ ‘CJ45’) OR sy-batch IS NOT INITIAL
The code under this condition was never executed, because when you schedule project in CJ45 as Background and Server group the set of code in the enhancement will execute in Foreground and it will execute the code in parallel processing.
- Parallel processing enables the SAP System to process separate data packets in different batch processes simultaneously.
- Significantly SAP is using this Server Group option to process separate data packets in different batch processes simultaneously.
I am going to achieve this custom requirement by using another powerful methodology provided by SAP it’s called Shared Memory.
With shared objects in ABAP it is possible to share common data on one application server of a SAP system between different user sessions.
The following steps needs to be implemented to achieve the same
- Creating Root Class for shared memory
- Creating Shared memory area
- Creating implicit enhancement to pass the value for shared memory area
- Reading values from shared memory area to User Exit
1 Creation of Root Class:
Creating root class for shared memory area in SE24 and choose the attributes as follows
Creating one attribute as ‘BATCH’ in this class to pass the value to shared memory area.
2. Creating the Shared memory area:
create the shared memory area in SHMA tcode and give the root class name as created above.
Executing CJ45 Tcode:CJ45 TCODE with Background processing option with SERVER GROUP option
Actual execution screen and parameter
Giving defined server GROUP name:
3. Creating implicit enhancement in the above popup screen program:
Passing data to Shared Memory:
Implement the below code snippet to pass the value to the shared memory
4. Retrieving values from Shared Memory:
Implementing the below code in the user exit EXIT_SAPLKASC_001
Finally adding the above local variable also in CHECK condition statement as below
CHECK (SY-tcode EQ ‘CJ44’ OR sy- tcode EQ ‘CJ45’) OR sy-batch IS NOT INITIALOR LV_BATCH IS NOT INITIAL.
After this above custom implementation steps now able to produce suitable result for custom requirement.