on 03-08-2016 4:43 PM
Hello,
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.
Thanks.
Regards,
MB
Hi,
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.
Regards,
Sameer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mohan,
I checked and indeed this is a bug in the ExecuteFromDB function but it only happens if you fire the query on the same BO on which your current script is running(in your case Service Request).
We are working on a fix for this. Meanwhile you can try doing the same query in a new Reuse Library function. Here, "this" is not passed and it will not get reset. You can also do checks and return true/false/values from the Library.
Regards,
Sameer
Hi Samer,
thanks for sharing this information.
Please let us know once you know the release date of the hotfix and also once the solution/fix is deployed.
For me is really important to know the release date in order to adjust the planning of my project accordingly. This functionality is really important to cover certain client requirements.
kind regards,
Andres
Hi Andres,
We had some design discussions regarding ExecuteFromDB() function and it will be changed to ExecuteFromDBDataOnly(). This is because the function is to be used only to read data and not change data + navigate to other nodes.
Once changed you can read data like :
var result = BusinessPartnerIdentification.ExecuteFromDBDataOnly(params).
var field = result.Common.extfield.content; -> No more possible as the query will return data of the Identification node and not support traversing to other nodes.So even with the fix your requirement will not be achieved. So i suggest you have an indicator or double maintain the value in a hidden extension field to capture and compare changes.
The fix for the function will come later/maybe in the next release.
Sorry to not have better news.
Regards,
Sameer
Hi Sameer,
Thanks for sharing the provided information.
however, could you be so kind and clarify some question/doubts for me:
var result = BusinessPartnerIdentification.ExecuteFromDBDataOnly(params).
var bp = result.getFirst();
IF ( bp.isSet())
{
this = bp;
}
thanks in advance for all suggestion/tips/info that you can share with me.
kind regards,
Andres
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 @ sameer.kumar@sap.com and maybe i can find a way.
Regards,
Sameer
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.