03-03-2010 11:39 AM
Hi everyone
I have a question about objects.
I want to use one object of a class in one application, and the same object in another application. At the same moment.
So i use a singleton to create my instance.
Now i've tested it and it seems this instance is not the same instance. So it looks like that one instance is created for each application.
But i need to write my data the the attributes of that one object, that is accessible between applications.
Is this uberhaupt possible ? If yes, how ?
Thx in advance !
Merijn.
PS: this refers to application logging. So if someone could provide some ideas about app. logging with use of abap objects, feel free ...
03-03-2010 12:30 PM
Hi Merijn,
in my opinion it is not possible to use one common object in two different applications.
Each application is using its own roll area, which you can compare like each application is executed in its own process.
But I think there are some possibilities to realize the communication between your applications.
1. you can use the filesystem or the database
2. if both application are executed in the same login session, you can use the SAP memory
3. I have no experience, but maybe you can use the services of a persistent class
4. depending on your requirements, maybe you can use async RFC like
example code from BC415 page 3-34
CALL FUNCTION u2019XYZu2019
DESTINATION u2019Bu2019
STARTING NEW TASK u2019T1u2019
PERFORMING UP1 ON END OF TASK
EXPORTING ...
TABLES ...
EXCEPTIONS
COMMUNICATION_FAILURE = 1
SYSTEM_FAILURE = 2.
...
FORM UP1 USING T.
RECEIVE RESULTS FROM FUNCTION u2019XYZu2019
IMPORTING ...
TABLES ...
EXCEPTIONS
COMMUNICATION_FAILURE = 1
SYSTEM_FAILURE = 2
FLIGHT_NOT_FOUND = 3.
...
ENDFORM.
These are only my ideas and I hope, that i did not write too much nonsens.
Regards, Hubert
03-03-2010 12:30 PM
Hi Merijn,
in my opinion it is not possible to use one common object in two different applications.
Each application is using its own roll area, which you can compare like each application is executed in its own process.
But I think there are some possibilities to realize the communication between your applications.
1. you can use the filesystem or the database
2. if both application are executed in the same login session, you can use the SAP memory
3. I have no experience, but maybe you can use the services of a persistent class
4. depending on your requirements, maybe you can use async RFC like
example code from BC415 page 3-34
CALL FUNCTION u2019XYZu2019
DESTINATION u2019Bu2019
STARTING NEW TASK u2019T1u2019
PERFORMING UP1 ON END OF TASK
EXPORTING ...
TABLES ...
EXCEPTIONS
COMMUNICATION_FAILURE = 1
SYSTEM_FAILURE = 2.
...
FORM UP1 USING T.
RECEIVE RESULTS FROM FUNCTION u2019XYZu2019
IMPORTING ...
TABLES ...
EXCEPTIONS
COMMUNICATION_FAILURE = 1
SYSTEM_FAILURE = 2
FLIGHT_NOT_FOUND = 3.
...
ENDFORM.
These are only my ideas and I hope, that i did not write too much nonsens.
Regards, Hubert
03-03-2010 12:42 PM
certainly no nonsens for me
I'm still a beginner.
Well i looked up the 'persistent class' idea, and maybe it wil do, but i have to read much much more.
Maybe I can use the db too, that's a last resort, but i'll think it over.
Thx for the answers !
03-03-2010 8:45 PM
Hello,
Shared Memory Objects are the solution for this problem. Check the online help or the SDN for details.
Concerning logging: There are function modules provided by SAP. Check the function modules within function group SBAL for an introduction. You will also find information in the SDN.
Unfortunately, the functionality is not provided through OO classes. Maybe in future releases...
Regards
David
03-04-2010 10:09 AM
Hi,
So the persistent classes are not an option ?
But i would like to create an own OO-solution to be able to log all the messages.
I tried it with factory pattern but didn't work out good enough (but my pattern could be wrong implemented :-s ).
In my own design, i use the correct functions (BAL ... ).
I just need a design for this problem.
applications.
-> each application must use the same application log to buffer the messages
-> at the end of the day, so after the run (that sends batches), the application log must be closed, and must write the buffered messages to db.
-> On the meanwhile, other messages of these applications could be written, so a new application log must be created tu buffer these message, while the old one keeps writing to db.
Maybe this could help...
Thx already for your interests
03-05-2010 7:30 AM
Hi MerijnBlommaert,
Even though I am not sure on Application logging, I can surely help you out in your requirement of using the same object in different programs. For this you can use Persistent Services.
Please refer the following [link|http://help.sap.com/saphelp_nw2004s/helpdata/en/f5/a3682ebc6911d4b2e80050dadfb92b/content.htm].
[Persistence Service|http://help.sap.com/saphelp_47x200/helpdata/EN/fd/022008bc9311d4b2e80050dadfb92b/content.htm]
Regards,
Pranaam.
Edited by: Pranaam on Mar 5, 2010 1:00 PM
Edited by: Pranaam on Mar 5, 2010 1:04 PM
03-05-2010 9:34 AM
Thanks for the information.
I already looked at your links, but for someone who's not that experienced in sap/abap, this is hard work :-).
I'll try to implement it as persistent object, if that's allright with my colleagues.
Thanks to everyone who posted their helpful answers.
I will mark this question as answered. If i have another problem, i'll bother you again. 😄