‎2009 Jan 15 1:59 PM
Hello
I'll try to explain me well
Iu2019m creating an interface between SAP and 3 different robots
The design roughly is as follows
Thereu2019s one interface with the definition of the common methods (Abstract)
Each robot is a class that implements this interface
Iu2019d like to execute the methods of this classes using something similar at the concept of threads in JAVA (create, pause, resume, finish, abort, etc )
I think about simulating threads using jobs but i can't stop, resume a job, somebody can give me another idea¿?
Thanks and regards
‎2009 Jan 18 2:23 PM
I'm not familiar with threads, but I think I can understand what it is (tell me if I'm wrong).
In SAP, threads are at a higher level : jobs as you say, but more generally SAP uses the term "[workprocesses|http://help.sap.com/saphelp_nw2004s/helpdata/en/69/c24e104ba111d189750000e8322d00/frameset.htm]".
I think that threads are used to achieve better performance, but we usually don't need this level of performance in SAP as its architecture is scalable (buy more memory, more processors, etc.)
For information, In SAP, we achieve parallel execution by using [parallel RFC|http://help.sap.com/saphelp_nw04s/helpdata/en/22/0425c6488911d189490000e829fbbd/frameset.htm], via [lock concept|http://help.sap.com/saphelp_nw2004s/helpdata/en/c2/2d7037ecc92a7ee10000009b38f8cf/frameset.htm] which is based on [lock objects|http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21eea5446011d189700000e8322d00/frameset.htm].
And when we need to "serialize" execution, we use simple home-made "wait for" algorithms.
What do you mean by "robot" (machine or scan program?) Why do you exactly need threads for ? (maybe this question makes no sense but I'm not familiar as I said)
Can you create a master program which controls the executions? When everything is finished, it stops.
‎2009 Jan 19 2:03 AM
Hi,
I just want to add some comments and ideas. As Sandra mentioned and as far I know there are no threads in ABAP. What you can do is to start new task by calling FM with additional option IN NEW TASK. Then you will have separate process for each FM call. Generally, threads share memory. The ABAP tasks do not share memory. Hence you need to find another way of passing information between tasks. One way is to use DB tables for this purpose. Another way is to use data clusters (check commands EXPORT/IMPORT). You could also use files but that's probably really stupid. You can use SAP lock objects to solve the problems with concurrent access.
Transaction SM50 will be very useful transaction for you. You can attach to the running process from here and run debugger for it. Hence you will be able to connect to your tasks and see what's going on there.
Main program (basic structure only):
DATA: l_a TYPE c.
CALL FUNCTION 'ZCREATE_ROBOT' STARTING NEW TASK 'R1'.
CALL FUNCTION 'ZCREATE_ROBOT' STARTING NEW TASK 'R2'.
CALL FUNCTION 'ZCREATE_ROBOT' STARTING NEW TASK 'R3'.
WHILE l_a IS INITIAL.
* Check for messages from robots.
<IMPORT message from R1>
<IMPORT message from R2>
<IMPORT message from R3>
* Some Logic
* Change status for each robot r.g. pause, resume
<EXPORT status for R1>
<EXPORT status for R2>
<EXPORT status for R3>
ENDWHILE.
Cheers
‎2009 Feb 18 12:26 PM