How to synchronize concurrent access to static data in ABAP Objects

Hi,
1) First of all I mwould like to know the scope of static (class-data) data of an ABAP Objects Class: If changing a static data variable is that change visible to all concurrent processes in the same Application Server?
2) If that is the case. How can concurrent access to such data (that can be shared between many processes) be controlled. In C one could use semaphores and in Java Synchronized methods and the monitor concept. But what controls are available in ABAP for controlling concurrent access to in-memory data?
Many thanks for your help!
Regards,
Christian

Hello Christian
Here is an example that shows that the static attributes of a class are not shared between two reports that are linked via SUBMIT statement.
*& Report  ZUS_SDN_OO_STATIC_ATTRIBUTES
REPORT  zus_sdn_oo_static_attributes.
DATA:
  gt_list        TYPE STANDARD TABLE OF abaplist,
  go_static      TYPE REF TO zcl_sdn_static_attributes.
<i>* CONSTRUCTOR method of class ZCL_SDN_STATIC_ATTRIBUTES:
**METHOD constructor.
*** define local data
**  DATA:
**    ld_msg    TYPE bapi_msg.
**  ADD id_count TO md_count.
**ENDMETHOD.
* Static public attribute MD_COUNT (type i), initial value = 1</i>
PARAMETERS:
  p_called(1)  TYPE c  DEFAULT ' ' NO-DISPLAY.
START-OF-SELECTION.
<b>* Initial state of static attribute:
*    zcl_sdn_static_attributes=>md_count = 0</b>
  syst-index = 0.
  WRITE: / syst-index, '. object: static counter=',
           zcl_sdn_static_attributes=>md_count.
  DO 5 TIMES.
<b>*   Every time sy-index is added to md_count</b>
    CREATE OBJECT go_static
      EXPORTING
        id_count = syst-index.
    WRITE: / syst-index, '. object: static counter=',
             zcl_sdn_static_attributes=>md_count.
<b>*   After the 3rd round we start the report again (via SUBMIT)
*   and return the result via list memory.
*   If the value of the static attribute is not reset we would
*   start with initial value of md_count = 7 (1+1+2+3).</b>
    IF ( p_called = ' '  AND
         syst-index = 3 ).
      SUBMIT zus_sdn_oo_static_attributes EXPORTING LIST TO MEMORY
        WITH p_called = 'X'
      AND RETURN.
      CALL FUNCTION 'LIST_FROM_MEMORY'
        TABLES
          listobject = gt_list
        EXCEPTIONS
          not_found  = 1
          OTHERS     = 2.
      IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL FUNCTION 'DISPLAY_LIST'
*       EXPORTING
*         FULLSCREEN                  =
*         CALLER_HANDLES_EVENTS       =
*         STARTING_X                  = 10
*         STARTING_Y                  = 10
*         ENDING_X                    = 60
*         ENDING_Y                    = 20
*       IMPORTING
*         USER_COMMAND                =
        TABLES
          listobject                  = gt_list
        EXCEPTIONS
          empty_list                  = 1
          OTHERS                      = 2.
      IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDIF.
  ENDDO.
<b>* Result: in the 2nd run of the report (via SUBMIT) we get
*         the same values for the static counter.</b>
END-OF-SELECTION.
Regards
  Uwe

Similar Messages

  • How does the Concurrent Access License (CAL) work.

    Description from Google: How does the Concurrent Access License (CAL) work? Xcelsius Engage Server CALs allow for concurrent live data updates inside Xcelsius dashboards. Every time an end-user triggers a Web service inside an Xcelsius dashboard to retrieve live data, a CAL is consumed for a period of 5 minutes. For that period, in a five CAL deployment for example, there will be only four CALs left for consumption. A five CAL deployment could support up to 25 users and additional CALs can be added to support a larger deployment.
    My question is as follows:
    How a five CAL deployment could support up to 25 users and what does it mean. In the first line it is saying that each CAL for a web service is consumed for a period of 5 minutes and how come it can support 25 users concurrently. Did it mean 25 web service connections inside a swf flash file or 25 different users to access a single web service through swf flash.

    The "Set cost controls" concurrent program is used in R12 to mass update the cost control fields on item costs.
    The cost control region is found by going to Cost management >Item costs > Item Costs
    The concurrent program lets you specify which items /costs should be updated by using various parameters such as cost type, item range, category range etc.
    And you can specify the source for the new cost control data and the new value for the fields.
    Hope this answers your question,
    Sandeep Gandhi

  • Static data in runnable objects of threadpool

    hi all,
    I have a threadpool and schedule Runnable objects into it.
    The runnble objects are run as per schedule.
    But I want to declare and initialize a static data in the runnable object. And I expect it to be initialised only once ie, the first time the runnable object is invoked by the threadpool and to be ignored in the subsequent scheduled invocations. And I want to access the static data throught the runnable object.
    I want to know whether the above behavior will take place or should i use any other ways to do this.

    Then maybe something like this?
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.List;
    import java.util.Date;
    public class RunnableWithPreviousState implements Runnable {
        private static class State {
         public Date startTime, endTime;
         public State() {
             startTime = new Date();
        private static List<RunnableWithPreviousState> runnables = Collections
             .synchronizedList(new ArrayList<RunnableWithPreviousState>());
        private State previousState, myState;
        @Override
        public void run() {
         myState = new State();
         runnables.add(this);
         int index = runnables.indexOf(this);
         if (index > 0) {
             index -= 1;
             previousState = runnables.get(index).myState;
         if (previousState != null) {
             // inspect previousState
         // do other processing
         myState.endTime = new Date();
    }Piet

  • Concurrent access to changing data structure

    I would like to design a data structure that would allow multiple read only threads to access it but periodically allow the structure to be modified or completely refreshed by one other thread. I would prefer to not have to synchronize access to the structure by the read only threads just to allow one thread to modify it once in a while. Can the object be locked and the other threads blocked just when the one thread is modifying the structure until it completes?
    Is there a common or recommended design for this situation?

    So you want it to block while the writer is writing, but not otherwise, correct?
    Check out Doug Lea's concurrency package. I've never used it, but it seems quite popular and I gather it's got a lot of handy tools. It might have what you're looking for. Google for it. It (or something based on it) might even be included in 1.5/5.0, IIRC.
    Barring that, I think that if your reads are quick (i.e., just retrieving a single value) and you don't have a ton of threads all doing a lot of very, very frequent reads, then you can just synchronize all access to the structure's state. Uncontended locks are quick to obtain and release, so unless your reads take a relatively long time or they're very densely packed in time, you won't get many collisions.
    If you do need to implement something like this, then what I'm thinking of is to have a flag that indicates whether there's a read or write going on. If there's a read going on, other reads can go on, but no writes. If there's a write going on, no other writes or reads can occur. Access to the flag would have to be synchronized, readers/writers would have to wait/notify each other, so you might not end up saving that much performance-wise anyway. I'm not even sure if there's a good way to make it work--it might just end up being an overcomplicated, non-working double-checked lock.
    Start with just syncing all access to the structure's state--both read and write--and then run some tests to see if your performance requirements are met.

  • A way to access SVG event data for an object?

    Is there a way to access the SVG event data for an object through scripting?

    post this in the correct forum - you will get a better response (btw the correct forum is KVM)
    to answer your question - any extra functionality above the MIDP1.0 specification will be manufacturer specific (and as such hardware dependant)
    I only know 2 of the APIs extensivly (the Nokia and Siemens) neither of these offer access to the phonebook or the message folder (it would be a security risk) I don't think they provide the cell id either.
    and no, there is no way to access the cellular phones OS. (on any phone!) it would completely destroy the purpose for having java on the phone.

  • Accessing a static varible from different object at the same time

    hi
    assume that i have calss it contains a static variable i am creating
    N numbere object of that class and i am try to access the static variable at the same time from different object.if i access like that any problem(deadlock) will occure or not? plz help me
    with regards
    suresh

    FeedFeeds : Read news and blogs a new way!
    http://www.feedfeeds.com
    Please don�t spread any kind of propaganda in this forum...;-)

  • How can i gain access to my data on a Time Capsule after a fresh install of Mavericks? I can't access any backups through Time Machine... They appear purple/transparent, and I can't even select them to view their contents. PLEASE HELP!!!

    So, I've got several thousand photos, and a decent amount of videos of my daughter, along with a lot of stuff for work stored on my Time Capsule, and now I can't access any of it. I did a fresh install of Mavericks on my MacBook Pro last week sometime, and haven't been able to figure out how to get my files back. Please Help!!! My daughter is 2 and a half, and every picture/video I have of her is locked on this thing. I was planning on making some photo/video projects fo my wife for Christmas, and now I'm definitely not going to be able to pull it off. Her birthday is at the end of January, though, so if I could have it by then, that would rule!
    Basically, the bar on the right of the screen has some gray dates, which I can access (all backups after the Mavericks install), and purple dates that go all the way back to March (when I originally purchased and began using the TC) which deny me access/viewing. It's possible that I created a slightly different user name when I reset my MacBook, which I guess is most likely the cause, but I have no idea what to do now to correct it. Thanks for taking the time!

    Mavericks does really nasty stuff..
    Try manually mounting the sparsebundle and extract the files you want.
    Yet another Pondini reference. http://pondini.org/TM/15.html
    We have avoided Mavericks you see knowing that it would cause these kinds of issues..
    You never ever load a new OS without doing a disk image beforehand.. TM is not reliable enough or trustworthy to be depended on.
    If none of the above work..
    I would get a USB drive on the computer and install Mountain Lion or whatever OS you had before you unfortunately upgraded to Mavericks.. Then use TM from that decent installation but mount the sparsebundle and choose the backup from a date well before mavericks was installed.
    Once you have extracted the files.. or even done a full restore you might be able to extract the files you want.

  • How to synchronize the signal sending and data acquiring process dynamically with one DAQ_Urgent

    Dear Sir,
    I am using one DAQ card to send a modulation signal (which is a signal summed by a low frequency saw tooth and high frequency sin signal) to the laser controller, and acquire voltage signal from another instrument  (It is in a same measurement system with the laser controller)?
    I would like these two process happening at the same time.
    In the attachment, there are two parts, one of them is signal generating program, the other one is data acquiring program, how to do like this: when I press"run", first the modulation will be sent to the laser controller immediately, and at the same time, the acquiring program starts as well...
    In addition, I think my program is not complete, could you please help me check if there are any other problems with it? 
    Thank you very much.. and appreciate your quick reply in advance.
    Best regards,
    Memorysun
    Attachments:
    Signals generation and lockin recording.vi ‏1227 KB

    Jamie S. wrote:
    Hi Memorysun,
    Thank you for your post and welcome to the forums.
    From your description what you want to achieve is:
     Write data to a Analog Output channel that is then recieved by the Laser
     Acquire (read) data from using an Analog Input channel (output from Laser/Instrument)
    This can be achieved using a single VI with 2 seperate DAQ tasks, one the "Continuously Writes" to the Laser and the other that "Continuously Reads" from the Laser/Instrument. Can I recommend the following examples that can be found in the NI Example Finder (Help>>Find Examples>>Hardware Input and Output>>DAQmx):
     "Cont Gen Voltage Wfm-Int Clk.vi" (for continuous writing)
     "Cont Acq&Graph Voltage-Int Clk.vi" (for continuous acquisition)
    The code from within both these VI's can be placed in a single VI therefore achieving the desired functionality.
    Many Thanks
    Jamie,
    They would be better served with an example that routes the AO hardware sample clock to the source of an externally clocked AI.
    Using the examples you posted will still leave them with the challenge of trying to alligh stimulus with response.
    Ben 
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to read Production Order Long Text data in ABAP program

    Hi friends,
      I have the issue in reading the ' Long Text '  tab view data of production order
    in CO03 transaction.Please can some body help me out to get this in ABAP program.
    Regards,
    Rajesh Akarte

    ok goto the long text, double click it, or use the small pencil, so that you proceed to the text editor.
    Once you are there, use the menu: goto->head
    a small popup will come up, stating the information you need.
    what you need is OBJECT, ID, Language and NAME.
    with those information you can feed the FM READ_TEXT.
    and woooohooo there you go

  • How to check the access right for a specific SAP object like MaterialMaster

    Hi!
    How can I check if I have the right to change a specific object like a material or document in SAP vie RFC. I need a remote able function which tells me, if I have enough rights! Or, if such a function does not exist, how can I write my own ABAP code to do this?
    Thanks,
    Konrad

    Hi,
    When initiating a transaction, a system program performs a series of checks to ensure the user is authorized.
    1. The program checks whether the transaction code exists in table TSTC.
    2. The program checks whether the transaction code is locked by the administrator (transaction code SM01).
    3. The program checks whether the user has the authority to start the transaction. Authorization object S_TCODE (transaction start) contains the authorization field TCD (transaction code). The user must have the appropriate authorization for the transaction code to be started (for example, FK01, Create Vendor).
    4. The program checks whether an authorization object is assigned to the transaction code. If this is the case, the program checks whether the user has an authorization for this authorization object. The transaction code/authorization object assignment is stored in table TSTCA.
    Note: An SAP program controls steps 1 through 4. It displays an automatic message to the user if an authorization attempt fails in the step.
    5. The system performs authorization checks in the ABAP program using the ABAP statement AUTHORITY-CHECK.
    Regards
    Sudheer

  • Need to know how to find the name of the classes for ABAP Objects

    Hi Experts,
    I am new in ABAP Objects. I do not now the best way to find the class which I want to use. Shall I search it using F4 search help, but many of the classes does not have a description with them.
    I want to create a text field on my splitter container. Can anybody please tell me the class-name for the text field.
    Regards,
    Saurabh A. Buksh

    Hi,
    Thank you for the helping me. But, I actually want something which we call a Text Box. I do not require a Text Edit Control.
    Please tell me if you know any classes related to it and the parameters that I need to pass into it.
    Thanks & Regards,
    Saurabh A. Buksh

  • Apache+Tomcat access to static apache data from Tomcat

    Hi,
    Apache is in path /opt/apache
    and tomcat is on /opt/apache/tomcat
    I have to access to static data (/opt/apache/data) that is handled by my apache http server from my tomcat web application. Is there a way to do this in a clean way without doing things like this :
    getServletCoontext().getRealPath(xxx) and doing some ../data manipulations
    Thanks

    I'm not completely sure I fully understand your problem.
    I do not recommend opening sockets to your own WLS instance. That is a
    recipe for deadlock.
    Can you just include the static file in your response?
    -- Rob
    Yol. wrote:
    We have a WebApplication which is running on a WebLogic Server 6.1.
    The clients access to the application via an Apache hosted in another machine.
    The Apache server redirects the requests to the server except the static files
    which are served by the Apache Server.
    Nevertheless, we have a few static resources that are not requested by the external
    clients but are requested by the application in the WLS. The problem is that to
    make this, it access the resource via the WLS, that is, via an url. That makes
    the WLS open at least one socket. This cause that after a few time, there are
    too many sockets in the machine opened in TIME-WAIT state.
    For some reasons it is not possible to change the configuration of the sockets
    in the server hosting the WLS.
    We would like to access to this resources that are in the war of the WebApllication
    without opening a socket.
    Is it possible? Any ideas or suggestions?
    Many many thanks in advance,
    Yol.

  • Best Practices for Accessing the Configuration data Modelled as XML File in

    Hi,
    I refer the couple of blof posts/Forum threads on How to model and access the Configuration data as XML inside OSB.
    One of the easiest and way is to
    Re: OSB: What is best practice for reading configuration information
    Another could be
    Uploading XML data as .xq file (Creating .xq file copy paste all the Configuration as XML )
    I need expert answers for following.
    1] I have .xsd file which is representing the Configuration data. Structure of XSD is
    <FrameworkConfig>
    <Config type="common" key="someKey">proprtyvalue</Config>
    <FrameworkConfig>
    2] As my project will move from one env to another the property-value will change according to the Environment...
    For Dev:
    <FrameworkConfig>
    <Config type="common" key="someKey">proprtyvalue_Dev</Config>
    <FrameworkConfig>
    For Stage :
    <FrameworkConfig>
    <Config type="common" key="someKey">proprtyvalue_Stage</Config>
    <FrameworkConfig>
    3] Let say I create the following Folder structure to store the Configuration file specific for dev/stage/prod instance
    OSB Project Folder
    |
    |---Dev
    |
    |--Dev_Config_file.xml
    |
    |---Stage
    |
    |--Stahe_Config_file.xml
    |
    |---Prod
    |
    |-Prod_Config_file.xml
    4] I need a way to load these property file as xml element/variable inside OSb message flow.?? I can't use XPath function fn:doc("URL") coz I don't know exact path of XMl on deployed server.
    5] Also I need to lookup/model the value which will specify the current server type(Dev/Stage/prod) on which OSB MF is running. Let say any construct which will act as a Global configuration and can be acccessible inside the OSb message flow. If I get the vaalue for the Global variable as Dev means I will load the xml config file under the Dev Directory @runtime containing key value pair for Dev environment.
    6] This Re: OSB: What is best practice for reading configuration information
    suggest the designing of the web application which will serve the xml file over the http protocol and getting the contents into variable (which in turn can be used in OSB message flow). Can we address this problem without creating the extra Project and adding the Dependencies? I read configuration file approach too..but the sample configuration file doesn't show entry of .xml file as resources
    Hope I am clear...I really appreciate your comments and suggestion..
    Sushil
    Edited by: Sushil Deshpande on Jan 24, 2011 10:56 AM

    If you can enforce some sort of naming convention for the transport endpoint for this proxy service across the environments, where the environment name is part of the endpoint you may able to retrieve it from $inbound in the message pipeline.
    eg. http://osb_host/service/prod/service1 ==> Prod and http://osb_host/service/prod/service2 ==> stage , then i think $inbound/ctx:transport/ctx:uri can give you /service/prod/service1 or /service/stage/service1 and applying appropriate xpath functions you will be able to extract the environment name.
    Chk this link for details on $inbound/ctx:transport : http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/userguide/context.html#wp1080822

  • Static data & methods

    I'm new to java programming and I'm having a really big problem with the use of and implementation of static data types and methods- help me out!!!

    When do you choose to declare a variable to be static
    and not
    private or public?They aren't mutually exclusive. You can have public static variables.
    Are static data members associated only with a
    specific instance of the
    declared class??Static members are part of the class not of a specific instance.
    You described instance variables.
    Can non-static methods access declared static data
    types??Yes, but the opposite is not true.
    can you use the "this" keyword in both static and
    instance methods ??No, in static methods there is no "this" which refers to the current object (which doesn't exist in static context).
    Can you declare your static data members as "Public"??Yes.

  • How do you synchroniz​e accesses to a LabVIEW Shared Variable?

    I would like to create an ad-hoc weather station program (I'll explain more in a bit).  I am using LabVIEW 8.0 Full Edition, and I would like to share data over a network between stations with the LabVIEW Shared Variable.  Here's what I want to be able to do:
    A node would start up, and begin publishing data to a network via a shared variable.
    The shared variable is an array of clusters
    The cluster information would hold things like:
    Station Name
    Station Location
    Weather information cluster (temperature, rainfall, windspeed, wind direction, etc...)
    Timestamp of last update
    When a new node would like to enter, it would bind to the shared variable, grow the array, and add its information.
    If a node's Station Name and Station Location is already in the shared variable, it would merely update the information in the cluster.
    Viewing nodes could pop in, bind to the shared variable, and read/display the information at any time. 
    I am trying to enumerate problems with this before implementing, and I have run into a stinker of a problem that I am not sure how to solve.  How do I synchronize accesses to the LabVIEW Shared Variable?  If I read the variable, modify it, and write it back, I will undoubtedly run into a race condition where 2 nodes attempt to update its data and I will lose the data written by the first node - Node A reads, Node A modifies, Node B reads, Node A writes, Node B Modifies, Node B Writes, and thus the modifications made by Node A are lost.  In my specific application losing some data isn't critical, but if not remedied this type of problem could cause massive amounts of data to be lost when there are numerous nodes, and that is definitely not acceptable. 
    Does anyone have any recommendations on how to synchronize the read-modify-write operations on the data in the Shared Variable?
    -Danny

    Wendy,
    I am afraid Semaphores are not network-shared objects (to my knowledge), they are system-level objects that use operating-system synchronization mechanisms.  If I were synchronizing on a single machine, a semaphore might be a valid mechanism; as an aside, most user-mode semaphores are designed to synchronize within a single process - to synchronize between processes you need to store the semaphore in the Kernel, and to synchronize over a network you would need a network node to handle serialization of requests.  My Shared Variable is published over a network, and to my knowledge there are no network-published synchronization mechanisms available - mostly because there is no way to currently perform an atomic test-and-set on the Shared Variable (am I correct?) and there isn't a mechanism for blocking access to a Shared Variable from another network device/machine (or is there?).  I've been looking for some way to implement an atomic test-and-set but I am running into a wall; I know that if I select the "single writer" attribute of the Shared Variable I can get LabVIEW to force a single writer allowing me to have an atomic "set", but I need more than that.
    If only there was a network-shared Semaphore or some way to block other network accesses to the Shared Variable I would be in business - something like what I want doesn't exist, does it?
    Thanks!
    -Danny
    Message Edited by texasdiaz on 02-23-2006 02:52 AM

Maybe you are looking for

  • Feature request

    Hi, After taking an afternoon to test Beta 2 on a complex UI design I have some suggestions: 1. You need to add the ability to create masks. I understand there are some work arounds, but masks should be a non-trivial add especially considering how ea

  • Fixed header in Web Dynpro

    Hi all, I was asked to make a fixed (non-scrollable) header in Web Dynpro. I placed two ViewContainer-elements and linked two views to the main view - one view for the header on the top, another for the body of the document. But it doesn't work - the

  • Help me in developing an application

    hi frnds, I have to develop an application similar to flexstore.But i am confused with "states" and how to integrate other mxml to the main mxml.Will you help me in this.Pls give a tutorial. regards

  • Podcast page black not white

    When i click podcasts of any category in itunes everyone has  white page  with a clear description of or summary of their page along with each podcast listed underneath the category . The itunes player appears above and the podcasts play almost immed

  • Source/class paths

    Hi, I'm developing a web application. i use JBuilder. I need to maintain my source files module wise . In other words I need to create a sub directory for each module in source file root folder and contain source files in those sub folders in root so