Pages

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.
https://4.bp.blogspot.com/-0fjIsDLjvJE/Uqw08KSzvFI/AAAAAAAAAMQ/x8wsqDSIp3c/s640/1.jpg 


 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.
Result:
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:


The SAP standard FM is SPTA_PARA_PROCESS_START_2.
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).


https://4.bp.blogspot.com/-E-AgW1b_HFU/Uqw1QTH0fvI/AAAAAAAAAMY/Cn9qP4M-knw/s640/2.jpg


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.


https://3.bp.blogspot.com/-qapJ3Fds0_c/Uqw1l10FsAI/AAAAAAAAAMk/8JqirpFhP68/s640/3.jpg


https://2.bp.blogspot.com/-Pl2sKfzfmGQ/Uqw1nWtBDfI/AAAAAAAAAMs/Ku2tVtmTqC0/s640/4.jpg


https://1.bp.blogspot.com/-M4mB_tOtU48/Uqw1pcwtw5I/AAAAAAAAAM0/Nkz2iujMNg8/s640/5.jpg


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.


https://1.bp.blogspot.com/-SW83pCoh6vs/Uqw1qzGhYsI/AAAAAAAAAM8/7KV68ahEzFg/s640/6.jpg


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.


https://1.bp.blogspot.com/-8czcbluQAr0/Uqw1tuq5rNI/AAAAAAAAANE/BCebcUFzntI/s640/7.jpg

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






10 comments:

  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.
    Regards,
    SAP Training in Chennai

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

    ReplyDelete
  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.

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

    ReplyDelete
  5. Thanks for sharing valuable information through your post. The information provided is of great use.
    SAP ABAP TRAINING IN HYDERABAD

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

    ReplyDelete
  7. Great Post. The information provided is of great use as I got to learn new things. Keep Blogging.
    SAP ABAP TRAINING IN HYDERABAD

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

    SAP ABAP Tutorial

    ReplyDelete