Question on Parallel Processing in ABAP
Hi Experts,
I am trying to process my records using Parallel Processing concept making calls to Remote Function Module.
So, in simple terms it would look as shown below
loop.
call function <rfc_module> creating new task with <taskname>
endloop.
1. In the above scenario say it created 5 tasks.
2. If one of the tasks have been failed because of timeout error then what happens to that task.
In the below link it says that the dialog work proces can run only for 300 seconds.
http://help.sap.com/saphelp_nw70/helpdata/en/fa/096e92543b11d1898e0000e8322d00/content.htm
3. How do we track the task that has not been finished successfully?
4. Does that throw an error?
Thanks,
Babu Kilari
Here is an exmple from HELP
TYPES: BEGIN OF task_type,
name TYPE string,
dest TYPE string,
END OF task_type.
DATA: snd_jobs TYPE i,
rcv_jobs TYPE i,
exc_flag TYPE i,
info TYPE rfcsi,
mess TYPE c LENGTH 80,
indx TYPE c LENGTH 4,
name TYPE c LENGTH 8,
task_list TYPE STANDARD TABLE OF task_type,
task_wa TYPE task_type.
DO 10 TIMES.
indx = sy-index.
CONCATENATE 'Task' indx INTO name.
CALL FUNCTION 'RFC_SYSTEM_INFO'
STARTING NEW TASK name
DESTINATION IN GROUP DEFAULT
PERFORMING rfc_info ON END OF TASK
EXCEPTIONS
system_failure = 1 MESSAGE mess
communication_failure = 2 MESSAGE mess
resource_failure = 3.
CASE sy-subrc.
WHEN 0.
snd_jobs = snd_jobs + 1.
WHEN 1 OR 2.
MESSAGE mess TYPE 'I'.
WHEN 3.
IF snd_jobs >= 1 AND
exc_flag = 0.
exc_flag = 1.
WAIT UNTIL rcv_jobs >= snd_jobs
UP TO 5 SECONDS.
ENDIF.
IF sy-subrc = 0.
exc_flag = 0.
ELSE.
MESSAGE 'Resource failure' TYPE 'I'.
ENDIF.
WHEN OTHERS.
MESSAGE 'Other error' TYPE 'I'.
ENDCASE.
ENDDO.
WAIT UNTIL rcv_jobs >= snd_jobs.
LOOP AT task_list INTO task_wa.
WRITE: / task_wa-name, task_wa-dest.
ENDLOOP.
FORM rfc_info USING name.
task_wa-name = name.
rcv_jobs = rcv_jobs + 1.
RECEIVE RESULTS FROM FUNCTION 'RFC_SYSTEM_INFO'
IMPORTING
rfcsi_export = info
EXCEPTIONS
system_failure = 1 MESSAGE mess
communication_failure = 2 MESSAGE mess.
IF sy-subrc = 0.
task_wa-dest = info-rfcdest.
ELSE.
task_wa-dest = mess.
ENDIF.
APPEND task_wa TO task_list.
ENDFORM.
Similar Messages
-
Parallel Processing through ABAP program
Hi,
We are trying to do the parallel processing through ABAP. As per SAP documentation we are using the CALL FUNCTION STARTING NEW TASK DESTINATION.
We have one Z function Module and as per SAP we are making this Function module (FM)as Remote -enabled module.
In this FM we would like to process data which we get it from internal table and would like to send back the processed data(through internal table) to the main program where we are using CALL FUNCTION STARTING NEW TASK DESTINATION.
Please suggest how to achieve this.
We tried out EXPORT -IMPORT option meaning we used EXPORT internal table in the FM with some memory ID and in the main program using IMPORT internal table with the same memory ID. But this option is not working even though ID and name of the internal table is not working.
Also, SAP documentation says that we can use RECEIVE RESULTS FROM FUNCTION 'RFC_SYSTEM_INFO'
IMPORTING RFCSI_EXPORT = INFO in conjunction with CALL FUNCTION STARTING NEW TASK DESTINATION. Documentation also specifies that "RECEIVE is needed to gather IMPORTING and TABLE returns of an asynchronously executed RFC Function module". But while creating the FM remote-enabled we cant have EXPORT or IMPORT parameters.
Please help !
Thanks in advance
Santosh<i>We tried out EXPORT -IMPORT option meaning we used EXPORT internal table in the FM with some memory ID and in the main program using IMPORT internal table with the same memory ID. But this option is not working even though ID and name of the internal table is not working</i>
I think that this is not working because that memory does not work across sessions/tasks. I think that the
IMPORT FROM SHARED BUFFER and EXPORT TO SHARED BUFFER would work. I have used these in the past and it works pretty good.
Also,
here is a quick sample of the "new task" and "recieve" functionality. You can not specify the importing parameters when call the FM. You specify them at the recieving end.
report zrich_0001 .
data: session(1) type c.
data: ccdetail type bapi0002_2.
start-of-selection.
* Call the transaction in another session...control will be stop
* in calling program and will wait for response from other session
call function 'BAPI_COMPANYCODE_GETDETAIL'
starting new task 'TEST' destination 'NONE'
performing set_session_done on end of task
exporting
companycodeid = '0010'
* IMPORTING
* COMPANYCODE_DETAIL = ccdetails
* COMPANYCODE_ADDRESS =
* RETURN =
* wait here till the other session is done
wait until session = 'X'.
write:/ ccdetail.
* FORM SET_session_DONE
form set_session_done using taskname.
* Receive results into messtab from function.......
* this will also close the session
receive results from function 'BAPI_COMPANYCODE_GETDETAIL'
importing
companycode_detail = ccdetail.
* Set session as done.
session = 'X'.
endform.
Hope this helps.
Rich Heilman -
Hi,
I have a internal table that has object references in it. Each item in the table are indepenent of the other. I want to extract info from each object and convert it into a internal table so that i can pass it to an RFC function.
So how can i do this extraction of the info from the objects in internal table in parallel.
To use the STARTING NEW TASK, i created a fn module that is RFC enabled.... then i can't pass the object reference to this module. So how can do this?
Also i read that this function module call will create a main or external session which has a limit of 6 per user session.Is this correct?
If above can be done, I also wanted to restrict the no of parallel processes being executed at any point of time to be 5 or so.
thanks in advance
MurugeshHi Murugesh,
Parallel processing can be implemented in the application reports that are to run in the background. You can implement parallel processing in your own background applications by using the function modules and ABAP keywords.
Refer following docs.
<b>Parallel Processing in ABAP</b>
/people/naresh.pai/blog/2005/06/16/parallel-processing-in-abap
<b>Parallel Processing with Asynchronous RFC</b>
http://help.sap.com/saphelp_webas610/helpdata/en/22/0425c6488911d189490000e829fbbd/frameset.htm
<b>Parallel-Processing Function Modules</b>
http://help.sap.com/saphelp_nw04s/helpdata/en/fa/096ff6543b11d1898e0000e8322d00/frameset.htm
Dont forget to reward pts, if it helps ;>)
Regards,
Rakesh. -
Parallel processing using ABAP objects
Hello friends,
I had posted in the performance tuning forum , regarding a performance issue problem , I am reposting it as it involves OO concept .
the link for the previous posting
Link: [Independent processing of elements inside internal table;
Here is the scenario,
I have a internal table with 10 records(indepentent) , and i need to process them .The processing of one record doesnt have any influence on the another . When we go for loop , the performance issue is that , the 10 th record has to wait until the 9 records get processed even though there is no dependency on the output.
Could some one tell a way out to improve the performance..
If i am not clear with the question , i would explain it still clearer...
A internal table has 5 numbers , say( 1,3,4,6,7)
we are trying to find square of each number ,,,
If it is a loop the finding of suare of 7 has to wait until 6 is getting completed and it is waste of time ...
This is related to parallel processing , I have refered to parallel processing documents,But I want to do this conceptually ..
I am not using conventional procedural paradigm but Object orientedness...I am having a method which is performing this action .What am I supposed to do in that regard.
Comradely ,
K.SibiHi,
As examplified by Edward, there is no RFC/asynchronous support for Methods of ABAP Objects as such. You would indeed need to "wrap" your method or ABAP Object in a Function Module, that you can then call with the addition "STARTING NEW TASK". Optionally, you can define a Method that will process the results of the Function Module that is executed asynchronously, as demonstrated as well in Edward's program.
You do need some additional code to avoid the situation where your program takes all the available resources on the Application Server. Theoretically, you cannot bring the server or system down, as there is a system profile parameter that determines the maximum number of asynchronous tasks that the system will allow. However, in a productive environment, it would be a good idea to limit the number of asynchronous tasks started from your program so that other programs can use some as well.
Function Group SPBT contains a set of Function Modules to manage parallel processing. In particular, FM SPBT_INITIALIZE will "initialize" a Server Group and return the maximum number of Parallel Tasks, as well as the number of free ones at the time of the initialization. The other FM of interest is SPBT_GET_CURR_RESOURCE_INFO, that can be called after the Server Group has been initialized, whenever you want to "fork" a new asynchronous task. This FM will give you the number of free tasks available for Parallel Processing at the time of calling the Function Module.
Below is a code snippet showing how these Function Modules could be used, so that your program always leaves a minimum of 2 tasks for Parallel Processing, that will be available for other programs in the system.
IF md_parallel IS NOT INITIAL.
IF md_parallel_init IS INITIAL.
*----- Server Group not initialized yet => Initialize it, and get the number of tasks available
CALL FUNCTION 'SPBT_INITIALIZE'
EXPORTING
GROUP_NAME = ' '
IMPORTING
max_pbt_wps = ld_max_tasks
free_pbt_wps = ld_free_tasks
EXCEPTIONS
invalid_group_name = 1
internal_error = 2
pbt_env_already_initialized = 3
currently_no_resources_avail = 4
no_pbt_resources_found = 5
cant_init_different_pbt_groups = 6
OTHERS = 7.
md_parallel_init = 'X'.
ELSE.
*----- Server Group initialized => check how many free tasks are available in the Server Group
for parallel processing
CALL FUNCTION 'SPBT_GET_CURR_RESOURCE_INFO'
IMPORTING
max_pbt_wps = ld_max_tasks
free_pbt_wps = ld_free_tasks
EXCEPTIONS
internal_error = 1
pbt_env_not_initialized_yet = 2
OTHERS = 3.
ENDIF.
IF ld_free_tasks GE 2.
*----- We have at leasr 2 remaining available tasks => reserve one
ld_taskid = ld_taskid + 1.
ENDIF.
ENDIF.
You may also need to program a WAIT statement, to wait until all asynchronous tasks "forked" from your program have completed their processing. Otherwise, you might find yourself in the situation where your main program has finished its processing, but some of the asynchronous tasks that it started are still running. If you do not need to report on the results of these asynchronous tasks, then that is not an issue. But, if you need to report on the success/failure of the processing performed by the asynchronous tasks, you would most likely report incomplete results in your program.
In the example where you have 10 entries to process asynchronously in an internal table, if you do not WAIT until all asynchronous tasks have completed, your program might report success/failure for only 8 of the 10 entries, because your program has completed before the asynchronous tasks for entries 9 and 10 in your internal table.
Given the complexity of Parallel Processing, you would only consider it in a customer program for situations where you have many (ie, thousands, if not tens of thousands) records to process, that the processing for each record tends to take a long time (like creating a Sales Order or Material via BAPI calls), and that you have a limited time window to process all of these records.
Well, whatever your decision is, good luck. -
Parallel processing for ABAP prorams in Process chain.
Hi All,
In one of the process chain, we have added the ABAP program. In Backend,the job is running as "BI_PROCESS_ABAP".
I just want to know, same like DTP, can we keep parallel processing for the ABAP programs also. Please suggest.
Thanks.Hello Jalina
Also check with BASIS if the memory allocated to run this program has not overflowed and the selections you have in your ABAP program is in small chunks and use variants to run them in parallel OR series
Thanks
Abhishek Shanbhogue -
Question regarding multi processes in ABAP
Hi
We have written a ATC / Checkman Check Implementation.
As we know the ATC / Checkman framework checks objects in object bundle of 50.
Inside the check implementation we have to make a remote HTTP Call. That will be valid for all n instances.
So the number n is determined by total number of objects / 50.
Question
In this multithreaded scenario how can we introduce a static variable which will be thread safe (making sure no two parallel threads write to this at a same time)
Any suggestions / help.
If you need more context i can explain more.
Thanks & Regards,
PiyushThis could be answered in general thread concept in ABAP.
As if we have to avoid parallel writes on a static variable how to do that? -
Question on parallel processing using the STARTING NEW TASK keyword
I have the following code in a program on my development system:
call function 'FUNCTION_NAME'
starting new task ld_taskname
performing collect_output on end of task
exporting
pd_param1 = ld_param1
tables
pt_packet = lt_packet.
You'll notice in the code above I left out the following part of the function call:
DESTINATION IN GROUP group
In my one-server development system the topmost code executes fine, but I'm getting a 'REMOTE FUNCTION CALL ERROR' when I execute this in a multi-server Q&A system.
My question: Is the missing 'DESTINATION' keyword required in order for this technique to work in a multi-server environment or is it optional keyword? I made the assumption that since it worked in my development environment that without the 'DESTINATION' addition the system simply used the current logged on system to start the new processes.
Any input appreciated.
Thanks,
LeeHi Lee,
Just take F1 help on CALL FUNCTION key word and go to the variant
CALL FUNCTION func STARTING NEW TASK task
[DESTINATION {dest|{IN GROUP {group|DEFAULT}}}]
parameter_list
[{PERFORMING subr}|{CALLING meth} ON END OF TASK].
This gives you very clear information about this Key word.
No one would give you better information better than this, i hope
Cheers
Ram -
Question on Parallel Processing
Hello Guy's . We would like to run more one payment run FPY1 simultaneously for different programs. However the system locks the relevant BP or CA during this process, hence we cannot run more than one payment run at a time. This causes a lot of delay as we have to wait for each payment run to finish. Is there a way where we can run more than one FYP1 or FPMA at a time. Will fpscheduler cater this. I think there should be a way where you can do it as PSCD is designed to process huge volume of data for different activities. Please advise.
Thanks in advance
SajHi, Currently we are using BPART which locks all the other CA whilst payrun we are trying to use VKONT and increase the jog interval. SO that simultaneously several payment run can be executed.
Saj -
ABAP OO and parallel processing
Hello ABAP community,
I am trying to implement a ABAP OO scenario where i have to take into account parallel processing and processing logic in the sense of update function modules (TYPE V1).
The szenario is definied as follows:
Frame class X creates a instance of class Y and a instance of class Z.
Classes Y and Z sould be processed in parallel, so class X calls classes Y and Z.
Classes Y and Z call BAPIS and do different database changes.
If classes Y or Z have finished, the status of processing is written into a status table by caller class X.
The processing logic within class Y and class Z should be a SAP LUW in the sense of a update function module (TYP V1).
Can i use events?
(How) Should i use "call function in upgrade task"?
(How) Should i use "call function starting new task"?
What is the best method to realise that behaviour?
Many thanks for your suggestions.Hallo Christian,
I will describe you in detail, whow I have solved this
problem. May be there is a newer way ... but it works.
STEPS:
I asume you have splitt your data in packages.
1.) create a RFC-FM: Z_WAIT
It return OK or NOT OK.
This FM: does following:
DO.
call function TH_WPINFO -> until the WPINFO has more
than a certain number of lines. (==> free tasks)
ENDDO.
If it is OK ==> free tasks are available
call your FM (RFC!) like this:
CALL FUNCTION <FM>
STARTING NEW TASK ls_tasknam " Unique identifier!
DESTINATION IN GROUP p_group
PERFORMING return_info ON END OF TASK
EXPORTING
TABLES
IMPORTING
EXCEPTIONS
*:--- Take care of the order of the exceptions!
COMMUNICATION FAILURE = 3
SYSTEM_FAILURE = 2
UNFORCED_ERROR = 4
RESOURCE_FAILURE = 5
OTHERS = 1.
*:--- Then you must check the difference between
*:--- the started Calls and the received calls.
*:--- If the number increases a certain value limit_tasks.
wait until CALLED_TASK < LIMIT_TASKS up to '600' seconds.
The value should be not greater then 20!
DATA-Description:
parameters: p_group like bdfields-rfcgr default 'Server_alle'. " For example. Use the F4 help
if you have defined the report-parameter as above.
ls_tasknam ==> Just the increasing number of RFC-Calls
as Character.
RETURN_INFO is a form routine in which You can check the results. Within this Form you must call:
RECEIVE RESULTS FROM FUNCTION <FM>
TABLES: ... " The tables of your <FM> exactly the same order!
EXCEPTIONS
COMMUNICATION FAILURE = 3
SYSTEM_FAILURE = 2
UNFORCED_ERROR = 4
NO_ACTIVATE_INFOSTRUCTURE = 1.
Her eyou must count the received Calls!
And you can save them into a internal table for checking!
I hope I could help you a little bit
God luck
Michael -
Parallel processing - some questions
Hi,
I'm about to develop a class for task management.
It should have methods like GET_TASK returning a taskid and task_return importing task_id received and possibly task_fail importing task_id sent with a bad sy-subrc when calling function with starting new task.
The idea behind is: New task is started by system using a dialog process with time limit restriction applying. Thus I have to split the whole task into more small packets than processes available. So I think I have to use the same task again after it returned successfully.
My assumption is I can't use more tasks than processes initially available and I can use the same tsak again after it has successsfully returned results.
I want some ideas and information on that exceeding the SAP documentation.
TIA.
Regards,
Clemens... and here comes the program (no formatting available with the answer given with "solved".
The programs retrieves billing documents with function BAPI_BILLINGDOC_GETLIST - this was the only BAPI I found quickly that has ranges as import parameters. This allows giving packages to the tasks.
*& Report ZZZPARTEST *
REPORT zzzpartest.
PARAMETERS:
p_dbcnt TYPE sydbcnt DEFAULT 1010,
p_pacsz TYPE sydbcnt DEFAULT 95.
CONSTANTS:
gc_function TYPE tfdir-funcname
VALUE 'BAPI_BILLINGDOC_GETLIST'.
DATA:
gt_bapivbrksuccess TYPE TABLE OF
bapivbrksuccess,
gv_activ TYPE i,
gv_rcv TYPE i,
gv_snd TYPE i,
BEGIN OF ls_intval,
task TYPE numc4,
idxfr TYPE i,
idxto TYPE i,
activ TYPE flag,
fails TYPE i,
END OF ls_intval,
gt_intval LIKE TABLE OF ls_intval.
START-OF-SELECTION.
PERFORM paralleltest.
* CLASS task DEFINITION
CLASS task DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
provide
RETURNING
value(name) TYPE numc4,
return
IMPORTING
name TYPE numc4,
initialize
RETURNING
value(group) TYPE rzllitab-classname.
PRIVATE SECTION.
CLASS-DATA:
gv_group TYPE rzllitab-classname,
BEGIN OF ls_task,
name TYPE numc4,
used TYPE flag,
END OF ls_task,
gt_task LIKE TABLE OF ls_task.
ENDCLASS. "itab DEFINITION
*** CLASS itab IMPLEMENTATION ***
CLASS task IMPLEMENTATION.
METHOD initialize.
DATA:
lv_max TYPE i,
lv_inc TYPE numc7,
lv_free TYPE i.
CHECK gt_task IS INITIAL.
SELECT classname
INTO gv_group
FROM rzllitab UP TO 1 ROWS
WHERE grouptype = 'S'.
ENDSELECT.
CALL FUNCTION 'SPBT_INITIALIZE'
EXPORTING
group_name = gv_group
IMPORTING
max_pbt_wps = lv_max
free_pbt_wps = lv_free
EXCEPTIONS
invalid_group_name = 1
internal_error = 2
pbt_env_already_initialized = 3
currently_no_resources_avail = 4
no_pbt_resources_found = 5
cant_init_different_pbt_groups = 6
OTHERS = 7.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
SUBTRACT 2 FROM lv_free.
IF lv_free >= 1.
DO lv_free TIMES.
ls_task-name = sy-index.
APPEND ls_task TO gt_task.
ENDDO.
group = gv_group.
MESSAGE s000(r1)
WITH
'Parallelverarbeitung benutzt'
lv_free
'Prozesse in Gruppe'
gv_group.
ELSE.
MESSAGE e000(r1)
WITH
'Parallelverarbeitung abgebrochen,'
lv_free
'Prozesse in Gruppe'
gv_group.
ENDIF.
ENDMETHOD. "initialize
METHOD provide.
FIELD-SYMBOLS:
<task> LIKE ls_task.
IF gv_group IS INITIAL.
MESSAGE e000(r1)
WITH 'Task group not initialized'.
ENDIF.
LOOP AT gt_task ASSIGNING <task>
WHERE used IS initial.
EXIT.
ENDLOOP.
CHECK sy-subrc = 0.
<task>-used = 'X'.
name = <task>-name.
ENDMETHOD.
METHOD return.
LOOP AT gt_task INTO ls_task
WHERE
name = name
AND used = 'X'.
DELETE gt_task.
ENDLOOP.
IF sy-subrc = 0.
CLEAR ls_task-used.
APPEND ls_task TO gt_task.
ELSE.
* fatal error
ENDIF.
ENDMETHOD.
ENDCLASS. "itab IMPLEMENTATION
*& Form paralleltest
FORM paralleltest.
DATA:
ls_bapi_ref_doc_range TYPE bapi_ref_doc_range,
lv_done TYPE flag,
lv_group TYPE rzllitab-classname,
lv_task TYPE numc4,
lv_msg TYPE text255,
lv_grid_title TYPE lvc_title,
lv_tfill TYPE sytfill,
lv_vbelv TYPE vbelv,
lv_npacs TYPE i,
lt_vbelv TYPE SORTED TABLE OF vbelv
WITH UNIQUE KEY table_line,
lv_mod TYPE i.
FIELD-SYMBOLS:
<intval> LIKE LINE OF gt_intval.
* build intervals
SELECT vbelv INTO lv_vbelv
FROM vbfa.
INSERT lv_vbelv INTO TABLE lt_vbelv.
CHECK sy-subrc = 0.
ADD 1 TO lv_tfill.
CHECK:
p_dbcnt > 0,
lv_tfill >= p_dbcnt.
EXIT.
ENDSELECT.
DESCRIBE TABLE lt_vbelv LINES lv_tfill.
IF (
p_pacsz < p_dbcnt OR
p_dbcnt = 0
) AND
p_pacsz > 0.
* p_dbcnt > 0 ).
lv_npacs = lv_tfill DIV p_pacsz.
lv_mod = lv_tfill MOD p_pacsz.
IF lv_mod <> 0.
ADD 1 TO lv_npacs.
ENDIF.
DO lv_npacs TIMES.
ls_intval-idxfr = ls_intval-idxto + 1.
ls_intval-idxto = ls_intval-idxfr - 1
+ p_pacsz.
IF ls_intval-idxto > lv_tfill.
ls_intval-idxto = lv_tfill.
ENDIF.
APPEND ls_intval TO gt_intval.
ENDDO.
ELSE.
ls_intval-idxfr = 1.
ls_intval-idxto = lv_tfill.
APPEND ls_intval TO gt_intval.
ENDIF.
WHILE lv_done IS INITIAL.
* find an interval to be processed
LOOP AT gt_intval ASSIGNING <intval>
WHERE activ = space
AND fails BETWEEN 0 AND 5.
EXIT.
ENDLOOP.
IF sy-subrc <> 0.
* no inactive unprocessed interval. All complete or must wait?
* check for intervals with unsuccesful tries
LOOP AT gt_intval ASSIGNING <intval>
WHERE fails BETWEEN 0 AND 5.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
* wait until all started processes have been received.
* Note: No receive is executed without WAIT
WAIT UNTIL gv_activ IS INITIAL UP TO 600 SECONDS.
ELSE.
* all done
lv_done = 'X'.
ENDIF.
UNASSIGN <intval>.
ENDIF.
* process interval if provided
IF <intval> IS ASSIGNED.
WHILE lv_task IS INITIAL.
IF lv_group IS INITIAL.
* init parallel processing
lv_group = task=>initialize( ).
ENDIF.
* get unused task
lv_task = task=>provide( ).
CHECK lv_task IS INITIAL.
* no unused task? wait for all started task are received
WAIT UNTIL gv_activ IS INITIAL UP TO 600 SECONDS.
ENDWHILE.
* call if task assigned
CHECK NOT lv_task IS INITIAL.
* prepare function parameters
ls_bapi_ref_doc_range = 'IBT'.
READ TABLE lt_vbelv INTO ls_bapi_ref_doc_range-ref_doc_low
INDEX <intval>-idxfr.
READ TABLE lt_vbelv INTO ls_bapi_ref_doc_range-ref_doc_high
INDEX <intval>-idxto.
* mark interval as failed
ADD 1 TO <intval>-fails.
ADD 1 TO gv_snd.
CALL FUNCTION gc_function
STARTING NEW TASK lv_task
DESTINATION IN GROUP lv_group
PERFORMING bapi_receive ON END OF TASK
EXPORTING
refdocrange = ls_bapi_ref_doc_range
EXCEPTIONS
communication_failure = 1 MESSAGE lv_msg
system_failure = 2 MESSAGE lv_msg
RESOURCE_FAILURE = 3.
IF sy-subrc = 0.
<intval>-activ = 'X'.
<intval>-task = lv_task.
ADD 1 TO gv_activ.
ELSE.
CALL METHOD task=>return EXPORTING name = lv_task.
ENDIF.
CLEAR lv_task.
ENDIF.
ENDWHILE.
* wait for pending processes
MESSAGE s000(r1) WITH 'Wait for pending processes'.
WAIT UNTIL gv_activ IS INITIAL.
* report unfinished intervals
LOOP AT gt_intval ASSIGNING <intval>
WHERE fails >= 0.
READ TABLE lt_vbelv INTO ls_bapi_ref_doc_range-ref_doc_low
INDEX <intval>-idxfr.
READ TABLE lt_vbelv INTO ls_bapi_ref_doc_range-ref_doc_high
INDEX <intval>-idxto.
MESSAGE i000(r1)
WITH
'Unverarbeitetes Intervall von'
ls_bapi_ref_doc_range-ref_doc_low
'bis'
ls_bapi_ref_doc_range-ref_doc_high.
ENDLOOP.
MESSAGE s000(r1) WITH 'start ALV'.
* transfer results to standard table
WRITE gv_rcv TO lv_grid_title LEFT-JUSTIFIED.
lv_grid_title+40(1) = '+'.
WRITE gv_snd TO lv_grid_title+50 LEFT-JUSTIFIED.
REPLACE '+' WITH 'RCV/SND' INTO lv_grid_title.
CONDENSE lv_grid_title.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_structure_name = 'BAPIVBRKSUCCESS'
i_grid_title = lv_grid_title
TABLES
t_outtab = gt_bapivbrksuccess.
ENDFORM. " paralleltest
*& Form bapi_receive
FORM bapi_receive USING pv_task TYPE any.
DATA:
lv_task TYPE numc4,
lt_bapivbrksuccess TYPE TABLE OF bapivbrksuccess,
lv_msg TYPE text80,
lv_subrc TYPE sy-subrc.
FIELD-SYMBOLS:
<intval> LIKE LINE OF gt_intval.
CLEAR lt_bapivbrksuccess.
RECEIVE RESULTS FROM FUNCTION gc_function
TABLES
success = lt_bapivbrksuccess
EXCEPTIONS
communication_failure = 1 MESSAGE lv_msg
system_failure = 2 MESSAGE lv_msg .
lv_subrc = sy-subrc.
lv_task = pv_task.
CALL METHOD task=>return EXPORTING name = lv_task.
LOOP AT gt_intval ASSIGNING <intval>
WHERE task = lv_task
AND fails <> -1.
EXIT.
ENDLOOP.
IF sy-subrc <> 0.
* fatal error
MESSAGE e000(r1)
WITH 'returned task' lv_task 'not in task table'.
ENDIF.
CLEAR <intval>-activ.
CASE lv_subrc.
WHEN 0.
<intval>-fails = -1.
APPEND LINES OF lt_bapivbrksuccess TO gt_bapivbrksuccess.
ADD 1 TO gv_rcv.
WHEN 1.
ADD 1 TO <intval>-fails.
WRITE: 'communication_failure for task', lv_task, lv_msg.
WHEN 2.
WRITE: 'system_failure', lv_task, lv_msg.
ADD 1 TO <intval>-fails.
ENDCASE.
SUBTRACT 1 FROM gv_activ.
ENDFORM. " bapi_receive
Regards,
Clemens -
I have written a module to read data from an external source, convert input to IDOCS, and process these IDOCS.
Due to performance of IDOC processing, I decided to use parallel processing to spread the IDOC creation load among several processes using server groups.
My main program sets up the parallel processing environment with a call to function module SPBT_INITIALIZE, then make repeated calls to a function module that processes the IDOCS, using the STARTING NEW TASK and DESTINATION IN GROUP xxx keywords.
What I'm seeing is the main process running as a background task and one dialog process running the parallel function module, even though there are still 8 or 9 other dialog processes available.
What I expected to see was several dialog process running my child function modules, not just the one.
Does anyone know why the other dialog processes are not being used?
Thanks for any input,
Dorian.Thomas:
I'm logging any errors that occur; I'm not seeing any resource failures - in fact no errors at all, other than expected application data errors. It seems that the RFC calls are all being made in a single child process that queues up the parallel jobs and uses just one dialog process to run them all. I expected to see as many dialog tasks being used as were available.
As far as the RFC parameters go - are you referring to the RZ10 values? I looked at all of the parameters containing "rfc" as part of their name, and nothing looked as though it was restricting the parallel task behaviour. Do you have any advice as to suitable settings?
I'm also wondering if what I am seeing is just the way SAP is supposed to work? Although I expected to see lots of child processes running in multiple dialogs if processes are available, maybe by design only one remote process per server is allowed? I checked the documentation I could find on the "starting new task" keyword, and nowhere does it say that multiple processes will be started on each server in the server group; only that a child process will NOT be started if the number of unused processes fall below a defined threshold. -
Parallel processing in background using Job scheduling...
(Note: Please understand my question completely before redirecting me to parallel processing links in sdn. I hve gone through most of them.)
Hi ABAP Gurus,
I have read a bit till now about parallel processing. But I have a doubt.
I am working on data transfer of around 5 million accounting records from lagacy to R/3 using Batch input recording.
Now if these all records reside in one flat file and if I then process that flat file in my batch input program, I guess it will take days to do it. So my boss suggested
to use parallel processing in SAP.
Now, from the SDN threads, it seems that we have to create a Remote enabled function module for it and stuf....
But I have a different idea. I thought to dividE these 5 million records in 10 flat files instead of just one and then to run the Custom BDC program with 10 instances which will process 10 flat files in background using Job scheduling.
Can this be also called parallel processing ?
Please let me know if this sounds wise to you guys...
Regards,
Tushar.Thanks for your reply...
So what do you suggest how can I use Parallel procesisng for transferring 5 million records which is present in one flat file using custom BDC.?
I am posting my custom BDC code for million record transfer as follows (This code is for creation of material master using BDC.)
report ZMMI_MATERIAL_MASTER_TEST
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case default
'/tmp/testmatfile.txt'.
DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
If it is nessesary to change the data section use the rules:
1.) Each definition of a field exists of two lines
2.) The first line shows exactly the comment
'* data element: ' followed with the data element
which describes the field.
If you don't have a data element use the
comment without a data element name
3.) The second line shows the fieldname of the
structure, the fieldname must consist of
a fieldname and optional the character '_' and
three numbers and the field length in brackets
4.) Each field must be type C.
Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record,
data element: MATNR
MATNR_001(018),
data element: MBRSH
MBRSH_002(001),
data element: MTART
MTART_003(004),
data element: XFELD
KZSEL_01_004(001),
data element: MAKTX
MAKTX_005(040),
data element: MEINS
MEINS_006(003),
data element: MATKL
MATKL_007(009),
data element: BISMT
BISMT_008(018),
data element: EXTWG
EXTWG_009(018),
data element: SPART
SPART_010(002),
data element: PRODH_D
PRDHA_011(018),
data element: MTPOS_MARA
MTPOS_MARA_012(004),
end of record.
data: lw_record(200).
End generated data section ***
data: begin of t_data occurs 0,
matnr(18),
mbrsh(1),
mtart(4),
maktx(40),
meins(3),
matkl(9),
bismt(18),
extwg(18),
spart(2),
prdha(18),
MTPOS_MARA(4),
end of t_data.
start-of-selection.
perform open_dataset using dataset.
perform open_group.
do.
*read dataset dataset into record.
read dataset dataset into lw_record.
if sy-subrc eq 0.
clear t_data.
split lw_record
at ','
into t_data-matnr
t_data-mbrsh
t_data-mtart
t_data-maktx
t_data-meins
t_data-matkl
t_data-bismt
t_data-extwg
t_data-spart
t_data-prdha
t_data-MTPOS_MARA.
append t_data.
else.
exit.
endif.
enddo.
loop at t_data.
*if sy-subrc <> 0. exit. endif.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=AUSW'.
perform bdc_field using 'RMMG1-MATNR'
t_data-MATNR.
perform bdc_field using 'RMMG1-MBRSH'
t_data-MBRSH.
perform bdc_field using 'RMMG1-MTART'
t_data-MTART.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
t_data-MAKTX.
perform bdc_field using 'BDC_CURSOR'
'MARA-PRDHA'.
perform bdc_field using 'MARA-MEINS'
t_data-MEINS.
perform bdc_field using 'MARA-MATKL'
t_data-MATKL.
perform bdc_field using 'MARA-BISMT'
t_data-BISMT.
perform bdc_field using 'MARA-EXTWG'
t_data-EXTWG.
perform bdc_field using 'MARA-SPART'
t_data-SPART.
perform bdc_field using 'MARA-PRDHA'
t_data-PRDHA.
perform bdc_field using 'MARA-MTPOS_MARA'
t_data-MTPOS_MARA.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM01'.
endloop.
*enddo.
perform close_group.
perform close_dataset using dataset. -
How to retrieve parallel process info (aRFC)
Hi guys , I have a program that calls 2 RFC-enabled function modules and runs them in parallel. To my knowledge, each function modules is assigned with a unique task id when performing parallel processing.
My question is, how do I retrieve the information on the individual process such as task name and its duration?
say
call function 'Z_XXX' starting new task 'A' performing 'Z_FUNC' on end of task.....
and
call function 'Z_XXX' starting new task 'B' performing 'Z_FUNC' on end of task .....
then execute these functions and let it runs for a while, then how do i retrieve the task name of each process programmatically (A and B)?
sorry I'm still pretty new when it comes to ABAP
edit:-
somehow my previous question was removed along with replies
Edited by: afro100 on Aug 27, 2009 1:51 PMHello,
You can use following function module to get the id of transactional processing.
CALL FUNCTION 'ID_OF_BACKGROUNDTASK'
* EXPORTING
* DEST = ' '
* IMPORTING
* TID = --> collect ID from this varaible
* FNUM =
and for reteriving status you can use:
CALL FUNCTION 'STATUS_OF_BACKGROUNDTASK'
EXPORTING
tid =
tables
errortab =
* EXCEPTIONS
* COMMUNICATION = 1
* RECORDED = 2
* ROLLBACK = 3
* OTHERS = 4
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Hope this helps!
Thanks,
Augustin. -
Parallel processing of mass data : sy-subrc value is not changed
Hi,
I have used the Parallel processing of mass data using the "Start New Task" . In my function module I am handling the exceptions and finally raise the application specific old exception to be handled in my main report program. Somehow the sy-subrc is not getting changed and always returns 0 even if the expection is raised.
Can anyone help me about the same.
Thanks & Regards,
NitinHi Silky,
I've build a block of code to explain this.
DATA: ls_edgar TYPE zedgar,
l_task(40).
DELETE FROM zedgar.
COMMIT WORK.
l_task = 'task1'.
ls_edgar-matnr = '123'.
ls_edgar-text = 'qwe'.
CALL FUNCTION 'Z_EDGAR_COMMIT_ROLLBACK' STARTING NEW TASK l_task PERFORMING f_go ON END OF TASK
EXPORTING
line = ls_edgar.
l_task = 'task2'.
ls_edgar-matnr = 'abc'.
ls_edgar-text = 'def'.
CALL FUNCTION 'Z_EDGAR_COMMIT_ROLLBACK' STARTING NEW TASK l_task PERFORMING f_go ON END OF TASK
EXPORTING
line = ls_edgar.
l_task = 'task3'.
ls_edgar-matnr = '456'.
ls_edgar-text = 'xyz'.
CALL FUNCTION 'Z_EDGAR_COMMIT_ROLLBACK' STARTING NEW TASK l_task PERFORMING f_go ON END OF TASK
EXPORTING
line = ls_edgar.
*& Form f_go
FORM f_go USING p_c TYPE ctype.
RECEIVE RESULTS FROM FUNCTION 'Z_EDGAR_COMMIT_ROLLBACK' EXCEPTIONS err = 2.
IF sy-subrc = 2.
*this won't affect the LUW of the received function
ROLLBACK WORK.
ELSE.
*this won't affect the LUW of the received function
COMMIT WORK.
ENDIF.
ENDFORM. "f_go
and the function is:
FUNCTION z_edgar_commit_rollback.
*"*"Interface local:
*" IMPORTING
*" VALUE(LINE) TYPE ZEDGAR
*" EXCEPTIONS
*" ERR
MODIFY zedgar FROM line.
IF line-matnr CP 'a*'.
*comment raise or rollback/commit to test
* RAISE err.
ROLLBACK WORK.
ELSE.
COMMIT WORK.
ENDIF.
ENDFUNCTION.
ok.
In your main program you have a Logical Unit of Work (LUW), witch consists of an application transaction and is associated with a database transaction. Once you start a new task, your creating an independent LUW, with it's own database transaction.
So if you do a commit or rollback in your function the effect is only on the records your processing in the function.
There is a way to capture the event when this LUW concludes in the main LUW. That is the PERFORMING whatever ON END OF TASK. In there you can get the result of the function but you cannot commit or rollback the LUW from the function since it already have implicitly happened at the conclusion of the funtion. You can test it by correctly comment the code I've supplied.
So, if you want to rollback the LUW of the function you better do it inside it.
I don't think it matches exactly your question, maybe it lead you on the right track. Give me more details if it doesn't.
Hope it helps,
Edgar -
Parallel processing open items (FPO4P)
Hello,
I have a question about transaction FPO4p (parallel processing of open items).
When saving the parameters the following message always appears : "Report cannot be evaluated in parallel". The information details tells that when you use a specific parallel processing object, you also need to use that field to sort on.
I my case I use the object GPART for parallel processing (see tab technical settings). In the tab output control I selected a line layout which is sorted by business partner (GPART). Furthermore no selection options are used.
Does anyone know why the transaction cannot save the parameters and shows the error message specified above. I really don't know what goes wrong.
Thank you in advance.
Regards, Ramon.Ramon
Apply note 1115456.
Maybe that note can help you
Regards
Arcturus
Maybe you are looking for
-
My Sites error - 403 and "We're almost ready!" plaguing web application
On an in-house managed farm, a My Site web application has been created per the instructions provided from Microsoft. The web application uses the managed path "personal" at the root of http://mysites. The initial "We're almost ready!" screen when a
-
Is it possible to print on a mac to a shared printer on a Windows desktop?
I have my windows XP desktop connected to a new HP printer which prints fine. I have my DSL internet connection split by using a router and on one port I connect it to my Airport express. The internet on both machines works fine. However, can I print
-
Does anyone know how to align hexagon shape in photoshop
help~ i have problem aligning my hexagon shape, they just don't have the same gap between each other...even when i turn the smart guide on it works the same (sorry for my bad english) well im using adobe photoshop cs6 extended, please give me tip & t
-
TS3623 Why does my tv buzz halfway through a film is it my cheap hdmi cable or not?
Why does my tv buzz halfway through a film is it my cheap hdmi cable or not?
-
Dear all, I am creating a new report which needs a conditional running total. I need to sum the credits quantity if the following condtions are met line_type="S" and line_no<3 I used running total like this Field to summarize: lab_credits2.credit_qty