Sunday, December 23

RFC destination from gateway to ECC is showing error

1. Introduction
2. Error
3. Resolution of Error

Introduction
You are trying to call function module from oData service. The oData service is hosted on SAP net weaver gateway system and function module which is RFC enabled is hosted on SAP ECC system. To make this call you need to have a RFC destination created in Gateway system. This activity can be done in SM59 transaction. Once RFC destination is created, test it by clicking on connection test as shown below.

Click on Connection test on below RFC Connection.


Below error is displayed


Error
Error when opening an RFC connection (LB: Hostname or service of the message server

Under such circumstances, if you try to run oData service on browser, you get below error.
Error Text as shown on the front end i.e browser
Call of service <oData service URL> terminated because of an error. The following error text was processed in system MUP : Error when opening an RFC connection (LB: Hostname or service of the message server unknown DEST =ECC_TRUSTED MSHOST =171.31.243.33 R3NAME =MUP GROUP =MUP).The error occurred on the application server mutcdcnwhwcuv. The termination type was: RABAX_STATE.If the termination type is RABAX_STATE, you will find more information on the cause of termination in system MGP in transaction ST22. If the termination type is ABORT_MESSAGE_STATE, you will find more information on the cause of termination on the application server mstddcnwgwciv in transaction SM21. If the termination type is ERROR_MESSAGE_STATE, you can search for further information in the trace file for the work process in transaction ST11 on the application server mstddcnwgwciv. You may also need to analyze the trace files of other work processes. If you do not yet have a user ID, contact your system administrator.  

Resolution of Error

If the destination system is unavailable or not accessible over HTTP, this error occurs.

Saturday, December 22

Testing oData Service using External Test Clients like ARC and Postman


1. Introduction
2. Google's ARC client
3. Concept of oData Write Operations without CSRF token
4. Google's Postman.


Introduction
SAP provides a testing environment for oData services called ‘Gateway Client’ which is an inbuilt tool in SAP NetWeaver Gateway System. It is meant for testing GET, POST, PUT, and PATCH, MERGE, DELETE http methods.
During SAP implementation projects, oData services also gets consumed in non-SAP application clients for example consuming oData service on an Android based mobile app. In such scenarios, testing oData services using an external client like ARC or Postman becomes critical. In this blog, we will see how to test oData service using ARC client and Postman.

Google’s ARC Client
First you need to Install ARC on your google chrome browser. After installation, click on Apps.
You will be able to see all the Apps installed on your Chrome browser like below.
Click on ARC icon, below page will be displayed. Where you need to enter your oData service's URL and select the type of Request like GET, POST, PUT etc...
Then Click on Send button, that it, you are done. This is equivalent to oData read operation, If you are connected to network from where your SAP Netweaver gateway system is accessible, your read request will go all the way to Gateway and fetch necessary information and display in XML format in below manner.

Concept of oData Write Operations without CSRF token
You can also add headers to your HTTP request. For example, if you are doing a POST request (i.e. write operation for your oData), you need to send X-Requested-With header and its value to be set a 'X'. When such a header is sent for a oData write operation, ICF of your netweaver gateway system will not check for X-CSRF-Token. Other wise for any oData write operation, CSRF token is a must.

In addition to sending X-Requested-with header, you also need to sent ~Check-CSRF-Token parameter's value to 0 at the ICF service level of your oData service. You can do this in SICF transaction of your gateway system as shown below.






Monday, May 22

SAPUI5 Table Binding with Data Coming from Backend

The Data that need to be displayed on SAPUI5 Table control resides of a backend system. The Data is fetched via oData services read call and rendered in table UI Control in below fashion


   
oModelECST_FETCH.read(url5,null, null, true, function(oData, oResponse){ debugger;
 oInvoices = new sap.ui.model.json.JSONModel({ "Invoices" : oData.results }); oInvoices.iSizeLimit = 100000;    
var tab =this.getView().byId("invoicestable"); // invoicestable is the ID of Table UI Control
   
tab.setModel(oInvoices);
var i=0;
tab.bindAggregation("items", {

path: "/Invoices",
template: new sap.m.ColumnListItem({
cells: [
     //
 new  sap.m.CheckBox({visible:invoicesThat.strtoBool(oData.results[tableIndex1].Count)}).setSelected(true),
       new  sap.m.CheckBox("cbinv",{visible:"{Count}", selected:"{Sel}"}),
     
       new  sap.ui.commons.TextView({ text: "{InvNo}", design:"Standard", semanticColor:"Default"}),
       new  sap.ui.commons.TextView({ text: "{InvDate}", design:"Standard", semanticColor:"Default"}),
       new  sap.ui.commons.TextView({ text: "{Tin}" , design:"Standard", semanticColor:"{semCol}"}),
//        new  sap.ui.commons.TextView({ text: "{FormNum}", design:"Standard", semanticColor:"Default"}),
       new  sap.ui.commons.TextView({ text:"{TypeOfTx}",design:"Standard",semanticColor:"Default"}),
       new  sap.ui.commons.TextView({ text: "{TaxableGoodsVal}", design:"Standard", semanticColor:"Default"}),
       new  sap.ui.commons.TextView({ text: "{AmtTaxVal}", design:"Standard", semanticColor:"Default"}),
     
       new  sap.ui.commons.TextView({ text: "{InclTaxVal}", design:"Standard", semanticColor:"Default", visible:inctaxval}),
       new  sap.ui.commons.TextView({ text: "{LabourChrgesVal}", design:"Standard", semanticColor:"Default",visible:labchargval}),
     
       new  sap.ui.commons.TextView({ text: "{OtherChrgesVal}", design:"Standard", semanticColor:"Default"}),
       //new  sap.ui.commons.TextView({ text: "{LabourChrgesVal}", design:"Standard", semanticColor:"Default"}),
       new  sap.ui.commons.TextView({ text: "{GrossTotalVal}", design:"Standard", semanticColor:"Default"}),

       ]
})
});

   },function(err){
     debugger;
   });
 

Access UI Control and Its Children at Runtime to Modify Properties | UI5

Based on user actions/output of user action, sometimes, other UI control's properties change. This behavior can be achieved by accessing UI controls mAggregation node at run time and setting desired values in UI control properties. Example of modifying 'enabled' property of a button which resides within a List's Custom list Items at place number 2. First UI control is a label, Second is the Button whose property is required to be modified


Get Currently Logged in User in SAPUI5 application

Some times to your oData calls, you want to send logged in user as one of the attributes to the call. This is how you can obtain currently logged in user within SAPUI5 application.

var y = "/sap/bc/ui2/start_up";
       var xmlHttp = null;
       xmlHttp = new XMLHttpRequest();
       xmlHttp.onreadystatechange = function() {
       if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
          var oUserData = JSON.parse(xmlHttp.responseText);
             oLoggedinID = oUserData.id;
          }
       };
       xmlHttp.open( "GET", y, false );
       xmlHttp.send(null);

 oLoggedinID will contain the login id of the person who has logged on.

thank you !
Mohammed Bohra
+91 8898030972