cancel
Showing results for 
Search instead for 
Did you mean: 

ExecuteFromDB Issue

former_member190818
Active Contributor
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

sameer_kumar13
Explorer
0 Kudos

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

former_member190818
Active Contributor
0 Kudos

Hello Sameer,

I've raised incident 3100928251. Can you please look and let me know?

Thanks.

Regards,

Mohan Babu

sameer_kumar13
Explorer
0 Kudos

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

former_member190818
Active Contributor
0 Kudos

Hello Sameer,

May I know when will this be fixed? Will it be fixed in sometime or going to be for next release?

Thanks.

Regards,

Mohan Babu

former_member232970
Participant
0 Kudos

Mohan,

I have the same issue when trying to use this query to read BP data from DB. SAP informed me that it will be solve in the coming release (this weekend).

kind regards,

Andres

former_member190818
Active Contributor
0 Kudos

Thank you Andres !!!

sameer_kumar13
Explorer
0 Kudos

Hi All,

For your information, while correcting the ExecuteFromDB( ) function we had to incorporate some design changes. As a result the fix could not be bundled with 1605 upgrade but will be sent as a hotfix later. I will let you know the exact dates soon.

Thanks for your patience,

Sameer

former_member232970
Participant
0 Kudos

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

sameer_kumar13
Explorer
0 Kudos

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

former_member232970
Participant
0 Kudos

Hi Sameer,

Thanks for sharing the provided information.

however, could you be so kind and clarify some question/doubts for me:

  • Could you please explain me what exactly do you mean with "Identification Node". If i'm correct, you refer to the node "Identification" on the business object Business Partner, correct?

  • If by "Not support of traversing to other nodes" you mean that it will not be possible access any other node on the business object, could you please be so kind and explain to me the utility/profit of this functionality? I dont see any utility on this functionality as (if i'm correct on my first point) it will only offer access to identification data such as "ID" or  "TypeCode" which are not maintainable by the user.

  • Now suppose the following case: I would like to overwrite ALL changes performed by the user on a business partner before the save take place. This is to prevent that certain user change/maintain certain contact information by means extern tools such as outlook. As the query will return an instance of the business object from DB level, will the following instruction take care of replacing/rollback all values:

               var result = BusinessPartnerIdentification.ExecuteFromDBDataOnly(params).

               var bp = result.getFirst();

               IF ( bp.isSet())

               {

                   this = bp;

               }

        

  • suppose that the previous approach doesnt work, is there any way on the event AfterModify or BeforeSave to Drop/discard all changes performed by the user without returing FALSE on event OnSave. Please take into consideration that OnSave = False will be interpretate by a external tool such as outlook that the tool should reprocess the contact (business partner) again. While my goal is to drop all changes + OnSave = True and the following synchronization should in theory get a fresh copy of the contact.

  • If i'm interpretate your respons correctly, the current query ExecuteFromDB, still doesn't work correctly for BusinessPartner (see post "ExecuteFromDB Issue: Buffer vs DB").

thanks in advance for all suggestion/tips/info that you can share with me.

kind regards,

Andres

sameer_kumar13
Explorer
0 Kudos

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