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

Passing objects between programs

Former Member
0 Likes
5,003

Can we pass reference of an object from on e program to other using submit or call transaction??

1 ACCEPTED SOLUTION
Read only

wol
Active Participant
0 Likes
2,398

Hello Nikita,

there are the following possibilities:

  1. Use persistent classes. You can load your object by defined business key in any other program in the same mode.
  2. Implement a factory-like class: It could remember / cache the objects in a static table an return them by a key or ohter get-logic (bit similar to possibility 1.)
  3. Serialize / deserialize:
    Serialization is a common technique to put complete objects into data and retrieve them. Your class could have some static factory-like methods which serialize / deserialze the object in a data string.
    Makes sense if the object is of data nature.
  4. use ABAP Shared Objects:

Info from SAP:

Shared Objects

Shared Objects are objects in the shared memory. Instances of classes and anonymous data objects can be stored. Named data objects can be stored as attributes of classes.

If you want, I give you more info for one of the possibilities.

Greets

Stefan

9 REPLIES 9
Read only

Former Member
0 Likes
2,398

Check the demo program and get the idea of using SPA/GPA parameters....

DEMO_PROGRAM_CALL_TRANSACTION

Read only

Former Member
0 Likes
2,398

Hi Nikita ,

ABAP programs have access to two cross-program memory areas that can be used for passing data :-

1.SAP Memory

Application programs that use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters).


2.ABAP Memory

ABAP memory is a memory area that all ABAP programs within the same internal session can access using the EXPORT and IMPORT statements. Data within this memory area remains throughout a sequence of program calls, with the exception of LEAVE TO TRANSACTION.



Regards,

Praveen Srivastava


Read only

0 Likes
2,398

This message was moderated.

Read only

Former Member
0 Likes
2,398

Yes we can  ,

sample is here  :

SUBMIT rfumsv00

       USING SELECTION-SCREEN '1000'

       WITH br_bukrs EQ p_bukrs

       WITH br_belnr IN s_belnr

       WITH br_gjahr IN s_fyear

       WITH br_budat IN s_pdate

       WITH br_xblnr IN s_xblnr

AND RETURN.

Read only

Former Member
0 Likes
2,398

Hello Nikita,

You can use SET/GET parameters or Shared Memory Area.

Read only

Former Member
0 Likes
2,398

You can also use Class with static attributes store/retreive the data.

1) in the 1st program you would call the class=>staticattribue and set the value. Use a set method to set the value.

2. in the 2nd program you would use a get method to return the value from the static variable in the class.

Thanks

Kumaran

Read only

former_member219762
Contributor
0 Likes
2,398

Hi,

We cannot pass object reference with set,get parameters and export import statements.If you want use object reference define that class as singleton and get instance in other internal session(submit or call transaction).Singleton gives same object reference for all internal sessions in given external session.

Regards,

Sreenivas.

Read only

wol
Active Participant
0 Likes
2,399

Hello Nikita,

there are the following possibilities:

  1. Use persistent classes. You can load your object by defined business key in any other program in the same mode.
  2. Implement a factory-like class: It could remember / cache the objects in a static table an return them by a key or ohter get-logic (bit similar to possibility 1.)
  3. Serialize / deserialize:
    Serialization is a common technique to put complete objects into data and retrieve them. Your class could have some static factory-like methods which serialize / deserialze the object in a data string.
    Makes sense if the object is of data nature.
  4. use ABAP Shared Objects:

Info from SAP:

Shared Objects

Shared Objects are objects in the shared memory. Instances of classes and anonymous data objects can be stored. Named data objects can be stored as attributes of classes.

If you want, I give you more info for one of the possibilities.

Greets

Stefan

Read only

Former Member
0 Likes
2,398

Yes Stefan is right

check this link

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/307d791b-3343-2e10-f78a-e1d50c7cf...

Thats SAPs latest answer to this issue.

what i have done for myself

i have serialized the object into a table like indx and then reseraaÅŸize it back

and i had the exact object

thats what i have done to save the object.

if you need more info i can let you know more

but stefans solution is better