Skip to Content

binding odata model

Hello experts in my project i need to import Excel file and then show values in a smart table .

Data that exists in the Excel file alredy exists in the system i need only to update them (the smart table is editable).

i need to show data in the smart table and then use submitChanges() to modify data .

i have my data in a JSON model and i dont know how to bind them to table and then submit the changes .

help me pleease i am facing this problem since one month .

i need to put this data in an odata model .

any ideas please

best regards

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Jul 11, 2020 at 04:00 AM

    Hi Abdallah,

    There is no easy of doing it. I think you need to loop through your JSONModel. Then, there should be two cases you need to handle:

    1. Update if the change in excel

    2. Create record if not available

    First of all you need to compare the keys of oData Entity and compare if there is already a context available with keys.

    If the context exists, then it is the first case, then you need to find the delta properties, using, for..in loop and use oDataModel.setProperty(oConext.getPath() + changePropertyName, "value");

    This will collect all the changes as pendingChanges and ready to be submitted.

    If the context doesn't exists, then it is the second case, where you need to create new record. You can use createEntry method to create a new record and that will update the oDataModel but will not create in the backend.

    All of these are now collected as the pending changes, once you get the confirmation to submit, you can trigger submitChange method and that should trigger backend calls to update all these information.

    Thanks

    Prashil

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 13, 2020 at 12:38 PM

    Hi Abdallah,

    Ideally, if you have sap.ui.table.Table, then getRows() should work and return you the array of row items.

    If not, you can also use Table.getAggregation("rows"), if you have binding correctly, then it will also return you an array.

    Thanks
    Prashil

    Add a comment
    10|10000 characters needed characters exceeded

    • actually when i am using the submitChange method to create multiple data i am getting error in tha beckend while it is working when i create a single record

      i dont know if a have to use the batch process instead of the submitCange method

      iam getting this msg :x051(/iwbep/cm_mgw_rt)

  • Posted on Jul 21, 2020 at 03:16 AM

    Hi Abdallah,

    THe error message is for changeset implemented. Changeset implementation is done at the gateway level. I suggest to go through Batch Request in SAP Gateway to get fair idea on what it is and how it can be implemented.

    Thanks

    Prashil

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.