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?

  1. Because this is a topic that I really like;
  2. I don’t know … because, I want to

How?

I’m describing the simple way to use the framework in the following items:


  1. The tasks you are trying to process are independent and non-related to each other;
  2. 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;
  3. Gather the data to be processed
    1. Example 1: select pernr into table it_employee from pa0000 where name like ‘%peanuts%’
    2. it_employee needs to have all the data that you require to process an unit of process (in this case an employee)
    3. If you need multiple data, example data from another table or from seven thousand and thirty five tables
      1. Create a data type that will hold all the data per unit of process.
  4. Instantiate the framework providing:
    1. FM name
    2. Internal table containing the data to be processed
  5. 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

Parallel Processing Framework.png

Parallel Processing Framework 1.png

Parallel Processing Framework 2.png

Full documentation

Manual: AVAZ – SAP BC – Parallel Processing.pdf – Google Drive

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 🙂
To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Ashish Singhal

    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

    (0) 
    1. Antonio Jorge Almeida Vaz

      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.

      (0) 

Leave a Reply