Technical Articles
Parallel Processing Framework
The purpose of this post is to share a tool, well, not only a tool, a framework … I like the term framework kind of sounds geek 😀 .
This framework will always be under development … so, feel free to provide some feedback.
In order to keep things simple I will post the source to the framework and some usage examples. But before, let’s jump into some what, why & how questions.
What?
This is a framework to allow users to easily have the ability to use work process parallelism without the burden to manage all the technical implementation details.
Why?
- Because this is a topic that I really like;
- I don’t know … because, I want to
How?
I’m describing the simple way to use the framework in the following items:
Â
- The tasks you are trying to process are independent and non-related to each other;
- You have to define a Function Module Remote Enabled (this is extremely important … I’ll bet that someone is going to miss this particularity 😛 ), that will be your way to process an entry;
- Gather the data to be processed
- Example 1: select pernr into table it_employee from pa0000 where name like ‘%peanuts%’
- it_employee needs to have all the data that you require to process an unit of process (in this case an employee)
- If you need multiple data, example data from another table or from seven thousand and thirty five tables
- Create a data type that will hold all the data per unit of process.
- Instantiate the framework providing:
- FM name
- Internal table containing the data to be processed
- Execute the run method
This is all blah blah but … talk to me in code!
If you are like me you are probably skipping all the introduction blah blah and just got to this point … or not, nevertheless follows a simple example:
” **********************************************************************
” Retrieve some example data
data: it_t005 type table of t005.
select * into table it_t005 up to 100 rows from t005.
try .
” **********************************************************************
” Build instance
l_pp_ref = zcl_pp_factory=>build_instance( pit_raw_data           = it_t005
p_rfc_name             = ‘Z_PP_UNIT_TESTS’
p_logon_group          = sp_loggr
p_max_execution_time   = sp_maxt
p_task_wait_time       = sp_tswt
p_task_max_retries     = sp_maxr
p_task_wait_no_resource = sp_tstn
p_log_level            = sp_logl
).
” **********************************************************************
” Execute the processing
l_pp_ref->run( ).
” **********************************************************************
” Display results
perform display_results using
l_pp_ref
changing
git_processed
git_unprocessed
git_error.
catch zcx_pp_exception into cx.
l_err = cx->if_message~get_text( ).
message l_err type ‘S’ DISPLAY LIKE ‘E’.
endtry.
Where?
At this particular moment I’m sharing this tool using the saplink format … if you don’t know what saplink is please follow this link before trying to install.
Considerations!!!
Regarding the generic runtime, it is considering that the Remote Function Module has a fixed signature. If you are planning on using this generic runtime, please make sure that you change your Function Module accordingly.
Some documentation
Full documentation
Manual: AVAZ – SAP BC – Parallel Processing
Download
Inside the manual PDF you can find the NUGG file.
PLEASE READ
There are some notes that I would like to leave before providing this framework.
- Use this at your own risk, I will not be held responsible in any way for whatever could happen if you use this framework
- Even if I have an infinite loop that overheats the CPU and causes a fire which then burns down a whole block leading to the world caos…I don’t care 😈
- You can use this as you want, I don’t mind … some credit is appreciated though 🙂
Hi Antonio,
Standard SAP has something already existing for parallel processing which can be used and is quite handy.
CALL FUNCTION func STARTING NEW TASK task
[DESTINATION {dest|{IN GROUP {group|DEFAULT}}}]
[{PERFORMING subr}|{CALLING meth} ON END OF TASK]
parameter_list.
After reading the blog post, i was confused on the usage of this "Framework".
Ashish
Hi Ashish,
The framework is using the SAP standard to execute the tasks.
The advantage is that if you have 20 processes that need to execute parallelism tasks you would need to adapt each process and maintain the code in 20 different places (because of the FM signature and retries and error control and ...).
With this framework you encapsulate all this logic and also you have retries, error logging and so on, completely out of the box without the need of constant reimplementation and adaptation on a per-case approach.
However If you are still not convinced ... oh well, just don't use it 🙂
PS: I appreciate your input though, thanks for that
Regards.
Can you distribute the coding otherwise than google.drive. The nugget inside is not available.
I have meanwhile lost access to this account I was using when the blog was posted. As I'm keep getting request to share the PDF (google drive share seems to not be working either) I have decided to uploaded the code to a github repo to simplify the NUGG download: https://github.com/antonio-vaz/parallelprocessing