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

Shared objects initialization - DB_COMMIT?

Clemenss
Active Contributor
0 Likes
707

Hi,

this question may be somewhat special:

In our project we want to minimize database accesses to certain never-changed customizing.

We implemented a class with static method. In class constructor, we get the customizing from root object of shared memory area.

We followed the steps outlined in Rich Heilman and Thomas Jung ABAP u2013 Next Generation.

In the automatic 'constructor' build method of root object they use CALL FUNCTION 'DB_COMMIT'. Altghough this is processed in a separate task and thus should not harm the caller, I do not understand the use of this statement.

Also, when reading data, they use a WAIT UP TO 1 SECONDS statement to allow the shared memory object to be in initialized. This causes an implicit database commit which is never wanted. I tried to avoid it by repeating the attach_for_read( ) call until I got the shared memory object. But here I don't know what happens if success never comes.

Where can I read more about shared memory objects? The online help does not provide too much.

Thanks in advance,

Clemens

3 REPLIES 3
Read only

thomas_jung
Developer Advocate
Developer Advocate
0 Likes
533

The DB_COMMIT is needed for the Auto Build option. The Area Constructor was called automatically becuase of this option and the transactional area only be built until a database commit occurs.

As far as the wait, the initialization can take a fraction of a second to a few seconds and is done asychronously. Therefore you need to halt the processing of your application while it takes place. The ABAP wait statement puts your dialog work process to sleep and therefore is the most efficient way to pass this time. You could also check within a loop, but you will be contstant consuming the work process and CPU time. It might be theoretically processing the loop pass thousands of times instead of just one or twice with the WAIT statement.

Read only

0 Likes
533

Thank you Thomas,

I used the loop to avoid the database commit because I just did not see any reason at all for a database commit in this situation. OK, no chance obviously.

Is there a way to create the root object synchronously without commit? I mean ist there a technical requirement for the commit?

Regards,

Clemens

Read only

0 Likes
533

I've personally always just gone on the word of the documentation which states a DB_COMMIT is required. I can't say that I've ever tried to research alternatives, as I would suspect there aren't any.