cancel
Showing results for 
Search instead for 
Did you mean: 

Save project B from project A

daniel_humberg
Contributor
0 Kudos

I have a requirement to update a certain project (project B) whenever a certain other project is changed (project A).

For that, I am planning to create a subsystem that is called whenever project A is changed (works fine).

I am also able to load project B (cl_dpr_appl_object_manager=>LOAD_PROJECTS ).

However, how can I save project B?

Using cl_dpr_appl_object_manager=>SAVE_CHANGES will not work, since it will also save project A and therefore cause an endless loop.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Daniel,

A subsystem is a good idea. However, I am not sure you would run into an infinite loop. When you call a save on Project B, yes a save will be called on Project A as well. However, since A has already committed, there will be no changes on it (the method has_changes() will fail) and hence save will do no further processing.

However, you might run into issue with DPR_TRANSACTION_MANAGER if not anything else.

While you will have to play around the transaction manager, it would be a good bet to call the save in the method INITIALIZE_AFTER_SAVE() of the subsystem, since that will be called after the first project has been persisted.

Do use the BAPI as mentioned in the other reply and not he save_changes() method of the object manager.

If project B will be updated once 'save' is pressed, then another idea would be to write an exit that will be called immediately when the 'save' button is pressed and does all the required updates to B before handing control back to project A. Only one save will then be performed and both the projects will be committed (since both are in the same session). In this case, be sure that the subsystem doesn't do a save since the save of the first project will be sufficient.

Hope this helps,

Best Regards,

Prashanth

daniel_humberg
Contributor
0 Kudos

I think doing that save asynchronously is the best option for me. Therefore, I will in deed queue all the projects that need to be updated, and save them using a background job that runs regularly.

Answers (1)

Answers (1)

Former Member
0 Kudos

Daniel,

You have a interesting problem. Why don't you create a background job ( to be released and execute immediately) to save changes in Project B when you save Project A (using subsystem). You may use standard BAPI s to make changes and save changes in Project B. Since the background job will run in its own session, it will not affect project A.

This approach will have added advantage to enable you to handle the situation when somebody is having project B locked when you are trying to update it. In that situation, background job can create and reschedule another job to run after 5-10 minutes.

I hope it helps.