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

transient object to persistent

Former Member
0 Likes
1,053

Hi all,

How can I make persistent a previously created transient object? I mean, is there any other way of making it persistent instead of executing method CREATE_PERSISTENT( attributes ) ??

Maybe something like:


MyTransientObject = Agent->Create_Transient( ... )
...
MyTransientObject->MakePersistent( )

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
975

Hi Jorge,

what I was suggesting was to just call the create_persistent method with the attributes of the transient object except the business key. Then you will get a new business key for the persistent object. Then overwrite the reference to the transient object with the new persistent object reference.

Something like this.

MyTransientObject = Agent->Create_Transient( ... )
...
MyPersistentObject = Agent->Create_Persistent( ... ).
MyTransientObject ?= MyPersistentObject.

Cheers

Graham

5 REPLIES 5
Read only

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
975

Hi Jorge,

it seems not. I have just looked through the doco and has a quick play and I can't see any inbuilt method to do this. I guess you just need to code your own MakePersistent method to do this.

Cheers

Graham

Read only

0 Likes
975

Thanks Graham,

unfortunately, if I try to create one persistent object from an already created transient object, an error occurs due to business key already is used by my transient object.

Persistent and Transient objects verify if business key is already being used.

So it seems that is not possible to create persistent objects from transient ones.

If this is correct, I don't know when to use transient objects, just for avoiding to create more than one object with same business key???

Read only

0 Likes
975

Hi Jorge,

you should be able to create a new persistent object with all the attributes of the transient object except the business key.

You then just need to update the object reference to the transient key to point to the instance of the new persistent object.

Cheers

Graham

Read only

0 Likes
975

Hi Graham,

I think your solution will not work, I guess I can't create a persistent object without business key; even if this is possible, business key is not modifiable, its only allowed to set value to the business key in CONSTRUCTOR methods, there are no SET methods for it.

Thanks again.

Read only

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
976

Hi Jorge,

what I was suggesting was to just call the create_persistent method with the attributes of the transient object except the business key. Then you will get a new business key for the persistent object. Then overwrite the reference to the transient object with the new persistent object reference.

Something like this.

MyTransientObject = Agent->Create_Transient( ... )
...
MyPersistentObject = Agent->Create_Persistent( ... ).
MyTransientObject ?= MyPersistentObject.

Cheers

Graham