Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

parallel processing issues

ankit_munshi2
Participant

Hello Experts,

I am having an issue with implementing parallel processing for an SQVI query. The query takes too long, so we decided to wrap the query in a custom FM and then call the custom FM in parallel for chunks of data. problem is return_data method is not getting called, below is the code :

I did try to search the existing forums but didnt find an appropriate answers.

CALL FUNCTION 'ZTEST_AM' STARTING NEW TASK lv_task DESTINATION IN GROUP DEFAULT "'parallel_generators'
CALLING return_data ON END OF TASK
TABLES
xt_ever = lt_ever
" yt_device = gt_device[]
EXCEPTIONS
no_data = 1
OTHERS = 2.
IF sy-subrc EQ 0.
COMMIT WORK.
lv_sent = lv_sent + 1.
ENDIF.
ENDDO.

WAIT UNTIL gv_comp LE lv_sent.

*****************************************

METHOD return_data.

DATA : lt_device2 TYPE TABLE OF zemst_device.

RECEIVE RESULTS FROM FUNCTION 'ZTEST_AM'
TABLES
yt_device = lt_device2[].

APPEND LINES OF lt_device2[] TO gt_device[].
gv_comp = gv_comp + 1.

ENDMETHOD.

***********************************

1 ACCEPTED SOLUTION

matt
Active Contributor

How do you know that the method isn't being called? Have you run in debug? Is suspect not, or you would have noticed that your code contains a pretty basic error. You wait until gv_comp until it is less than lv_sent. Then in each return you add 1 to gv_comp. Not going to work, is it? Maybe you should wait until gv_comp is greater than or equal to lv_sent?

Tip: when you have a program not working as expected, try running in debug before posting here.

9 REPLIES 9

matt
Active Contributor

How do you know that the method isn't being called? Have you run in debug? Is suspect not, or you would have noticed that your code contains a pretty basic error. You wait until gv_comp until it is less than lv_sent. Then in each return you add 1 to gv_comp. Not going to work, is it? Maybe you should wait until gv_comp is greater than or equal to lv_sent?

Tip: when you have a program not working as expected, try running in debug before posting here.

Sandra_Rossi
Active Contributor
0 Kudos

There's no proof that the OP didn't debug, because, as you said, the WAIT UNTIL doesn't wait, so probably the query terminates and displays the result, and consequently the callback method cannot be called.

matt
Active Contributor
0 Kudos

Debugging the process would have caught that. So, no proof, but there is evidence...

Sandra_Rossi
Active Contributor
0 Kudos

My bad, I wasn't clear too. I mean that the OP might have debugged by setting a break point at the callback method only, so he just didn't debug enough ; it happens to everybody to not see an obvious problem, and need to ask fellow developers to point it out.

former_member242292
Discoverer
0 Kudos

Hello Ankit,

As you have provided only parts of the source it is hard to see the actual scope of the variables. What I would suggest is to have a single variable containing the number of started parallel processes (for example "gv_started_processes"), which should be increased by 1 if the function "ZTEST_AM" has been executed successfully and decreased by 1 in a call-back method, when new data has been received.

After that you could use the statement "WAIT UNTIL gv_started_processes = 0".

ptrck
Explorer
0 Kudos

Can you paste the signature of return_data? Is it a public method? 1 clike importing parameter?

BTW: use WAIT FOR ASYNCHRONOUS TASKS

Jelena
Active Contributor

I suspect the real problem is right here: "parallel processing for an SQVI query". Why are you doing this in a user-specific query? Have you tried to find the root cause of the bad performance? Maybe much better solution would be to create an ABAP program and have more efficient data selection without any parallel processing? I like queries (SQ01 ones, not SQVI) as much as the next guy but they have some limitations.

former_member182466
Contributor
0 Kudos

In addition to what Matthew mentions you will also need to add the following exceptions to your function call:

COMMUNICATION_FAILURE
SYSTEM_FAILURE
RESOURCE_FAILURE

Otherwise you won't really know that the call was triggered successfully.

Also your code has an ENDDO but no DO. I suspect you chop up the EVER table into chunks in your DO and pass those to function call. If you create more chunks than you have processes available the call will fail and you'd have to wait for processes to become available. The SAP help has a sample program, I know it has a few syntax errors, if I remember correctly there is at least an ENDCASE missing but it does give a good outline on how to do parallel processing. Also, make sure your LV_TASK is unique for every call you make.

ankit_munshi2
Participant
0 Kudos

Thank you guys!!

There was a typo in the program . Wait statement had LE in it (instead of GE). I debugged and found it out finally. Remaining code is working fine.

Thank you very much for your valuable inputs all!!