Application Development and Automation 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: 
Read only

WAIT UNTIL during parallel processing - condition true, when obviously false

matt
Active Contributor
0 Likes
3,429

From the debugger

   WAIT UNTIL used_slots LT slots_allocated.
    " Get number of first free slot
    READ TABLE slots WITH KEY used = abap_false REFERENCE INTO DATA(slot).
    ADD 1 TO used_slots.
    slot->used = abap_true.
    ret_result = slot->task_name.

Clearly used_slots is not less than slots_allocated.

Any suggestions? Thanks,

matt

1 ACCEPTED SOLUTION
Read only

MateuszAdamus
Active Contributor
2,784

Hello matthew.billingham

Just a guess, but maybe that's the reason: "If the result of log_exp is false and there is no asynchronous function call with a callback routine, the execution of the program is not interrupted (regardless of the result of log_exp) and sy-subrc is set to the value 4.". Although, you probably checked this already.

https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapwait_until.htm

Kind regards,

Mateusz

5 REPLIES 5
Read only

MateuszAdamus
Active Contributor
2,785

Hello matthew.billingham

Just a guess, but maybe that's the reason: "If the result of log_exp is false and there is no asynchronous function call with a callback routine, the execution of the program is not interrupted (regardless of the result of log_exp) and sy-subrc is set to the value 4.". Although, you probably checked this already.

https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapwait_until.htm

Kind regards,

Mateusz

Read only

2,784

Also, from the same SAP Help page: "If the new check on the result of the logical expression is false and the callback routines of the functions previously called asynchronously were all executed, sy-subrc is set to 4 and the execution of the program is resumed with the statement that follows WAIT.". This gives me an idea, that maybe records of the USED_SLOTS internal table are not updated properly. Have you checked that part?

What is the SY-SUBRC value after the WAIT?

Kind regards,

Mateusz
Read only

matt
Active Contributor
2,784

You got it first time - although I was thinking it must the second one, initially. I saw asynchronous function calls with callback executing - but then I checked ST22 and found dumps... I'd a typo in the FM name. It didn't exist...

Read only

0 Likes
2,784

The lack of function name validation during code activation should be added long time ago...

Glad you've found the issue.


Kind regards,
Mateusz
Read only

michael_piesche
Active Contributor
0 Likes
2,784

matthew.billingham, what is the general logic behind used_slots and slots_allocated and how do both values change over time?

In my scenarios of applying parall processing, I would manage the parallel tasks this way:

  1. Determine how many parallel tasks are necessary and available (e.g. n-tasks)
    If necessary tasks are less than available, n will be equal to necessary tasks
    If available tasks are less then necessary, n will be equal to available tasks
  2. Start n-parallel tasks and add 1 to count_tasks for each task started
  3. Add 1 to finished_tasks for each task that is finished
  4. Wait for all n-parallel tasks to end which is when count_tasks = finished_tasks:
    During the execution of the WAIT UNTIL command, count_task has the value n from the beginning and finished_tasks will gradually get higher until it also has the value of n, which takes place when all tasks are finished.

In your scenario, I assume you have m parallel tasks, but only n available slots at the same time for processing the tasks (n < m). That way, you can only start n tasks right away, and have to queue the remaining tasks until the first set of tasks are finished. Once a task is finished, you will take the first next task in the queue and start it.

Is this correct so far?
The interesting question would be then, how and when do the counters for used_slots and slots_allocated change over time? Are both 'moving' targets?
I am not sure if my questioning is going to solve your problem, but I am trying to understand the logic first.