Skip to Content

ExecuteFromDB Issue


I'm facing issue with ExecuteFromDB. The query returns the same data which is there in buffer. It is not reading the DB values.

Retrieve, Query.Execute(selectionparams) gets the same data (buffer) and Query.ExecuteFromDB(selectionparams) gets the data from DB and overwrites "this" node (buffer).

How can I retrieve the BO data from DB in extension BO without overwriting buffer value in "this" node?

For instance, I want to read ServiceRequest BO data in BeforeSave event to compare the field values.




Add comment
10|10000 characters needed characters exceeded

1 Answer

  • Posted on Mar 16, 2016 at 04:29 AM


    Retrieve and Query.Execute(selectionparams) are supposed to return the same data(buffer).

    ExecuteFromDB() should return the last saved image of the data but it shouldn't ideally overwrite the "this" variable. Are you reading the query data in a variable ? One case i can think of is if your changes before firing the query are denied due to some error then both the queries will return the same data.

    Can you share your system and implementation logic ? You can also raise an incident with SAP support.



    Add comment
    10|10000 characters needed characters exceeded

    • Hi Andres,

      Apologies for the late reply. We were in the middle of our Development cycle finalizing the behavior of ExecuteFromDB() function.

      Firstly, we have decided to keep the ExecuteFromDB() function(not deprecate it) + deliver a new function ExecuteFromDBDataOnly() in the 1608 Studio release.

      1. Identification node - Yes, the identification entry in Business Partner.

      2, "Not support of traversing to other nodes" - Yes, the function ExecuteFromDBDataOnly() will only return fields and not nodes. You will be able to read fields only on the node on which the query will be fired. This will be mostly relevant for Custom Business Objects and SAP BO nodes that have an inbuilt query delivered. Also, it offers better performance when queries are used in a long piece of code.

      3. Unfortunately, using either of the two functions above you will not be able to discard changes for the whole BO instance, only the node on which you fired the query. This is because :

      var result = CustomerQuery.ExecuteFromDB();

      var a = result.field; //This will be the database entry.

      var b = result.CommonNode.field; //This will still be buffer entry.

      If you use the DOT operator on the query result to navigate via an association, you will see buffer data as the DOT operator does a retrieve again. Every DOT is interpreted as retrieve which is a default read from buffer from the framework. So it is not possible from Studio yet to give db image for sub-nodes.

      4. Apart from Setting Validation On Save = false, there is no other way to discard changes on the whole bo at once.

      Even when you do : this = bp; it will reset just the node on which the script is written i.e. in Root-AfterModify it will reset the ROOT node but Item etc. will still have the changes from the user.

      5. The ExecuteFromDB functionality works for the current node but as mentioned above not for sub-nodes/associations. We looked for solutions but it is not possible for associations to also return DB image.

      Hope it helps. If you have a complicated requirement to achieve, you can send it to me @ and maybe i can find a way.