Skip to Content

At my current customer, we have extended the SAP Shopping cart structures with a couple of custom fields. One of those fields contains a field on which the shipping address needs to be re-determined.Currently, the SAP NXP (UI5) shopping cart does an initial load of the shipping address, but there is no re-determination done on a round trip.

To make sure that the shopping cart we are implementing corresponds with the current workflow, this has to be implemented. Doing so, I came to the conclusion that:

1. There wasn’t a lot of information available on how to do so.

2. The cookbook for SRM NXP contains an error which caused a big search in how to implement it correctly.

Since I think sharing is key, i’ll post my findings.

The first thing I came across, is that if I use the filename “custom2.js” for my custom function, it somehow doesn’t get parsed by the extensibility classes. Choosing a file name that is different from this (custom.js in my case), somehow parses correct.

As soon as I saw my console.log() messages turning up in my JavaScript console, I was able to implement my custom-code.


CUSTOM = function() {
}
CUSTOM.prototype.CUSTOM_POST_EXIT = function (methodName, view, controller, methodSignature) {
     if (view.oView.sId == "singleitemdet_id") { // View which contains my Z-Fields
             var crtl = view.oView.getController();
             var modelData = crtl.getView().getModel().getData();
             var lData = crtl.loadedData;
             if ( modelData.<myZ-field> != lData.<myZ-field> ) { // Comparison on object-level works better than using the response of the method.
              window.execRefresh = true; // Set parameter on the window, so i'ts globally available.
             }
     }
     if (view.oView.sId == "shipAddress" ) { // Shipping address view
         var crtl = view.oView.getController();
         if (window.execRefresh) {
             crtl.refresh("MODE_SWITCHED"); // Do the actual refresh on the shippingaddress object.
             window.execRefresh = false;
         }
     }
};


This custom code actually reuses the existing method on the shipping address controller to make sure it’s being refreshed but by checking for a change, it allows the address being changed without overruling the change with a refresh.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply