Two Different Types of Parallel Processing Examples - SAP Blogs PDF
Two Different Types of Parallel Processing Examples - SAP Blogs PDF
Products Industries
Industries Support
Support Training
Training Community
Community Developer
Developer Partner
Partner About
About
Home / Community / Blogs + Actions
Abhijit Mandal
more by this author
ABAP Development
Enterprise Performance Management | SAP Application Interface Framework | abap | parallel process | parallel process in dtp | parallel
processing | performance management | sap application interface framework | sap solutions for enterprise performance management
share
0 share
0 tweet share
0
Follow
Purpose & Overview: We all know how to upload data into SAP but many of us not aware
of best possible way to upload the data in to sap. Now, if you are dealing with small volume of data
then there will be no problem but when it comes to huge volume of data then execution time is
important.
There are different solutions available. But SAP has provided wonderful solutions called ‘Parallel
Processing’. There are two types of parallel processing available.
With Release 3.1G, SAP offers a solution to the “short nights” problem: parallel-processed
background jobs. Long-running SAP reports can now implement parallel processing, which
lets them parcel out the work to be done to available dialog work processes in the SAP
system and then collect the results.Parallel-processing is implemented with a special variant of
asynchronous RFC. It’s important that you use only the correct variant for your own parallel
processing applications: the CALL FUNCTION STARTING NEW TASK DESTINATION IN GROUP
keyword.
Another one is the best one and most effective one. SPTA Framework. Performance wise this is
best possible parallel process. It takes minimum time to execute compare to other parallel
processes.
My attempt is to provide a good example of both and give a comparison between two parallel
processes.
Business Requirement: In this example for both the cases we have to upload data from legacy
file to Z table in SAP.
Step1: First create a Z table: This is the table where we will update the data.
Step2- Create Function Module: We will create a function module, through which we will upload the
data. Create import export parameter.
Step3: Function Module Coding:
FUNCTION zemp_data_upd1.
*”———————————————————————-
*”*”Local Interface:
*” IMPORTING
*” VALUE(IM_DATA) TYPE ZEMP_DATA OPTIONAL
*” EXPORTING
*” VALUE(EX_RESULT) TYPE ZUPD_RESULT
*”———————————————————————-
IF NOT im_data IS INITIAL.
IF sy–subrc EQ 0.
ex_result–empid = im_data–empid.
ex_result–message = ‘Updated’.
ELSE.
ex_result–empid = im_data–empid.
ex_result–message = ‘Not-Updated’.
ENDIF.
COMMIT WORK.
ENDIF.
ENDFUNCTION.
Report ZABHI_PARA_PROCESS_1.
TABLES: zemp_data.
TYPES:
DATA:
gv_ptask TYPE i,
gv_rcv_task TYPE i.
PARAMETERS:
I. INITIALIZATION.
RAISE no_authority_for_report.
ENDIF.
PERFORM f_get_file .
START-OF-SELECTION.
CHANGING gt_emp.
IF sy-subrc = 0.
COMMIT WORK.
ENDIF.
CHANGING gt_result.
END-OF-SELECTION.
ENDLOOP.
*&———————————————————————*
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
FORM f_get_file .
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name =‘‘
IMPORTING
file_name = p_file.
ENDFORM. ” F_GET_FILE
*&———————————————————————*
*&———————————————————————*
* text
*———————————————————————-*
* –>P_P_FILE text
* <–P_gt_emp text
*———————————————————————-*
EXPORTING
filename = lv_filename
filetype = ‘ASC’
has_field_separator = ‘X’
TABLES
data_tab = p_gt_tab
EXCEPTIONS
file_open_error =1
file_read_error =2
no_batch =3
gui_refuse_filetransfer = 4
invalid_type =5
no_authority =6
unknown_error =7
bad_data_format =8
header_not_allowed =9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. ” F_SUB_GET_DATA
*&———————————————————————*
*&———————————————————————*
* text
*———————————————————————-*
* –>P_GT_EMP text
* <–P_GT_RESULT text
*———————————————————————-*
lv_msg(80) TYPE c,
CLEAR:ls_data,
ls_result,
gv_snd_task,
gv_rcv_task,
lv_lines.
gv_ptask = gv_ptask + 1.
CLEAR: lv_excp_flag.
DO.
ADD 1 TO lv_taskname.
CLEAR lv_excp_flag.
EXPORTING
im_data = ls_data
EXCEPTIONS
*the called function module here. Exceptions are returned to you and you can
CASE sy-subrc.
WHEN 0.
ADD 1 TO gv_snd_task.
WHEN 1 OR 2.
CLEAR: ls_result.
CLEAR ls_result.
WHEN 3.
lv_excp_flag = ‘X’.
WHEN OTHERS.
CLEAR ls_result.
ENDCASE.
IF lv_excp_flag IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDLOOP.
ENDFORM. ” F_SUB_UPLOAD_LINK
*&———————————————————————*
*&———————————————————————*
* text
*———————————————————————-*
*———————————————————————-*
gv_ptask = gv_ptask – 1.
IMPORTING
ex_result = ls_result
EXCEPTIONS
no_update = 1
OTHERS = 2.
gv_rcv_task = gv_rcv_task + 1.
CLEAR ls_result.
A. ENDFORM. ” PROCESS_CALLBACK_PROG
Step 5- Test the program: Activate the program and then execute it. Select server group from
existing otherwise you can create a Z server group by executing transaction code RZ12 – RFC
Server Group Maintenance.
Step 5: Execute it and see the result: Employee details in Ztable will be updated and the report is
also generate.
*————————————————————————PROCESS 1 IS COMPLETE
—————————————————————————————————————-*
Step1-Creation of Ztable: For this process also, we will use same table to update employee
details:
Step2- Create Function Module: We will create a function module, through which we will upload the
data. Create import export parameter.
Step3: Function Module Coding:
See the difference of two function module. In this FM no COMMIT WORK inside the function
module.
FUNCTION zemp_data_upd.
*”———————————————————————-
*”*”Local Interface:
*” IMPORTING
*” VALUE(IM_DATA) TYPE ZEMP_DATA OPTIONAL
*” EXPORTING
*” VALUE(EX_RESULT) TYPE ZUPD_RESULT
*”———————————————————————-
IF NOT im_data IS INITIAL.
IF sy–subrc EQ 0.
ex_result–empid = im_data–empid.
ex_result–message = ‘Updated’.
ELSE.
ex_result–empid = im_data–empid.
ex_result–message = ‘Not-Updated’.
ENDIF.
ENDIF.
ENDFUNCTION.
REPORT zabhi_para_process_2 .
TABLES: zemp_data.
TYPE-POOLS: spta.
* Define a type that contains ALL the input & output data
TYPES:
DATA:
BEGIN OF importing,
END OF importing,
BEGIN OF exporting,
emp_result LIKE gt_result , “TYPE ty_result,
END OF exporting,
END OF gty_rfcdata.
PARAMETERS:
I. INITIALIZATION.
ENDIF.
PERFORM f_get_file .
START-OF-SELECTION.
CHANGING gt_emp.
IF sy-subrc = 0.
COMMIT WORK.
ENDIF.
gv_repid = sy-repid.
CLEAR: gv_error_count.
EXPORTING
server_group = p_rfcgr
max_no_of_tasks = p_maxtak
before_rfc_callback_form = ‘F_BEFORE_RFC’
in_rfc_callback_form = ‘F_IN_RFC’
after_rfc_callback_form = ‘F_AFTER_RFC’
callback_prog = gv_repid
EXCEPTIONS
invalid_server_group =1
no_resources_available = 2
OTHERS = 3.
END-OF-SELECTION.
SKIP.
ENDLOOP.
*&———————————————————————*
*& Form F_before_rfc
*&———————————————————————*
* text
*———————————————————————-*
* –>P_BEFORE_RFC_IMP text
* –>P_BEFORE_RFC_EXP text
* –>PT_RFCDATA text
* –>P_FAILED_OBJECTS text
* –>P_OBJECTS_IN_PROCESS text
* –>P_USER_PARAM text
*———————————————————————-*
FORM f_before_rfc
USING
CHANGING
p_user_param.
DATA:
FIELD-SYMBOLS:
CLEAR ls_obj_in_process.
IF sy-subrc = 0.
ls_obj_in_process = ls_failed_obj.
ls_emp-empid = ls_obj_in_process-obj_id(10).
ELSE.
* No there aren’t.
IF sy-subrc IS INITIAL.
CLEAR ls_emp.
ls_obj_in_process-obj_id(10) = ls_emp-empid.
ENDIF.
ENDIF.
IF p_objects_in_process IS INITIAL.
CLEAR p_before_rfc_exp-start_rfc.
EXIT.
ENDIF.
EXPORTING
data = ls_task_data
IMPORTING
indxtab = pt_rfcdata.
p_before_rfc_exp-start_rfc = ‘X’.
ENDFORM. “BEFORE_RFC
*———————————————————————*
* FORM IN_RFC *
*———————————————————————*
*———————————————————————*
FORM f_in_rfc
USING
CHANGING
DATA:
FIELD-SYMBOLS:
* stored in memory.
* Unpack RFC input data (that has been packed in the BEFORE_RFC form)
EXPORTING
indxtab = p_rfcdata
IMPORTING
data = ls_taskdata.
*—— Prepare your import data from -importing-workarea ( can define as per req )
CLEAR ls_data.
IF sy-subrc EQ 0.
ENDIF.
*—— Prepare your import data from -importing-workarea ( can define as per req )
EXPORTING
im_data = ls_data
IMPORTING
ex_result = ls_result
EXCEPTIONS
no_update = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
* Fill result tables
* This would include data for result lists, message handler etc.
* lS_taskdata-exporting-workarea = lS_taskdata-importing-workarea.
REFRESH: ls_taskdata-exporting-emp_result[].
EXPORTING
data = ls_taskdata
IMPORTING
indxtab = p_rfcdata.
* RFC will end with an automatic rollback and data written to the
ENDFORM. “F_in_rfc
*&———————————————————————*
*&———————————————————————*
* text
*———————————————————————-*
* –>P_RFCDATA text
* –>P_RFCSUBRC text
* –>P_RFCMSG text
* –>P_OBJECTS_IN_PROCESS text
* –>P_AFTER_RFC_IMP text
* –>P_AFTER_RFC_EXP text
* –>P_USER_PARAM text
*———————————————————————-*
FORM f_after_rfc
USING
p_rfcdata TYPE spta_t_indxtab
CHANGING
p_user_param.
DATA:
DATA:
IF p_rfcsubrc IS INITIAL.
EXPORTING
indxtab = p_rfcdata
IMPORTING
data = ls_taskdata.
TO gt_result.
EXIT.
ENDIF.
* Error handling
IF lv_tabsize = 1.
p_after_rfc_exp-no_resubmission_on_error = ‘X’.
INTO ls_obj_in_process.
IF sy-subrc NE 0.
CLEAR ls_obj_in_process.
ENDIF.
ELSE.
CLEAR p_after_rfc_exp-no_resubmission_on_error.
ENDIF.
ENDFORM. “AFTER_RFC
*&———————————————————————*
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
FORM f_get_file .
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name =‘‘
IMPORTING
file_name = p_file.
A. ENDFORM. ” F_GET_FILE
*&———————————————————————*
*&———————————————————————*
* text
*———————————————————————-*
* –>P_P_FILE text
* <–P_gt_emp text
*———————————————————————-*
CLEAR lv_filename.
EXPORTING
filename = lv_filename
filetype = ‘ASC’
has_field_separator = ‘X’
TABLES
data_tab = p_gt_tab
EXCEPTIONS
file_open_error =1
file_read_error =2
no_batch =3
gui_refuse_filetransfer = 4
invalid_type =5
no_authority =6
unknown_error =7
bad_data_format =8
header_not_allowed =9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
REFRESH: p_gt_tab.
ENDIF.
ENDFORM. ” F_SUB_GET_DATA
Activate the program and then execute it. Select server group from existing otherwise you can
create a Z server group by executing transaction code RZ12 – RFC Server Group Maintenance.
For this case one extra selection field has been taken for defining maximum task.
We will delete first from the table and upload the same file which has been used earlier.
Step 5: Execute it and see the result: Employee details have been updated.
*—————————————————————————– End of Process 2
—————————————————————————————————————————*
Now we are going to compare which parallel process performance is better. For better comparison, take
large volume of data because in small volume of data you will not find the difference.
Process 1:
Execute it :
Process 2:
Result:
See the time difference is very less. For better statistics use large volume of data.
Reference: Sap standard report for parallel processing.
Alert Moderator
9 Comments
You must be Logged on to comment or reply to a post.
Matthew Billingham
Mathew, If you look into inside of FM SPTA_PARA_PROCESS_START_2 , you will find most
of the thing has been written as object oriented.
But still, I will try make an object oriented version.
Thanks…
Adriano S. Campanhola
Hi Adriano,
Thanks for your comment The main difference is Task dependency in Process 1 and Process 2 is without
individual task dependence. I think you can go through this document to find out about these two process
Parallel Processing Using SPTA Framework.
amit soni
Hi Abhijit,
Hello Amit,
No of task means how many parallel tasks you want to open,
For your 2nd query you may check with “update debugging” .
Because In_rfc is force synchronous update. This is the most efficient method for parallel processing since
no update data will be written to the DB but rather stored in memory.
Thanks & Regards,
Abhijit
AbhinavX Gupta
Thanks for the post : we can also refer the demo program : SPTA_PARA_DEMO_1
Share & Follow
Privacy Terms of Use Legal Disclosure Copyright Trademark Sitemap Newsletter