cancel
Showing results for 
Search instead for 
Did you mean: 

Access denied Error for sap-ui-core.js in IE8 !

SandipAgarwalla
Active Contributor
0 Kudos

Hi All

I am developing a SAPUI5 application hosted on a local installation (localhost) of Tomcat server, trying to display all the sales order from the SAP ES Workplace ERP system using the SAP Demo Gateway services provided...

I am using the following REST service to fetch all Sales Order - http://gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS/SOHeaders

My HTML5 application is running on the local host..But when I try to run this on IE8, gives me a Access denied

But the sap-ui-core.js is indeed placed under the location mentioned above..If I write a simple application which only display some text, the same code works.

Here is the HTML code I have written

<!DOCTYPE html>

<html>

    <head>

        <meta http-equiv='X-UA-Compatible' content='IE=edge' />

        <title>Fetch Sales Order via Gateway - SAPUI5</title>

        <script id="sap-ui-bootstrap"

           type="text/javascript"

           src="../sapui5/resources/sap-ui-core.js"

           data-sap-ui-theme="sap_goldreflection"

           data-sap-ui-libs="sap.ui.commons, sap.ui.table">

           document.domain = '*.sap.com'

        </script>

        <script src="scripts/fetchsalesorder_new.js"></script>

    </head>

    <body class="sapUiBody">

    <div id="salesorders"></div>

        <div id="lineitems"></div>

    </body>

</html>

And the snippet of the script file

//supress the Same Origin Policy on IE8 & Chrome

var domainString = "document.domain";

domainstring = "*.com"

'Access-Control-Allow-Origin: *.sap.com'

'Access-Control-Allow-Headers: X-KEY'

var ODataModel = sap.ui.model.odata.ODataModel

var salesOrderService =

        "http://gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS/SOHeaders",

username = "GW@ESW",

   password = "ESW4GW",

oModel = new sap.ui.model.odata.ODataModel("http://gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS/SOHeaders")

asJson = false,

salesOrderCollection = "SOHeader";

var salesDetailsTable = new sap.ui.table.DataTable({

   title : "Available Sales Order",

   width : "100%",

   visibleRowCount : 5,

   ExpandedVisibleRowCount : 20,

   selectionMode : sap.ui.table.SelectionMode.Single,

   editable : false

  });

// connect the data table to the SalesOrder service

salesDetailsTable.setModel(oModel);

salesDetailsTable.bindRows("SOHeader");

//place table at the div element

salesDetailsTable.placeAt("salesorders");

What could be the issue here??

Appreciate any help.

Regards

Sandip

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I developed a SAP UI 5 project consuming SAMPLE FLIGHT gateway service using eclipse plugin .

I am getting the table layout but the table data is empty.

The chrome javascript console says

 

Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin.

Can anyone explain in detail how to suppress same origin policy by making changes in client side javascript code

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Madhumitha,

I recommend to make use of the UI5 Simple Proxy servlet for local testing purposes while complying with the same origin policy. 

Have a look at the corresponding section in my UI5 on Gateway end-to-end tutorial . It shows how to ...

  • call and address a Gateway OData service in your UI5 app
  • use the UI5 simple proxy servlet for local testing (to comply with the same origin policy)
  • configure the web.xml file with its com.sap.ui5.proxy.REMOTE_LOCATION parameter needed fro the UI5 proxy servlet
  • implement a getUrl() helper method to get different Gateway service URLs for local testing versus running the UI5 app on the ABAP server.

Regards, Bertram

Former Member
0 Kudos

Hi Bertram ,

I used the UI5 Simple proxy servlet for local testing purposes.

It is working.

Thanks for your timely help.

Also can you tell me how this issue needs to be handled in production ??

Former Member
0 Kudos

Hi Bertam,

I could not mark your answer as "correct " since i did not initiate the discussion .But your reply was very useful.

Is deploying the SAP UI 5 app in the ABAP server is the only way the issue can be solved in production or can we use any third party reverse proxy servers ?

Answers (3)

Answers (3)

Former Member
0 Kudos

I am currently developing with SAPUI5 and facing the same problems mainly how to get around the "Cross Origin" security policy and so far my conclusions are:

1. A used method to get around this problem is the use of JSONP BUT SAP REST Services don't         work with JSONP, responses are in XML format thus when creating a new ODataModel instance        the SECOND PARAMETER is useless.

2. Bypassing BROWSER security

   CHROME : Using command line switch value "--disable-web-security" works fine.

                    

                     NOTE: It works fine only using this switch value no other is needed.

                     REMEMBER to CLOSE ALL CHROME WINDOWS, the entire PROCESS.

 

   IE8/IE9     :  It works for me LOWERING the SECURITY, I configured my HOST in TRUSTED                              SITES and PUT SECURITY LEVEL to LOW.

   FIREFOX  : For newer versions (I have version 17) it seems that security can not be configured to

                     bypass the SAME ORIGIN POLICY, although there are some workarounds for older

                     versions, not good.

3.  A definitive solution probably could be one that is used all around for any WEB SERVER which

     requires to add at least ONE HTTP RESPONSE HEADER (Access-Control-Allow-Origin) BUT     

     in this case and following the theory the header needs to be as a part of the RESPONSE of the          "SAP NetWeaver Application Server" hosting the REST Service which in fact I don't know if it     

     is possible at all.

    IMPORTANT : The RESPONSE HEADER "Access-Control-Allow-Origin" needs to be applied

                          in the TARGET HOST from where data is ultimately retrieved thus if this HEADER

                          is added to the HOST where the SAPUI5 resources and develops are it won't work.

Obviously the workaround of lowering the Browsers security is not the way to go.

former_member191810
Participant
0 Kudos

Hi.

1. Try replacing this line

var oModel = new sap.ui.model.odata.ODataModel("proxy/http://usciu3f.wdf.sap.corp:50050/sap/opu/odata/sap/ZGV_PRICE_QUERY_CONS", true) ;

with this

var oModel = new sap.ui.model.odata.ODataModel("proxy/http/usciu3f.wdf.sap.corp:50050/sap/opu/odata/sap/ZGV_PRICE_QUERY_CONS", true,your_user,your_password) ;

Example:

var oModel = new sap.ui.model.odata.ODataModel(

                                                                                "proxy/http/gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS",

                                                                                false, "GW@ESW", "ESW4GW");



2. when you call bindRows method try with this change:

      oTable.bindRows("/zgv_price_queryCollection", null, [filter]);   

Please confirm us if there was a change.

Bye.

Former Member
0 Kudos

Hi,

I've looked up many threads and tried the recommendations but still stuck up with the same issue. The code is the same from the Blog http://scn.sap.com/community/developer-center/front-end/blog/2012/10/15/consume-netweaver-gateway-se...

I corrected it to

      var oModel = new sap.ui.model.odata.ODataModel( 
                                   "proxy/http/gw.esworkplace.sap.com/sap/opu/odata/IWBEP/RMTSAMPLEFLIGHT_2", 
                                                       false, 
                                                       "GW@ESW", 
                                                       "ESW4GW"); 

The tables are still empty !

I'm using Chrome/Firefox

Former Member
0 Kudos

No data is returned by the service. The error in IE console is 2013-01-04 09:39:38 The following problem occurred: HTTP request failed500

former_member191810
Participant
0 Kudos

Hi.

Could you please share all your source code?

Former Member
0 Kudos

Thanks for replying: pasting below the source code:

index.html

<!DOCTYPE HTML> 

<html> 

     <head> 

              <meta http-equiv="X-UA-Compatible" content="IE=edge"> 

              <script src="./resources/sap-ui-core.js" type="text/javascript"  

                      id="sap-ui-bootstrap" 

                      data-sap-ui-libs="sap.ui.ux3, sap.ui.commons, sap.ui.table" 

                      data-sap-ui-theme="sap_goldreflection"> 

               </script> 

               <script type="text/javascript"> 

                    // Create a SAP UI5 shell element 

                    var oShell = new sap.ui.ux3.Shell("flightAppShell", {    

                         appIcon : "http://www.sap.com/global/images/SAPLogo.gif", 

                         appTitle : "Flight manager", }); 

                    // Just take the shell and place it in the html area called shellArea 

                    oShell.placeAt("shellArea"); 

                    sap.ui.localResources("sitmil"); 

                    var view = sap.ui.view({ 

                        id : "idFlightService1", 

                        viewName : "sitmil.retrieveFlight", 

                        type : sap.ui.core.mvc.ViewType.JS }); 

                    oShell.addContent(view); 

               </script> 

     </head> 

     <body class="sapUiBody" role="application"> 

          <div id="shellArea"></div> 

     </body> 

</html>

retrieveFlightView.js

sap.ui.jsview("sitmil.retrieveFlight", {

      getControllerName : function() {

         return "sitmil.retrieveFlight";

      },

      createContent : function(oController) {

                var layout = new sap.ui.commons.layout.MatrixLayout('layout');   

                layout.setWidth('80%');   

                var rPannel = new sap.ui.commons.Panel('rPannel');             

                var rTitle = new sap.ui.commons.Title('rTitle');    

                rTitle.setText('All - Flights');    

                rPannel.setTitle(rTitle);    

                var oTable = new sap.ui.table.DataTable(); 

                oTable.addColumn( 

                     new sap.ui.table.Column({ 

                          label: new sap.ui.commons.Label({text: "AirLine"}), 

                          template: new sap.ui.commons.TextField().bindProperty("value", "AirLineID"), 

                          sortProperty: "AirLineID" 

                })); 

                oTable.addColumn( 

                     new sap.ui.table.Column({ 

                          label: new sap.ui.commons.Label({text: "Flight Number"}), 

                          template: new sap.ui.commons.TextField().bindProperty("value", "FlightConnectionID"), 

                          sortProperty: "FlightConnectionID" 

                })); 

                oTable.addColumn( 

                     new sap.ui.table.Column({ 

                          label: new sap.ui.commons.Label({text: "Date"}), 

                          template: new sap.ui.commons.TextField().bindProperty("value", "FlightDate"), 

                          sortProperty: "FlightDate" 

                })); 

                oTable.addColumn( 

                     new sap.ui.table.Column({ 

                          label: new sap.ui.commons.Label({text: "Airfare"}), 

                          template: new sap.ui.commons.TextField().bindProperty("value", "AirFare"), 

                          sortProperty: "AirFare" 

                })); 

                oTable.addColumn( 

                     new sap.ui.table.Column({ 

                          label: new sap.ui.commons.Label({text: "Airline Currency"}), 

                          template: new sap.ui.commons.TextField().bindProperty("value", "LocalCurrencyCode"), 

                          sortProperty: "LocalCurrencyCode" 

                })); 

                oTable.addColumn( 

                     new sap.ui.table.Column({ 

                          label: new sap.ui.commons.Label({text: "Type of the plane"}), 

                          template: new sap.ui.commons.TextField().bindProperty("value", "AirCraftType"), 

                          sortProperty: "AirCraftType" 

                }));  

                var oModel = new sap.ui.model.odata.ODataModel( 

                                              "proxy/http/gw.esworkplace.sap.com/sap/opu/odata/IWBEP/RMTSAMPLEFLIGHT_2", 

                                                                  false, 

                                                                  "GW@ESW", 

                                                                  "ESW4GW"); 

                oTable.setModel(oModel); 

                oTable.bindRows("/FlightCollection"); 

                rPannel.addContent(oTable);   

                layout.createRow(rPannel); 

                this.addContent(layout);

                    }

});


The developer trace shows the error:  GET http://GW%40ESW:ESW4GW@localhost:8080/SITMIL/proxy/http/gw.esworkplace.sap.com/sap/opu/odata/IWBEP/R... 500 (Internal Server Error)

I have tried the Sales Order example in another blog by Sunil Sharma and I encounter the same problem: http://GW%40ESW:ESW4GW@localhost:8080/SalesOrderService/proxy/http/gw.esworkplace.sap.com/sap/opu/od... 2013-01-07 15:47:52 The following problem occurred: HTTP request failed500,Internal Server Error I believe its an issue with the availability of the Gateway Service now. What do you guess ?

former_member182294
Active Contributor
0 Kudos

Hi Sandip,

You can try disabling SOP in Chrome browser. Check the below post:

http://stackoverflow.com/questions/3102819/chrome-disable-same-origin-policy

Thanks

Abhilash

SandipAgarwalla
Active Contributor
0 Kudos

Abhilash, Simon

Thanks for your inputs

@Abhilash - I tried disabling SOP in chrome, but still it does not work. Interestingly, in chrome it does not even show some of the text/images which are placed in the HTML along with the code for Table.

In IE I can at least get the banner..

I tried debugging in Chrome using the developer tools, it points out to some syntax error bu its written in  Chinese

Here is a screen shot

Simon - Tried accessing the tomcat using FQDN, but still the same problem. Added the following line in the Hosts file

# Local Tomcat Server
127.0.0.1    tomcat.local.com    localhost

Still no luck..

Regards

Sandip

Former Member
0 Kudos

Hi Sandip,

Can you post/share your entire HTML and Script file (fetchsalesorder_new.js) and I will try it on my local installation and see if I can see what's going wrong.

Thanks,
Simon

SandipAgarwalla
Active Contributor
0 Kudos

Here you go mate..

the new platform does not allow to attach HTML and JS file..hence have to post the code here

1) fetchsalesorder.html

<!DOCTYPE html>

<html>

    <head>

        <meta http-equiv='X-UA-Compatible' content='IE=edge' />

        <title>Fetch Sales Order via Gateway - SAPUI5</title>

        <script id="sap-ui-bootstrap"

           type="text/javascript"

           src="../sapui5/resources/sap-ui-core.js"

           data-sap-ui-theme="sap_goldreflection"

           data-sap-ui-libs="sap.ui.commons, sap.ui.table">

           document.domain = '*.sap.com'

        </script>

        <script src="scripts/fetchsalesorder_new.js"></script>

    </head>

    <body class="sapUiBody">

        <div id="salesorders"></div>

        <div id="lineitems"></div>

    </body>

</html>

2) fetchsalesorder_new.js

//supress the Same Origin Policy on IE8 & Chrome

var domainString = "document.domain";

domainstring = "*.com"

'Access-Control-Allow-Origin: *.local.com'

'Access-Control-Allow-Headers: X-KEY'

var appHeader = new sap.ui.commons.ApplicationHeader("SalesOrderDetailsHeader");

var ODataModel = sap.ui.model.odata.ODataModel

// Specify the SAP Gateway SalesOrder service as an OData model

var salesOrderService =

        "http://gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS/SOHeaders",

    // The SalesOrder service requires authentication...Get the username/password from the SDN page.

  username = "GW@ESW",

   password = "ESW4GW",

//oModel = new sap.ui.model.odata.ODataModel("http://gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS/SOHeaders")

    // SAP Gateway only supports XML, so don't use JSON

   asJson = false,

   oModel = new ODataModel(salesOrderService, asJson, username, password)

   salesOrderCollection = "SOHeader";

var salesDetailsTable = new sap.ui.table.DataTable({

   title : "Available Sales Order",

   width : "100%",

   visibleRowCount : 5,

   ExpandedVisibleRowCount : 20,

   selectionMode : sap.ui.table.SelectionMode.Single,

   editable : false

  });

  salesDetailsTable.addColumn(new sap.ui.table.Column({

       label: new sap.ui.commons.Label({text: "Order ID"}),

       template: new sap.ui.commons.TextField().bindProperty("value", "OrderId"),

       sortProperty: "OrderId" }));

            

salesDetailsTable.addColumn(new sap.ui.table.Column({

    label: new sap.ui.commons.Label({text: "Document Date"}),

    template: new sap.ui.commons.TextField().bindProperty("value", "DocumentDate"),

    sortProperty: "DocumentDate" }));

salesDetailsTable.addColumn(new sap.ui.table.Column({

    label: new sap.ui.commons.Label({text: "Customer ID"}),

    template: new sap.ui.commons.TextField().bindProperty("value", "CustomerId"),

    sortProperty: "CustomerId" }));   

salesDetailsTable.addColumn(new sap.ui.table.Column({

    label: new sap.ui.commons.Label({text: "Sales Org"}),

    template: new sap.ui.commons.TextField().bindProperty("value", "SalesOrg"),

    sortProperty: "SalesOrg" }));   

salesDetailsTable.addColumn(new sap.ui.table.Column({

    label: new sap.ui.commons.Label({text: "Order Value"}),

    template: new sap.ui.commons.TextField().bindProperty("value", "OrderValue"),

    sortProperty: "OrderValue" })); 

salesDetailsTable.addColumn(new sap.ui.table.Column({

    label: new sap.ui.commons.Label({text: "Currency"}),

    template: new sap.ui.commons.TextField().bindProperty("value", "Currency"),

    sortProperty: "Currency" }));

// connect the data table to the SalesOrder service

salesDetailsTable.setModel(oModel);

salesDetailsTable.bindRows("SOHeader");

//place table at the div element

salesDetailsTable.placeAt("salesorders");

Have fun with SAPUI5 this weekend

Regards

Sandip

Former Member
0 Kudos

Hi Sandip,

So I had a bit of a play around and did some reading too: https://developer.mozilla.org/en/http_access_control I think what you are trying to do is not possible unless you have control over the gw.esworkplace.sap.com server - it is up to the server to decide what domains it will accept these type of requests from - you would have to configure the server to send back a

Access-Control-Allow-Origin: http://tomact.local.com

or something similar (* also works to all all). But you don't have access to so that. If your JS was being hosted in the same origin as the gw.esworkplace.sap.com server it would also work.

However I did get around it as Abhilash suggests. You can turn off the Same Origin Policy in chrome with the following command:

chrome.exe --disable-web-security

When I did that it gets around that problem (and move onto another!). It should work for you too. Make sure you close all other sessions of Chrome, navigate to the folder where Chrome.exe is located and run that command as above.

The next error I get is related to the format of the URL you use to get the list of sales orders:

Looks like it doesn't like that /SOHeaders isn't the last segment in the URL:

http://gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS/SOHeaders/SOHeader?$skip=0&$top=100&$inl...

if you just get rid of the /SOHeader at the end it works:

http://gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS/SOHeaders?$skip=0&$top=100&$inlinecount=...

Anyway over to you mate! Hope this helps you.

Cheers,

Simon

SandipAgarwalla
Active Contributor
0 Kudos

Ok..so finally I could make it to work ...

Interestingly the application works in IE only, but not Chrome or Firefox (And I dnt know why)...I did disable the SOP in Chrome but still....

Here are the screenshot of the UI5 app running in IE

Here are few things which I changed in the HTMl and JS

1) Added Suppress SOP script

//supress the Same Origin Policy on IE8 & Chrome

var domainString = "document.domain";

domainstring = "*.com"

'Access-Control-Allow-Origin: *.local.com'

'Access-Control-Allow-Headers: X-KEY'

2) Truncated the Gateway Service URL -

http://gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS

3) Tomcat Server is accessed using a FQDN ...

e.g. - http://tomcat.local.com:8080/sample_apps/fetchsalesorder.html

@Simon Kemp - Thanks for your inputs

@ Abhilash - Thanks for your help..The code snippet is inspired from your blog..

And the last, I still do not know why the same app does not work in Chrome and Firefox

Regards

Sandip

SandipAgarwalla
Active Contributor
0 Kudos

App completed..Some of the screen shots

Former Member
0 Kudos

Hey, glad you got it working! I am really interested to find out exactly what that bit of script does

Here are few things which I changed in the HTMl and JS

1) Added Suppress SOP script

//supress the Same Origin Policy on IE8 & Chrome

var domainString = "document.domain";

domainstring = "*.com"

'Access-Control-Allow-Origin: *.local.com'

'Access-Control-Allow-Headers: X-KEY'

Did you work that out yourself or did you follow some guide? After all my reading of how Same Origin Policy works I am confused as to how you can set these HTTP headers in JavaScript...??? I would really like to understand this better

Thanks for sharing!

Simon

SandipAgarwalla
Active Contributor
0 Kudos

Simon

I followed some guide to get that code snippet..just googled it.....

Here is one I link I had followed

http://media.techtarget.com/rms/pdf/Web_application_security.pdf

Yet to go thru the entire document to understand it fully, so even I am not too sure how it can set and suppress the SOP

Did you try the code at your end? By any chance did it work on Chrome & FF?

HTML5 looks confusing to me at this moment, I would prefer a declarative approach than a programmatic approach for coding (read as --spoiled by WDJ framework)

Thanks

Sandip

Former Member
0 Kudos

Hi Sandip,

That PDF you link to is great! It makes me want to buy the rest of that book, it looks really good and things are explained very clearly.

I have tried and tried and the only way I can get this to work is by using chome and disabling web security using --disable-web-security when starting the chrome.exe

In IE9 and Firefox it gives the Same Origin Policy error and doesn't work. I have no idea how you get it working in IE... that is amazing! Have you tried to see what happens if you comment out those lines at the top of your JavaScript file? I am just not sure that they actually do anything at all and would be interested to see if it stops it working for you in IE or not if you get rid of them...?

Regarding this vs. WDJ or a more declarative model... I guess each has their own place. Personally I like the flexibility of SAPUI5, I get frustrated sometimes with WDJ and WDA . It's all about choosing the right tool for the job at hand I think.

Thanks,

Simon

SandipAgarwalla
Active Contributor
0 Kudos

Hey Simon

I tried commenting the SOP lines at the top, and strangely it still works..I am using IE8..Haven't tried it on IE9...and same code does not work in Chrome & FF...I must say I am bit clueless at the moment..

Did you try it on IE8 by any chance??

Regarding UI5 vs WD - I agree you get frustrated sometimes with WD with the limitations..and at the moment UI5 does look good with all the UI elements it has and the scripting and all..

Well I was hinting more towards the amount of code you have to write to get the User Interface in UI5, vs WDJ..Its just a personal view, for someone who started with WDJ framework and was spoilt with the declarative model..

I hope with the future releases, SAP UI5 will have some declarative model thereby reducing the number of lines codes you have to write (personal wishlist )

Regards

Sandip

Former Member
0 Kudos

Hi Sandip,

I haven't tried with IE8 as I have already upgraded my PC to IE9....

But I have finally got it working in Chrome and Firefox, it took me a while to wrap my head around it. As usual the smart people at SAP are way ahead of us and have already provided the solution in the form of a proxy servlet that you can use to bypass the SOP that is enforced by the browser. Basically in your example you need to replace the URL to the Gateway service with the following:

var salesOrderService = "proxy/http/gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS";

This proxy servlet will call the Gateway oData service for you (as a middle man), but the browser just sees you calling the proxy servlet which is in the same origin as your application, therefore there is no SOP errors (e.g. no "access denied" errors in the console).

This comment from explains it really well http://scn.sap.com/message/13441467#13441467 it is a little confusing because they talk about local testing vs. deploying the SAPUI5 framework on the NGAP (Next Gen ABAP Platform), but the principle is the same, ideally in our scenario our Gateway system would be the same system where we have SAPUI5 and our application deployed and we wouldn't get any SOP problems.

Just wanted to share the solution with you and the rest of the community.

Thanks,

Simon

former_member191810
Participant
0 Kudos

Hello for everyone.

Now I had that issue and I confirm that, with the proxy prefix, was solved.

Thanks for everyone.

Former Member
0 Kudos

Hello Guys,

I am facing the same issue. It works fine in IE but not in chrome. I tried to make use of the proxy prefix as suggested by Simon, but it gives the following error. Did I miss any other step over here.

<p>The requested URL /proxy/http://usciu3f.wdf.sap.corp:50050/sap/opu/odata/sap/ZGV_PRICE_QUERY_CONS/$metadata was not found on this server.</p>

Warm Regards,

Gupta

SandipAgarwalla
Active Contributor
0 Kudos

Gupta

Did you disable the SOP in Chrom??? Disable it and then run your app

Former Member
0 Kudos

Hello Sandip,

I disabled SOP using the command

C:\Users\I055330\AppData\Local\Google\Chrome\Application\chrome.exe --allow-file-access-from-files --disable-web-security. It still does not work.

BTW I am trying to create this application for mobile devices. Please find my code as mentioned below.

<html>
       <head>
              <meta http-equiv="X-UA-Compatible" content="IE=edge">

        <script src="http://veui5infra.dhcp.wdf.sap.corp:8080/sapui5-internal/resources/sap-ui-core.js"
                      id="sap-ui-bootstrap"
                      data-sap-ui-libs="sap.ui.commons,sap.ui.table,sap.m"
                      data-sap-ui-theme="sap_mvi" >  //sap_goldreflection OR sap_mvi
              </script>
              <!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required -->

        <script>
//--------------------------- Application Header -------------------------   
    var app = new sap.m.App("myApp", {initialPage:"page1"}); // page1 should be displayed first
     
    var oLayout = new sap.ui.commons.layout.MatrixLayout({
      id : "matrix1",
      layoutFixed : false,   
      });      
      // create the first page of your application
     var page1 = new sap.m.Page("page1", {
      title: "Condition Records",
      content : oLayout  
     });
   
// ------------------------------- Creation of Layout ------------------------------------

    oLayout.createRow(null, null);     
    var oLabel1 = new sap.m.Label({
     id : 'key_name',
     text : 'Variable Key Name',
     width : '150px'  
    });

    var oTF1 = new sap.m.Input({
     id : 'key_name_txt',
     tooltip : 'Key Name',
     editable : false,
     value : 'Product ID',
     width : '100px' });    
    
   // oLabel1.setLabelFor(oTF1);
    oLayout.createRow(oLabel1, oTF1);

    var oLabel2 = new sap.m.Label({
     id : 'key_value',
     text : 'Variable Key Value',
     width : '150px'   });

    var oTF2 = new sap.m.Input({
    // id : 'key_val_txt',
    // tooltip : 'Key Value',
    // editable : true,
     value : 'HT-1010',
     width : '100px',
     enabled: true
         });    
    
   // oLabel2.setLabelFor(oTF2);
    oLayout.createRow(oLabel2, oTF2);
   
   
    var oButton = new sap.m.Button({
     text: "Search"
    });
    oLayout.createRow(null, oButton);
   
    //oLayout.placeAt('content');
    app.addPage(page1);
    app.placeAt('content');
       
//-----------------------------------------------------------------------------------    
 
    var oModel = new sap.ui.model.odata.ODataModel("proxy/http://usciu3f.wdf.sap.corp:50050/sap/opu/odata/sap/ZGV_PRICE_QUERY_CONS", true) ;
    var oTable = new sap.ui.table.DataTable({
     columns: [
      {label:"Sales Organization", template: "sales_org"},
      {label:"Condition Type", template: "kschl"},
      {label:"Distribution Channel", template: "dis_channel"},
      {label:"Created By", template: "created_by"},    
      {label:"Condition Rate", template: "kbetr"},
      {label:"Condition Pricing Unit", template: "kpein"},
      {label:"Unit of Measure", template: "kmein"},    
      {label:"Condition Currency", template: "konwa"} 
     ]
      });  
    oTable.setModel(oModel);
   //--------------------------------on click of SEARCH button ----------------------------------------  
    oButton.attachTap(function() {    
     // oTable.bindRows("zgv_price_queryCollection");+ oTextField1.getValue()
      var filter = new sap.ui.model.Filter("iv_variable_key_value", sap.ui.model.FilterOperator.EQ, oTF2.getValue());
      // load the pricing table using the filter
      oTable.bindRows("zgv_price_queryCollection", null, [filter]);    
     //   oTable.bindAggregation( "rows", "zgv_price_queryCollection" );         
      oTable.placeAt("results");
    });
  //--------------------------------------------------------------------------------------------- 
   
        </script>

       </head>
       <body class="sapUiBody" role="application">
              <div id="content"></div>
     <div id="results"></div>    
       </body>
</html>

Warm Regards,

Gupta

former_member191810
Participant
0 Kudos

Hi.

1. Try replacing this line

var oModel = new sap.ui.model.odata.ODataModel("proxy/http://usciu3f.wdf.sap.corp:50050/sap/opu/odata/sap/ZGV_PRICE_QUERY_CONS", true) ;

with this

var oModel = new sap.ui.model.odata.ODataModel("proxy/http/usciu3f.wdf.sap.corp:50050/sap/opu/odata/sap/ZGV_PRICE_QUERY_CONS", true,your_user,your_password) ;

Example:

var oModel = new sap.ui.model.odata.ODataModel(

                                                                                "proxy/http/gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS",

                                                                                false, "GW@ESW", "ESW4GW");



2. when you call bindRows method try with this change:

      oTable.bindRows("/zgv_price_queryCollection", null, [filter]);    

Please confirm us if there was a change.

Bye.

Former Member
0 Kudos

Hi Sandip,

I ran into the same issue as you did. Can you please provide more details about the below steps that you performed?

1) Added Suppress SOP script -

Where am I supposed to add this script (index.html or the JS file)?

Can you please share the complete code snippet?

2) Truncated the Gateway Service URL -

I think I was able to do this part.

3) Tomcat Server is accessed using a FQDN -

Can you please provide detailed steps for doing this? (I tried to change in the host file but somehow my eclipse do not recognize the FQDN)

Thanks in advance.

Regards

Shyam

Former Member
0 Kudos

Hi Sandip,

Where did yo add the Added Suppress SOP script in Eclipse. I mean which file. I Am fairly new to this to not sure where to add this.

We are not using a proxy server though but ICM.

Thanks

Amina

Former Member
0 Kudos

Hi Sandip,

I expect you are running into the so called Same Origin policy problem that I seem to deal with lately on an almost daily basis 🙂 Here is a good description of it: http://blogs.msdn.com/b/ieinternals/archive/2009/08/28/explaining-same-origin-policy-part-1-deny-rea...

Since you are running on localhost and the webservice is from esworkspace.sap.com you are getting this Access Denied issue. Interestingly the first few lines of that script you show is trying to supress the same origin policy.

The error you show is actually occurring on line 5920 in that sap-ui-core.js file. You should run the code in Firefox or Chrome and use the tools (or Firebug in firefox) to debug the error.

Also try accessing your local tomcat with a proper FQDN like tomcat.sandip.com (edit your local hosts file to enable this) and see what happens - sometimes there are problems when you use localhost or IP addresses as "hostnames"

Hope this helps and I look forward to seeing you blog about your experience using SAPUI5!

Simon