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: 

How to call a class instance from e.g. 10 different parallel processes?

former_member205645
Participant
0 Kudos

Hello Gurus,

i have created a class instance in one abap Process/Mode and i want to access this instance from other parrallel jobs. I pass the instance and other values to the new created Dialog Jobs/Processes but i am losing the instance while the values are still there. The question is if that is possbile in ABAP - i tried with a SPA/GPA but the parameters are type text so the garbage collector erases my instance. Any ideas?

Regards,

Ioan Constantin.

1 ACCEPTED SOLUTION

MarcinPciak
Active Contributor
0 Kudos

It depends what you are actually denoting as a process here. Do you mean separate external sessions?

In any case passing references via memory I think is not possible. This is like passing a handle for object which exists only in program's roll area. Once you terminate the program that handle would become empty. I think the only way is to flatten object (serialize it), and then pass it either to memory or store it under persistent form (i.e. as table record). Then in next "process" deflatten (deserialize) it.

This is more or less the same process which workflow uses. Every class which can "interact" with workflow must implement interface IF_WORKFLOW . In that you have to program yourself how the object will look like in persistent form, then how it will retrieve an object from this persistent form. This kind of action must be done as workflow runs asynchronously . One user creates workflow object then leaves the session (garbace collector flushes the memory so no more object exists there). After some time another user wants to access the same item (object). The only way to have this done is to restore it from persisten form and recreate.

Note!

Even the objects data are the same (attributes) there will be two separate instances in these processes, which you can't compare.

Regards

Marcin

4 REPLIES 4

MarcinPciak
Active Contributor
0 Kudos

It depends what you are actually denoting as a process here. Do you mean separate external sessions?

In any case passing references via memory I think is not possible. This is like passing a handle for object which exists only in program's roll area. Once you terminate the program that handle would become empty. I think the only way is to flatten object (serialize it), and then pass it either to memory or store it under persistent form (i.e. as table record). Then in next "process" deflatten (deserialize) it.

This is more or less the same process which workflow uses. Every class which can "interact" with workflow must implement interface IF_WORKFLOW . In that you have to program yourself how the object will look like in persistent form, then how it will retrieve an object from this persistent form. This kind of action must be done as workflow runs asynchronously . One user creates workflow object then leaves the session (garbace collector flushes the memory so no more object exists there). After some time another user wants to access the same item (object). The only way to have this done is to restore it from persisten form and recreate.

Note!

Even the objects data are the same (attributes) there will be two separate instances in these processes, which you can't compare.

Regards

Marcin

0 Kudos

> This is more or less the same process which workflow uses. Every class which can "interact" with workflow must implement interface IF_WORKFLOW . In that you have to program yourself how the object will look like in persistent form, then how it will retrieve an object from this persistent form.

Nice point Marcin!

@OP: To add to Marcin's response, the persistent form of the object reference is hence called L ocal P ersistent O bject R eference or LPOR !

0 Kudos

Hello Marcin,

thank you for the answer. I am familiar with the IF_WORKFLOW interface, i know what you mean.

Regards

Ioan.

Former Member
0 Kudos

Hello Ioan,

by using so-called Shared Objects you can buffer and share references across sessions. The classes in question have to be shared memory enabled (property) and have to be created in the shared memory (CREATE OBJECT.. AREA HANDLE..). Using them is only possible while you have bound/attached your session to a shared memory area; check the docu for Shared Objects in general and transactions SHMM, SHMA in particular.

Hope this helps, regards,

Sebastian