Saturday, 14 December 2013

SPTA Framework - Parallel Processing Technique in SAP ABAP

Now a day for some SAP program, the nights are getting too short to execute.
The CP industry, specially for distribution client the data volume is increasing very high day by day.

With the huge volume of data we are facing problems:
          Scheduled jobs are not finishing within the time frame.
          Dump for ABAP memory issue for huge data processing.
          Dump for timeout error for huge data processing.

SAP offers a solution for the problem: called parallel processing.
There are different frameworks available for parallel processing;
SPTA is the most popular one.

Let’s begin with one example of parallel processing with SPTA framework. 

 We can predefined three parameters for SPTA framework.
  1. Server Group – Instances (maintained in RZ12).
  2. Maximum number of work packet per server instance.
  3. Maximum number of records per work packet.
Let’s assume one record takes 1 sec for processing.

Before implementing SPTA –
1000 records get processed one by one and it will take 1000 sec (16 min approx) to be processed.

After implementing SPTA –
All the 1000 records get processed into 10 different tasks and that runs parallel, so by this way it takes 100 records processing time to complete 1000 records process and that is 100 sec (2 min approx).

So the total performance improvement would be 800% which can turn around whole day running job into few minutes.

SPTA Framework in Details:

There are three parameters by which we will call three subroutines to build our own logic for parallel processing.

  • BEFORE_RFC_CALLBACK_FORM: This routine is called by the function module before calling the RFC function module. Here we have to build different work packets which we want to process in the RFC function module.
  • IN_RFC_CALLBACK_FORM: This routine is called by the function module after work packets are created. In this routine we can use our own RFC enabled function module or custom code to process each work packets.
  • AFTER_RFC_CALLBACK_FORM: This routine is called at the end by the function module. After processing of all the work packets we have to collect all the processed data.

Other mandatory parameters are
·         SERVER_GROUP (we can pass our server group name which has been created from RZ12).
·         CALLBACK_PROG (The calling program name).
·         USER_PARAM (Data to be processed in SPTA process).

The main step in BEFORE_RFC_CALLBACK_FORM is WP (work packet) creation.
Here we are creating WP with maximum 10 records inside.

After finishing all the WP creation, all the WP will run in different tasks in parallel mode in IN_RFC_CALLBACK_FORM.

Debugging SPTA using SRDEBUG:

It’s good to remember that sometime when different server instances being used in SPTA processing then only the external breakpoint would not work to go into debug mode. In this case we need to use SRDEBUG.

Parallel tasks (sessions) in SPTA:

Here I have tried to make a clear picture of all the WP creation and how all the WP run in different sessions or tasks.

I have putted a breakpoint in the IN_RFC subroutine and run the main program, all the WP being created in BEFORE_RFC and then all the task will run in parallel mode in IN_RFC.

SAP has provided a sample demo program to understand SPTA Framework easily.
Program name -
SPTA_PARA_DEMO_1    Simple parallelization (without individual task dependence)


  1. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
    SAP Training in Chennai

  2. It was very nice blog to learn about SAP BASIS. Thanks for sharing.SAP basis

  3. Thanks for a the explanation.. It's nicely explained. I have used it couple of times but the explanation and visualization you have done is great.

  4. Thanks for your explain. this blog is very usefull.

  5. Thanks for sharing valuable information through your post. The information provided is of great use.

  6. Very useful information, thanks for sharing !!!

  7. Great Post. The information provided is of great use as I got to learn new things. Keep Blogging.

  8. very usefull thanks, successfuly implemented SPTA in my ABAP Program

    SAP ABAP Tutorial