cancel
Showing results for 
Search instead for 
Did you mean: 

Correct Changeset Handling in MDK APP

0 Kudos

Hi,

after several attempts I have no idea any more. So I hope somebody can help me out.

So here is what I'm trying to implement:

I'm trying to implement a MDK App with offline store to create a Business Partner. The Business Partner has many many-to-many relations. And to create a Business Partner I have to send all data in an combined format.

I know that many-to-many deep create is not supported in the offline store. So I'm trying now to create a changetset to collect all entities in the app and on sync I want to have one big $batch request so that I can handle this request in the changeset_process method and create the business partner with all naccessary data at once.

So my problem is now. I have an object table with multiple phone or fax numbers created with an CreateEntity Action. But on sync they are all seperate requests. How can I get the created table lines into a changeset action? So that I have the Business Partner (Parent) Entity and the object table items (Childs) in one batch request (Changeset Action)

General Data:

Phone Numbers:

I hope you can understand me :).

Thank you.

PS: I have also seen this post https://answers.sap.com/questions/13085230/group-update-requests-when-syncing-in-sap-mdk.html?childT... but it doesn't help me.

Regards

Alex

Accepted Solutions (1)

Accepted Solutions (1)

mingkho
Advisor
Advisor

Hi Alexander

Can you describe in what way does the solution suggested in this post does not help you?
https://answers.sap.com/questions/13085230/group-update-requests-when-syncing-in-sap-mdk.html?childT...

An alternative approach is to navigate to a modal page inside ChangeSet action, the modal page should be where you create the BusinessPartner and its child items. It will have to be a modal page, normal page is not support for ChangeSet. e.g.

{
    "Actions": [
        "/MyApp/Actions/NavToAModalPage.action"
    ],
    "OnFailure": "/MyApp/Actions/ChangeSetOnFailureMessage.action",
    "OnSuccess": "/MyApp/Actions/ChangeSetOnSuccessMessage.action",
    "Target": {
        "Service": "/MyApp/Services/MyODataService.service"
    },
    "_Type": "Action.Type.ODataService.ChangeSet"
}

When you navigate to the modal page in your change set, all OData operations performed within that modal stack (including any other pages you navigated to within that modal) are temporarily stored until you close the modal with Close page action (with "DismissModal": "Action.Type.ClosePage.Completed").

Once the modal page is closed as completed, the ChangeSet action will be committed and all of the temporary stored operations will be committed in a batch request to the offline store and when you sync the offline store, it will send the same batch request to your back end too.

Regards

Ming

0 Kudos

Hi,

thank you very much for the answer. Will test it right know. But thanks for the detailed answer 🙂

Regards

Alex

0 Kudos

With Modal Page you mean a Section Page?

mingkho
Advisor
Advisor

Modal page is an option in the Navigation action, you can choose to open any page as modal page.

0 Kudos

Ah ok. Crazy that was not clear 😄 Now the answer from https://answers.sap.com/questions/13085230/group-update-requests-when-syncing-in-sap-mdk.html?childT... starts to make sense^^. Do you know what this ModalPageFullscreen is?

Thank you so much for your answers 🙂

mingkho
Advisor
Advisor

Setting ModalPageFullscreen to true will force the modal dialog to always cover the entire screen. This is mainly for Tablet or Desktop device. In mobile phone devices, the modal is always fullscreen due to the limited screen size, so the ModalPageFullscreen is ignored in mobile phones.

0 Kudos

Thank you. Can you check my new Answer/Question. 🙂

0 Kudos

Hey Ming,

could please check my newst question 🙂

Regards

Alex

yyertuganov
Participant
0 Kudos

Good afternoon Ming Kho and Alexander,

Thank you very much for your comments here, they were very helpful for me where I also planning to use this methodoly in the MDK app I am working on where, all the data in the Mother-Header has to be saved with its Children-Positions at the same time in Offline mode (since Deep Insert is not supported in Offline).

So this method does save everything inside the Batch and in Backend I process them together within Changeset_Process method etc. that part is working.

My main question is, in Frontend MDK, how and where I can get the response of this Batch call? I have tried to catch it in individual Create calls within the batch, but that responds when it is created in Offline store. But what interests me are the results from backend during the Synchronization, in other words do I look for Results of Upload, or Download actions or is there some other way to look for Backend Response for each individual calls within the Batch?

Many thanks,

Yergali

Answers (2)

Answers (2)

0 Kudos

Hi Ming,

sorry but Im very new at working with the MDK. Can you tell me how the best way to refresh the page is? How does the OnReturning Action or Rule should look like to refresh the page?

Thanks

Regards

Alex

0 Kudos
export default function RedrawPage(context) {
    context.getPageProxy().getControl("SectionedTable0").redraw(); //IMPORTANT: redraw the sectionedTable not the page^^
}
0 Kudos

Thanks its working now. The request are collected in one batch nice. 🙂

Maybe one more question. How can I achieve that the data I've created in a subpage is directly visible in the table of the parent page? Currently the data is only visible after I've closed the parent page also and then go back to parent without snycing it.

Thanks

Alex

mingkho
Advisor
Advisor

There isn't a straight forward way for this right now. Because any OData operation done within the Change Set is stored in a temporary in-memory location that's currently not exposed and those "pending" data will only be committed to the offline store after the Change Set is committed, that's why you only see the data after the parent page is closed (that's when the Change Set is committed).

Your best bet is probably to separately store them in an array in the parent page's ClientData object after you successfully call the CreateEntity call of the child item. Perhaps in the OnSuccess of the CreateEntity Action of the child item, you have a rule:

export default function SaveProduct(context) {
  var clientData = context.evaluateTargetPath("#Page:TheParentPage_Name/#ClientData");
  if (!clientData.Products) {
    clientData.Products = [];
  }
  clientData.Products.push({
    "ID": context.getPageProxy().evaluateTargetPath("#Control:ProductId/#Value"),
    "Name": context.getPageProxy().evaluateTargetPath("#Control:ProductNameTextBox/#Value"),
    "Description": context.getPageProxy().evaluateTargetPath("#Control:ProductDescTextBox/#Value"),
    "Price": context.getPageProxy().evaluateTargetPath("#Control:PriceTextBox/#Value")
  });
}

And the in your parent page where you show the items in an Object Table, set its Target to:

"Target": "{#ClientData/Products}"

(There's not need for #Page:TheParentPage_Name because this context is already in the parent page)

Note: You'd need to refresh the page when your return to the parent page (in the OnReturning event) to pick up the changes.