SAP Gateway
Browsing All 253 Articles Latest Live
Mark channel Not-Safe-For-Work? cancel confirm NSFW Votes: (0 votes)
Are you the publisher? Claim or contact us about this channel.

Convert XSTRING of CSV to Internal Table for mass actions


Hi All,


To perform mass operations, one of the most popular method is to upload an excel or csv file. Although we have GUI_UPLOAD function module to upload a file and get the data in the internal table but this is limited to SAP GUI only. In cases where the file is getting uploaded from UI5 front end, we get xstring file in the back end. We need to parse this file and extract data from it. There is some limitations in terms of converting the data of excel file(xstring) into internal table (explored on SCN and found out that we cannot easily convert the xstring of .xls into internal table while its easy in case of .csv) so we are restricted to use CSV files.


The scope of this blog does not contain the process of file uploading from UI5 front end and receiving it in the Gateway service. This part you can easily achieve using by these references:

1) Gateway service part: How To Upload and Download Files Using SAP NW Gateway SP06

2) File Uploading part: Uploading files to SAP using HTML5 /AJAX/Gateway media links with real-time progress bar


I am gonna cover only the conversion part of that csv to any internal table using dynamic internal table concept. Once you get the data in your internal table you can use it in any way.


Once you get the xstring of csv file in back-end, you can use the below FM to extract data. The input and output parameters are as below:



In input parameters, you need to pass remove_header flag as 'X' if the first line of your csv file contains header field names. In tables, you can pass any internal table for getting the data. I am using dynamic internal table for this.

The code is:

FUNCTION zui5_csv_to_itab.
*"*"Local Interface:
*"----------------------------------------------------------------------   DATA struct_descr TYPE REF TO cl_abap_structdescr.   FIELD-SYMBOLS:     <comp_descr> LIKE LINE OF cl_abap_structdescr=>components,     <comp> TYPE any.   DATA: ls_string TYPE string,          it_line TYPE TABLE OF string,          wa_line TYPE string,          it_line2 TYPE TABLE OF string,          wa_line2 TYPE string,          l_regex TYPE string.   DATA : l_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.   CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'     EXPORTING
*     FROM_CODEPAGE = '8500'       in_xstring    = file_content
*     OUT_LEN       =     IMPORTING       out_string    = ls_string.   SPLIT ls_string AT cl_abap_char_utilities=>cr_lf INTO TABLE it_line.   TRY.       struct_descr ?= cl_abap_typedescr=>describe_by_data( data_table ).     CATCH cx_sy_move_cast_error.       RETURN.   ENDTRY.   LOOP AT it_line INTO wa_line.     IF sy-index = 1 AND remove_header = 'X'.     ELSE.       REPLACE ALL OCCURRENCES OF       REGEX ',(?=(?:[^"]*$)|(?:[^"]*"[^"]*"[^"]*)*$)'       IN wa_line WITH l_tab.       REPLACE FIRST OCCURRENCE OF         REGEX '^"'         IN wa_line WITH ' '.       CONCATENATE '"' l_tab '"|"' l_tab '|' l_tab '"' INTO l_regex.       REPLACE ALL OCCURRENCES OF         REGEX l_regex                         "    '"l_tab"|"l_tab|l_tab"'         IN wa_line WITH l_tab.       REPLACE ALL OCCURRENCES OF '""' IN wa_line         WITH '"'.    "Added during testing       REPLACE ALL OCCURRENCES OF REGEX '"$' IN wa_line         WITH ' '.       SPLIT wa_line AT l_tab INTO TABLE it_line2.       LOOP AT struct_descr->components ASSIGNING <comp_descr>.         ASSIGN COMPONENT <comp_descr>-name                OF STRUCTURE data_table TO <comp>.         READ TABLE it_line2 INTO <comp> INDEX sy-tabix.       ENDLOOP.       APPEND data_table TO data_table.       REFRESH it_line2.     ENDIF.   ENDLOOP.

Reference: ABAP RegEx met CSV and said 'I'll keep a Tab on you' | &amp;#169; Passionate about SAP - A Blog

Show your cards, please!



Let me tell a short story.

Imagine a SAP customer having a webapplication using SAPUI5. The architecture is a typical transactional Fiori-like application.

Meaning: SAPUI5, connecting to SAP Gateway via OData. The services are implemented in the ECC backend via ABAP OO.

In our case leveraging the SAP PM/CS module. This is working perfectly fine. Like this:

                                                                            Drawing standard as-is2.png




Due to new requirements, HANA as platform came into scope as well. Searches do have to stay fast even if the amount of data will grow on our ECC system. Another reason was to be able to search in ‘legacy’ data. ECC Tables will now be replicated to HANA enterprise. Also the legacy (read-only) data will be loaded into HANA. Search services are implemented here via OData as well, in this case via xsodata. So a 2nd OData source come into play.

Pictured it in mind? Great! Let’s draw it.

So our new picture would ideally be like this.

                                  Drawing incl HANA.png


SAP Gateway as our central access point for services. Meaning we can still to tracing/ logging as we are used to have with our initial architecture with the SAP Gateway to ECC setup. See response times, trace activity for a limited amount of time. And have a single and central access point for all our services. Ideally as well, since we have to deal in SAPUI5 with the 'same origin policy' issue. Also for other applications later on which have to benefit from these services, can benefit from a single access point.

As Sheldon Cooper, would say:



All set... Or not?

External OData source

When we want to use SAP Gateway as our route to HANA, means we have to call an external OData source (HANA) via SAP Gateway.

Let me explain; Calling external OData services (in our case HANA) via SAP Gateway can be done, it is called OSCI. It is explained here. So we did. We run the wizard, and ….. it failed. “Metadata cannot be loaded”. It turns out a ‘http://’ deep down in the class is missing. No worries, when adding this via the debugger, luckily we could continue. Generation was successful. The metadata could now be loaded. All fine? Actually no, when testing our ‘new’ service via the gateway client, it failed. It had a different interpretation of 'nullable'. Meaning all records with empty values failed, The default of Nullable is differently interpreted in Gateway. Nothing to worry as well, I guess we can fix that by making our definitions more explicit on the HANA side.

What was unexpected is, a complete new service is generated in Gateway. A completely new set of classes. Doing all the logic as you would have when generating a Gateway service using an ECC backend via an RFC. Meaning it parses the incoming request and check for validity against the metadata. Especially responses are completely parsed. Not only it takes time (we run 60.000 records through it, and it took >1,5 minute before a parse error came up). But parsing and validating the response would anyway be done in the source system, in our case HANA.

Sheldon is over-reacting when hearing this news.

                                                     sheldon ohno.png

Of course there are reasons for this, and there are great teams working at SAP, who must have a very good reason to implement it like this. In our scenario it is a bit unexpected, and behavior which is actually not required.

Our requirement would be fulfilled with having a proxy behavior. Proxying requests to HANA. With Gateway as proxy, but still enabling logging, tracing and response time measuring. A pure representation of a proxy is shown below.




What does Fiori do?


How does standard Fiori do this, when calling HANA OData services from a Fiori application. Is Gateway being leveraged here as a central point of access? Is it using OSCI?

This picture is directly from SAP documentation. The "Setup of SAP Fiori System Landscape with SAP HANA XS". It describes the architecture for an analytical application. A SAPUI5 application consuming OData services from HANA.


What do we see? The webdispatcher. The good‘ol webdispatcher. This does mean it will do simple proxying, this also means it will not be consuming time in reading and validating and parsing the response. Great? Yes, sure it is acting a proxy. But remember, we want to have full tracing, and logging options. To be able to see if a request has failed. To turn on a trace for 2 hours and watch what happens (for a particular user). To quickly spot the services which have high response times, and possibly cause time-outs.


We could implement our solution with bypassing SAP Gateway for HANA OData services. Since we are serving the SAPUI5 from a Java stack (Gateway is not our frontend server). We implemented a proxy here by using a Java proxyservlet, to route requests to HANA. However we do not have the routing and logging, handy tracing options and response times measuring in (one) place. It can be build and implemented here, sure, but it’s not standard.

It could be, that our future architecture will be a even more Fiori-like landscape. Gateway, ECC, HANA. The Gateway server being the frontend server, this stack running the Launchpad and offering the SAPUI5 applications. Meaning it might grow towards an architecture without the Java stack, this means we cannot do the proxying anymore here.



What is SAP’s roadmap here? In scenario's with more OData sources being consumed in one or in more applications.

Is the webdispatcher the final solution, as in the Fiori analytical landscape? Monitoring and managing is less advanced here as the customer would prefer.

Is there another way to route and monitor and manage these different API’s via one solution. Will SAP Gateway get proxy functionality?

Or is this why SAP started a partnership with ApiGee?


Although it seems to be more focused on cloud based solutions, will this also be available for on premise usages as API management for all (SAP) OData sources?


Please SAP, show your cards!




Thanks for making it onto the end of this blog. Please share your comments!

Book Analogy to understand Central Hub and Embedded Scenario


Hello Folks,


Target Audience: Beginners in SAP Gateway.



Here I am going to explain the deployment scenario of SAP gateway with relating it to the books.

There are 4 objects here: customer, publisher, printer and papers(or raw materials). Suppose the customer wants 50 copies of some novel 'Novel ABC'. Here is the process:

  • The customer requests this to Publisher of the novel.
  • The publisher checks who is the printer for this novel and asks the printer to print 50 copies.
  • The printer checks for the raw material and if the raw material is not available, it asks for the raw material.
  • As soon as the printer receives the papers(or raw materials), it prints the copies and send it to the publisher.
  • The publisher receives the copies and send the requested copies to the customer.

Book analogy.PNG

Relate it with Gateway scenarios:

Lets relate the above scenario with gateway.


Books AnalogyCustomerPublisherPrinterPapers (Raw Material)
Gateway ScenariosBrowserFront End ComponentsBack-End ComponentsData (ECC)



The process is:

  • The browser requests it to the front end system. (Where service is registered)
  • The front end checks that the requested service is registered against which system. (checks the back-end system which registered the service and where all the classes are presented)
  • The back-end receives the request, checks and asks for the data. (control comes to the classes of the service and asks for the data)
  • When the back-end gets the data, it sends the data back to the front-end system.
  • The front end system sends the response to the browser.



  • Creating the service = Printing the book
  • Registering the service  = Publishing the book
  • Getting the data or calling the FM =  getting the papers


For deployment options, we can check the SAP help page Embedded Versus Hub Deployment - SAP NetWeaver Gateway Master Guide - SAP Library


Scenario A: Central Hub Deployment — Development in SAP Business Suite Backend System


                              When Printing Press has the papers or raw materials

This approach suggests that the printing press has papers i.e. the backend system has the classes/methods of created service as well as data.

This means that Publishing house does not have the capability of printing the book i.e. the gateway service is developed at the backend system and only registered at front end hub system.

So we will have front end components(GW_CORE, IW_FND) at the Hub system and backend system will have IW_BEP copmonents.

book A.PNG

ch a.PNG


Scenario B: Central Hub Deployment — Development in SAP NetWeaver Gateway System


                              When Publishing House also prints the book

This approach suggests that the Publishing House also has Printing Press but not the papers i.e. the front end system has the classes/methods of created service but not the data.

This means that Publishing house does have the capability of printing the book i.e. the gateway service is developed at the front end system and only data is fetched from ECC system.

So we will have front end components as well as backend components (GW_CORE, IW_FND & IW_BEP) at the Hub system.


book B.PNG

ch B.PNG


Scenario C: Embedded Deployment — Development in SAP Business Suite Backend System


                    When publishing house prints the book as well as has the papers

This approach suggests that the Publishing House, Printing Press as well as papers or raw materials are at one place i.e. everything is in one system.

This means that Publishing house does have the capability of printing the book and also have the papers i.e. the gateway service is developed at the backend system, registered at the same system and data is also fetched from same system.

So we will have front end components as well as backend components (GW_CORE, IW_FND & IW_BEP) at the backend system.

book embeded.PNGembedded.PNG


Hope this helps in understanding the concept of Central Hub and Embedded deployment scenarios.

Test POST request to Gateway with SoapUI


This blog describes how to make POST calls containing CSRF tokens to Gateway using SoapUI.


The testcase contains 3 steps, and a property named CSRF,



Check field "Maintain HTTP session" under testcase options, this will make sure that the cookies set in the GET request are reused in the POST request,

TestCase Options.png



1: Get CSRF

This will fetch the token via a GET request, add header "X-CSRF-Token" and value "Fetch"

Get CSRF.png



2: Groovy Script

The script will take the token from the GET request and store it in the testcase "CSRF" property




def headerValue = testRunner.testCase.getTestStepByName("Get CSRF").httpRequest.response.responseHeaders["x-csrf-token"];


log.info( headerValue[0] );


testRunner.testCase.setPropertyValue( "CSRF", headerValue[0] );





The actual request using the token, add header "X-CSRF-Token" with value "${#TestCase#CSRF}", set content type according to input data


SAP Gateway and API Management Coming to TechEd && D-Code Bangalore


Since SAP and Apigee entered thepartnership agreementand released the new product offering called “SAP API management” Sep. 2014 there has been tremendous customer interest on this solution. 


Want to see this new solution in action or chat with our experts on Gateway and API management face to face? If you are attending TechEd && d-code in Bangalore (March 11- 13 in Bangalore International Exhibition Centre) you will have the perfect opportunity to get the latest updates on SAP API management and SAP Gateway.

               SAP API management Technical insides


One of the easiest ways to find the experts besides at the sessions is stopping by at our demo Pod in the info zone. Besides the SAP API management topic our experts onsite will offer a series of sessions about SAP Gateway as well which is a technology that enables a simple way to connect devices, environments and platforms to SAP software based on OData standard. SAP Gateway is one of the important API sources that work seamlessly with the API management solution. Below is an overview of how SAP API management integrates with the SAP product family including SAP Gateway.




Here is what our team offers at TechEd Bangalore:
1. Lectures and hands-on sessions on SAP API management and Gateway:

Session ID

Session Type





Session Date/Time



1 h

Cutting-Edge SAP API management leveraging REST

Orchestration, and Intelligent  Processes




15:15 - 16:15 pm


Product Roadmap

1 h

Road map Q&A: SAP Gateway - On Premise and in the cloud

Integration on SAP HANA Cloud




14:00 - 15:00 pm


12:00 -

1:00 pm



2 h

Consuming SAP Data in Google Apps by leveraging SAP

Orchestration, and Intelligent  Processes

Chandan V.A,



Vinayak Adkoli


16:00 - 18:00 pm



4 h

Develop an E2E integration scenario with SAP Gateway, SAP HANA and SAPUI5

Orchestration, and Intelligent  Processes

Amit Nigam,

Rashimi BR,

Atanu Mallik,

Ashwani Mulpuru


9:45 - 11:45 am



2 h

Advanced OData Service Development with SAP Gateway

Development and extension
  platform for HANA and Cloud

Vinayak Adkoli,

Kranti Khilari,

Arun Bhaskaran Nair


13:30 - 15:30 pm


Code review


SAP Gateway – Tune Your OData Services

Development and extension  platform for HANA and Cloud

Arun Bhaskaran Nair


9:45 - 10:15 am


2. Code Jam sessions with access to Gateway experts and Gateway tools




Session Type





Session Date/Time 


Mini codejam

1 h

Let’s have fun with OData and Apache Olingo on the SAP Hana Cloud Platform

Development and Dev and
  extension platform for HANA and Cloud
Chandan V.A


13:15 -

14:15 pm


Mini codejam

1 h

Development and extension Platform for SAP HANA and Cloud

My first OData Service using SAP Gateway Technology

Kranti Khilari,




17:00 -

18:00 pm


3. Relatedlecture and hands-on sessions


Session ID

Session Type





Session Date/Time



2 hOData in SAP HANA Cloud IntegrationOrchestration, and Intelligent Processes

Arun Bhaskaran, Suresh





9:15 -

11:15 am



1 h

OData in SAP Process Orchestration

Orchestration, and Intelligent

Vikrant Patil, Suresh



16:30 -

17:30 pm


4. Demo Pod in Info Zone - SAP Integration Solutions and API Management

Our experts will be at the demo Pod in the Info zone with several innovative demos to cover the entire SAP Integration solution portfolio with API management as the featured product. Here are some preview of the demos powered by the brand new SAP API management that you can experience at the pod.

  • SAP API Management technical demo

You can experience the brand new SAP API management system live at the pod.  The on-premise edition is already released and the in-cloud edition is coming soon. Here is a sneakPreview of SAP API Management powered by HANA Analytics in the SAP Cloud.


  • Augmented Reality Demo - Visual Showroom (offline)

Through a tablet device  user can see the augmented reality of an interior design item from a catalog and order product real-time powered by SAP API management (joint developed with SAP partner Quantilus).


  • Google Glass demo – DiscoverSimple Assist (offline)

Google Glass app on hands-free laptop repair scenario with 3D or video instruction and online inventory checking / ordering powered by SAP API Management and Gateway (joint developed with SAP partner Quantilus).

5. Social Media Program

On top our social media program will be very active during the entire TechEd && d-code in Bangalore. Whether you are onsite or remote, you can find the latest about SAP API management and Gateway on the following social media channels!

SAP Gateway                 SAP.com | SCN| LinkedIn |Youtube |Twitter |Facebook
SAP API Management   SAP.com |
SCN| LinkedIn |Youtube |Twitter |Facebook


SAP API management and Gateway Product Management Team

How to save text(PR Approver comments) in header level.




the Blog describes how to save text(PR Approver comments) in header level for Standard fiori PR App.


  • Enhancements :-
    • Ø Implicit Enhancement for Collective Approve Action (SET_DECISION_REL_COLLECTIVE).
    • Ø Implicit Enhancement for Collective Reject Action (SET_DECISION_REJECT_COLLECTIVE).


  • Implicit Enhancement - SET_DECISION_REL_COLLECTIVE:-

Execute SE80-> choose Package-> specify package name ‘GBAPP_APV_PR’.


Expand ‘Class Library->Classes’, double click on class ‘CL_GBAPP_APV_PR_API’.img2.png   

Find the method ‘SET_DECISION_REL_COLLECTIVE’, double click on the method.img3.png

Once get into the method click on the Enhance (Shift + F4) button from tool bar.


Right click on the method at starting line, choose ‘Enhancement Operations -> Show Implicit Enhancement Options’. It will show like below arrow at both start & end of the the method.


Right click at the end of the method, choose 'Enhancement Operations -> Create Implicit Enhancement’. click on 'Code' button.


'Select or Create Enhancement Implementation' popup will come.It will ask you the Enhancement name & Short description. click on Enter.


Implement custom logic(Logic provide below) between ENHANCEMENT and ENDENHANCEMENT. Save and activate it.


  • Implicit Enhancement - SET_DECISION_REJECT_COLLECTIVE:-

  Same as ‘Implicit Enhancement - SET_DECISION_REL_COLLECTIVE’.


  • Custom Logic:-
    1. Check whether the Document Type is not equal to RV (Contract Requisition) or not.
    2. If Document Type is not RV, then initiate the text (FM: INIT_TEXT) with Id = ‘B01’, Name = ‘PR No.’ and Object = ‘EBANH’.
    3. Loop the Item text table and append to the other table (Which is the input table of SAVE_TEXT function module).
    4. Pass the Header details (Id + Name + Object) and Text table to the SAVE_TEXT fm.


DATA : l_thead      TYPE thead,

        lt_tline     TYPE STANDARD TABLE OF tline INITIAL SIZE 30,

        l_tline      TYPE tline,

        l_txfunction TYPE cdupdkz.

DATA : lv_bsart TYPE bbsrt.


IF NOT iv_approval_text IS INITIAL.


     FROM eban

     INTO lv_bsart

     WHERE banfn = iv_pr_number.

   IF lv_bsart <> 'RV'.


     l_thead-tdid = 'B01'.

     l_thead-tdname = iv_pr_number.

     l_thead-tdobject = 'EBANH'.


* initialize text



         id       = l_thead-tdid

         language = sy-langu

         name     = l_thead-tdname

         object   = l_thead-tdobject


         header   = l_thead


         lines    = lt_tline


         OTHERS   = 1.


     LOOP AT lt_text INTO ls_text.

       l_tline-tdformat = ls_text-tdformat.

       l_tline-tdline   = ls_text-tdline.

       APPEND l_tline TO lt_tline.





         header   = l_thead


         function = l_txfunction


         lines    = lt_tline


         OTHERS   = 1.





TechEd Bangalore, 2015: My First OData Service Using SAP Gateway Technology(CJ606)


Wow! TechEd is knocking at our door again. TechEd opens the 'gateway' to meet new people and also people with similar interests. As always, I am excited to participate in one of the biggest technology events.  Undoubtedly, it is a world of opportunity for everyone to learn something excitingly new in this event.



Like they say “There is a Gateway for that”, I am thrilled to share that there is aSAP Gateway session for you as well. In fact there are several sessions catering to different target groups. The sessions will cover interesting topics like, OData in SAP HANA Cloud Integration, OData in SAP Process Orchestration and Cutting-Edge SAP API Management Leveraging REST. You can find more about all the sessions related to SAP Gateway in this SAP Gateway and API Management Coming to TechEd && D-Code Bangalore.



It is my privilege to announce that we shall be conducting a Mini Code Jam session on “My First OData Service Using SAP Gateway Technology (CJ606)”.

In recent times, I am happy to see many people showing interest in SAP Gateway. Though, we have good amount of resourceful materials available at the Gateway SCN, I have heard that learners find it difficult to kick start their learning process. So, here is an opportunity for beginners to get enlightened with concepts of OData and Gateway in this session. In this session you will be able to understand the important role played by SAP Gateway in the mobility world. The session will start with an overview of OData and SAP Gateway, then we will guide you to construct OData URIs to access different information from the backend. At the end of the session, you will be able to create a simple OData service with QUERY-CREATE-READ-UPDATE-DELETE operations using the code based approach.

If you have never created any OData service before, do not worry we shall help you to create your first OData service. We would also help you to get your doubts cleared. 

So, if you are a newbie or an enthusiast, here is a chance to venture into SAP Gateway.

I am excited to meet you, see you there …

How to create a SAP Netweaver Gateway Project to Expose RFC as OData Services


Dear All,


I am writing this blog specifically for SMP 3.0 as from SMP 3.0 onwards the entire architecture is based on OData Framework. Be it any backend datasource, there is a concept of Entity Data Model (EDM) to expose your backend data in OData.

For SAP Backend systems, there are two ways to consume data from RFC(Remote Function Modules).

1. Expose the RFC as a SOAP Service using SOAP Manager and create Data Models on Eclipse IDE with SAP OData Plugins

2. Create a Gateway Service Project on Netweaver Gateway and import the service into your Eclipse IDE with SAP OData Plugins.


For method 2, the pre-requisite is to have an SAP Netweaver Gateway installed either in an Central Hub Deployment or Embedded Deployment

Central Hub Deployment of SAP Netweaver Gateway has SAP NW Gateway Server installed in a different instance then the SAP ERP instance whereas Embedded Deployment has all the components of SAP Netweaver Gateway installed in the same instance.


For this blog post we are going to follow method 2 and are using an Embedded Deployment model of SAP Netweaver Gateway.


Log in to you SAP Server Instance and go the the transaction SEGW


(If you are missing any roles, capture the SU53 logs and get in touch with your basis person to provide you with the required authorization. The basic authorization required would be of the Gateway Developer Role)


Once you log in to SEGW you would see the below screen






Click on the Create Button to create a new Project.

It will prompt you to enter the Project name, Description and the Package name if you wish to Transport the project to QAS. Else you can just create it

inside the Local Temp ($TMP) Directory by clicking Local Object button


3.PNG  4.PNG


Now we will create a Data Model Directly from the RFC,


I have an RFC made by name Z_SMP_PM_NOTIFICATION


which has two input parameters and returns a list as an output






So inside our project Right Click on Data Model and click on Import --> RFC/BOR Interface



Give the name of the Entity and the Destination RFC.


Here we will give the name of the Entity as NotificationList and the destination RFC as Z_SMP_PM_NOTIFICATION.




Click on Next to define the Fields that we require in our entity. For my RFC to work i need the REQ_INTERFACE_NAME as the input as the LT_NOTIF_LIST as output parameter so i would select only those fields.




Click on Next to define a key. You can also change the name of the fields under the name column. Defining a key for an entity is mandatory




Click on Finish to create the entity.


Next we will create an EntitySet which will be of the datatype the Entity that we created.


Double Click on the Entity Sets node and click on the Create Icon

11.PNG to create a new entity. Give the name of the Entity Set and the Entity Type name as the name of the Entity that we just created




Once this is done you would see an entry under the Service Implementation node with the same name as the Entity Set.

Expand it to see you will see 5 operations along with every entity set

Create - This operation will be used if you want to create any data within SAP from the webservice. for e.g Creating a new Employee in the master table

Delete  - This operation is used to delete existing entry within SAP from the webservice. for eg Deleting a particular Employee within the master table

GetEntity(Read) - This operation is used if you want to retrieve a single record against a key from SAP for e.g Retrieving details of a particular employee

GetEntitySet(Query) - This operation is used to retrieve a list of records from SAP against a query or without a queryfor e.g Retrieving list of employees or retrieving a list of employees with Country Code IN etc

Update - This operation is used to update the existing data of a record within SAP For e.g Updating contact details of a particular employee.


Since for this example our RFC returns a list of Notifications so we will proceed for defining a GetEntitySet(Query) Operation on our EntitySet.

Right Click on the GetEntitySet(Query) node and select Map to Datasource.


You can either map the fields manually or click on Propose Mapping button on the top to map it automatically




If your input parameter has any constant value then you can directly define it over here with ' ' quotes.


Once this is done we are done with the development of the Entity set and Mapping. Next this is we will Generate the Runtime Objects which all the Gateway Services require for operating.

Gateway Services based on Model Provider and Data Provider Classes.

Click on the Generate Runtime Objects button 19.PNG

If there are not errors you will see a below message that all these classes are created with a green box on their side.


Once all the classes are made, next thing we will do is to register this service against the SAP Netweaver Gateway Server so that we can access it.

The pre requisite for this would be that you create Destination for the Systems. If the destinations are not maintained you can make those using the TCODE SM59 and then create an alias using SPRO->SAP Netweaver-->Gateway-->OData Channel-->Configuration-->ConnectionSettings-->SAP Netweaver Gateway to SAP System--> Manage SAP System Alias and create a new Entry there against the RFC Destination.

Double Click on the Service Maintenance Node and you should see all the Destinations that you have created.

Select the Destination and click on Register Service.


Click on Register Button and it will ask you for a prompt


It will open a new page, Do not change any values, Within the package Assignment give the Package name if you wish to transport or

you can store it as a Local Object.

Click on the green tick to register the service.

Once the service is registered and deployed you will see a green box against the destination.



We have now deployed the service on the SAP Netweaver Gateway Server.


Next we will proceed to testing the Service that we just deployed. Go to the transaction /IWFND/MAINT_SERVICE


Here you will see a list of services




Select our service and click on the Gateway Client button





It will open up a new window




click on the 30.PNG and you will see the list of Entity Sets that we created under this Service




If you have any input parameters then you can give it after the Entity Set name. The RFC that we created had one input parameter which was a constant so i defined the constant value during mapping itself. If you have any input values for query operation you can supply it as follows


/sap/opu/odata/sap/ZTESTNOTIFICATION_SRV/NotificationCollection?$filter=parametername eq 'value'


Once you add this click on the 32.PNG button to test the service.

It should return with a HTTP Request code 200 and with the data




This way you can develop multiple entity sets and test it.


Hope this helps you all.


For more info on SMP, follow SMP Developer Center



Rakshit Doshi

Simple steps to perform Batch Operations in SAP Gateway Services.


Hi All,

This blog is continuation ofSimple Step-by-Step SAP-Gateway Service Guide ,


In above mentioned blog you'll find all structures,tables,entities,entity sets,association and all basic operations(CRUD), Once you done with basic operations, When the requirement is as follows.. you can continue with this blog

Again this is for beginners,not for experts 

In some cases, business entity instances may logically belong together and need to be handled or processed together in the same logical unit of work. For example, on a sales order, an update of two or more related item entries could be required and must be processed together in a single request (all or none).

SAP Net Weaver Gateway can be used to process such scenarios with its capability to execute multiple operations in a single request.

Starting with SP 04, SAP Net Weaver Gateway provides the capability for client applications to batch multiple operations into a single HTTP request, allowing for a series of retrieve operations and/or modifying operations to be executed using one request.

O Data Batch requests allow the grouping of multiple operations into a single HTTP request payload. The components of a batch request, how the request is handled, and the components of the batch response have some significant differences from components and processing of a normal, single-operation OData request.

Batch Requests are submitted as a single HTTP POST request to the batch endpoint of a service.

Initial (Mandate) Steps :

     1. Go to transaction SEGW.


     2.Expand  Project(which we created in above mentioned blog) -> Run time Artifacts.

     3.Right click on class ends with DPS_EXT.

     4. Select Go to ABAP Workbench.


     5. Go to edit mode.


     6. Redefine methods.




          a.       Click on /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_BEGIN   and click redefine button.

          b.       Click on /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_END      and click redefine button.


           Only redefine and comment the code inside.



     7.Activate the service.

     8. Go to gateway client .(Please referSimple Step-by-Step SAP-Gateway Service Guide).


Batch Read :


    1.  Check HTTP Method as POST.

    2.  Request URI -> Append /$batch at the end of the service name.


    3.  Click on Add Header.


    4.  Enter Content-Type as

multipart/mixed; boundary=batch


    5.     Paste the code in http request body.


 Content-Type: application/http
 Content-Transfer-Encoding: binary
 GET EmpDetailsSet('76')?$format=xml HTTP/1.1
 Content-Type: application/http
 Content-Transfer-Encoding: binary
 GET  EmpDetailsSet('77')?$format=xml HTTP/1.1

     6. Replace Entity Set and Values according to yours.

     Batch_Read_Request _final.PNG

    7. Click Execute.


         You’ll get two records in HTTP Response body.


Batch Create :

    Steps :-

Follow steps 1- 4 of Batch Read.

    1.  Paste the code in http request body.

 Content-Type: multipart/mixed; boundary=changeset
 Content-Type: application/http
 Content-Transfer-Encoding: binary
 POST EmpDetailsSet HTTP/1.1
 Content-Type: application/atom+xml
 Content-Length: 588<?xml version="1.0" encoding="utf-8" standalone="yes"?><atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
 xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><atom:content type="application/xml"><m:properties><d:DETAILS m:type="ZEMPLOYEE_INFO_SRV.Details"><d:Street1>Pai Layout</d:Street1><d:Street2>Bangalore</d:Street2><d:City>BANGALORE</d:City><d:Country>INDIA</d:Country></d:DETAILS><d:EMP_ID>76</d:EMP_ID><d:NAME>ARSHAD SHAIKH CREATE</d:NAME><d:ADDRESS>BANGALORE</d:ADDRESS><d:SALARY>100000000</d:SALARY></m:properties></atom:content></atom:entry>
 Content-Type: application/http
 Content-Transfer-Encoding: binary
 POST EmpDetailsSet HTTP/1.1
 Content-Type: application/atom+xml
 Content-Length: 588<?xml version="1.0" encoding="utf-8" standalone="yes"?><atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
 xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><atom:content type="application/xml"><m:properties><d:DETAILS m:type="ZEMPLOYEE_INFO_SRV.Details"><d:Street1>Pai Layout</d:Street1><d:Street2>KR Puram</d:Street2><d:City>BANGALORE</d:City><d:Country>INDIA</d:Country></d:DETAILS><d:EMP_ID>77</d:EMP_ID><d:NAME>LK SONI CREATE</d:NAME><d:ADDRESS>BANGALORE</d:ADDRESS><d:SALARY>100000000</d:SALARY></m:properties></atom:content></atom:entry>

     6. Click Execute.


          Your No of records maintained in above request body will be created.



Batch Update :


Follow steps 1- 4 of Batch Read.

   5    . Paste the code in http request body.


 Content-Type: multipart/mixed; boundary=changeset
 Content-Type: application/http
 Content-Transfer-Encoding: binary
 PUT EmpDetailsSet('76') HTTP/1.1
 Content-Type: application/atom+xml
 Content-Length: 588<?xml version="1.0" encoding="utf-8" standalone="yes"?><atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
 xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><atom:content type="application/xml"><m:properties><d:DETAILS m:type="ZEMPLOYEE_INFO_SRV.Details"><d:Street1>Pai Layout</d:Street1><d:Street2>Bangalore</d:Street2><d:City>BANGALORE</d:City><d:Country>INDIA</d:Country></d:DETAILS><d:EMP_ID>76</d:EMP_ID><d:NAME>ARSHAD SHAIKH UPDATE</d:NAME><d:ADDRESS>BANGALORE</d:ADDRESS><d:SALARY>100000000</d:SALARY></m:properties></atom:content></atom:entry>
 Content-Type: application/http
 Content-Transfer-Encoding: binary
 PUT EmpDetailsSet('77') HTTP/1.1
 Content-Type: application/atom+xml
 Content-Length: 588<?xml version="1.0" encoding="utf-8" standalone="yes"?><atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
 xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><atom:content type="application/xml"><m:properties><d:DETAILS m:type="ZEMPLOYEE_INFO_SRV.Details"><d:Street1>Pai Layout</d:Street1><d:Street2>KR Puram</d:Street2><d:City>BANGALORE</d:City><d:Country>INDIA</d:Country></d:DETAILS><d:EMP_ID>77</d:EMP_ID><d:NAME>LK SONI UPDATE</d:NAME><d:ADDRESS>BANGALORE</d:ADDRESS><d:SALARY>100000000</d:SALARY></m:properties></atom:content></atom:entry>

     6. Click Execute.



          Your No of records maintained in above request body will be updated.


Batch Delete :


Follow steps 1- 4 of Batch Read.

    5    .Paste the code in http request body.

 Content-Type: multipart/mixed; boundary=changeset
 Content-Type: application/http
 Content-Transfer-Encoding: binary
 DELETE EmpDetailsSet('76') HTTP/1.1
 Content-Type: application/http
 Content-Transfer-Encoding: binary
 DELETE EmpDetailsSet('77') HTTP/1.1

    6.Click Execute.


         Your No of records maintained in above request body will be Deleted.


Arshad Shaikh --

OData Model Naming Conventions


Hi Friends,


I thought of sharing the naming conventions I follow to improve the readability of my OData service for UI developers and other consumers.


General rules for all artefactsNo "ALL CAPS"
Use Camel case
No Underscores
Use English Names
No SAP technical names
Entity NamesOnly Nouns
Only Singulars
Not to contain operation names
examplesSalesOrderHeader, SalesOrderItem, Address, CostCenter
examples:SALES_ORDER, PO_CREATE, Orders, CostCenterF4, Bukrs, PurchaseOrderList
Complex TypeWhenever you have too many fields in your entity, improve the readability of your Entity by grouping fields into Complex Types

Complex Type "Address" for complex properties "DeliveryAddress", "PostalAddress"

Complex Type "CompensationDetail" for complex properties "OldCompDetail", "NewCompDetail"

Entity SetsPlural of Entity name. Or add 'Set' at the end of Entity name
examples:SalesOrderHeaders, SalesOrderItems, Addresses, CostCenters, Currencies, CurrencySet
NavigationsSame as Entity name if the target cardinality is 1
Same as EntitySet name if the target cardinality is M

Consider two self explanatory, related entities, SalesOrderHeader and SalesOrderItem. Consider the navigation between them named as "SalesOrderItems". Now, to navigate from header to item, we can use a self explanatory URL as below.


If you had named the Navigation as say "Header_Item", then you would have called URL


which is not at all consumer friendly.

Function ImportsName should clearly Indicate the operation getting performed
examples:ReleasePO, ApproveLeave, BlockSalesOrder, GetReleaseStatus


Let me know your views and if you follow any other best practices.

SAP Gateway Hands-on sessions in Bagalore TechEd 2015


Here are a few highlights from a few SAP Gateway Hands-On session conducted in the ongoing TechEd 2015 in Bangalore.


Session: DEV360 - Advanced OData Service Development with SAP Gateway


With the Buzz around S4/HANA, it was clear that there will be a renewed need to supplant Business Suite capabilities either as HCP extensions or ABAP extensions for Public cloud and Managed Cloud / On-premise installations respectively.


The Advanced OData Service Development with SAP Gateway Hands-on Session on the day of the keynote couldn’t have been scheduled on a better slot. 

The session saw a packed house and we were concerned that more than a handful of participants might not find a vacant desktop to occupy!





Arun started with a quick recap of Gateway concepts and explaining the salient features of our Design Time tools via segw.


After getting developers on boarded onto their systems and sampling out the exercise files, Kranti took over and explained framework features of $expand and how self-expand could be utilized and backed up with some perceivable improvements in response time.


Arun then went to speak about Server Side caching capabilities via Soft State, its relevance and guided the audience with the exercise files.


It was my turn to put Client Side caching into perspective via ETag support for Conditional Read and Update requests.


In a nutshell it was a well-balanced distribution between ‘slide talk’ and actual hands-on . At the end of two hours as we were winding up, we were glad to see happy faces leave the hall having completed the exercises and hopefully after having added a trick or two to their knowhow of OData Service Development



Session: INT263 - Consuming SAP data in Google Apps leveraging SAP Gateway


As an exciting day 1 was drawing to a close and we were skeptical of how many people would show up for the hands-on session for Consuming SAP data in Google Apps leveraging SAP Gateway which was coincidentally timed exactly around the afternoon snacks interval.


But our fears were put to rest as participants started pouring in and it was just a matter of time before all seats were taken, so much so that we had to create additional backend users to account for the deluge of participants.






Balu began with an overview of SAP Gateway, brief architecture and its relevance for user centric applications.


Soon Chandan got onto the fore and started off the exercises to create a backend entity via Gateway tools and after having dealt with that portion satisfactorily, we started the much awaited segment of weaving a consumption story around Google APIs.


I started off with a context around Google Apps Script and showed a few example with Gmail and Forms integration and we then lead the participants round it up with a SpreadSheet App that fetched Business Partner and Sales Order data from the Gateway service.


Understandably, with questions and queries pouring in, we soon ran out of time and thankfully were able to extend the session by a good 15 minutes before we wound up an interesting day at TechEd2015.




-Vinayak Adkoli





SAP API Management at SAP TechED Bangalore 2015


Friday was the day for SAP API Management.


The day started with Balakrishnan Gottipati interviewed Chee Keong Law, Director Channel and Alliances, APJ from APIgee on SAP TechTV Live.You can see the replay by 14th March 12:00AM IST here. I would encourage all to watch the replay to understand the digital economy and the market perspective.





The API Management demo session was from 11:00 to 13:00 and the session was always full with people wanting to see the product and getting their queries answered. Sreeharsha had a very interactive and engaged audiences.


Experience Sharing: TechEd 2015 Mini CodeJam - My First OData Service Using SAP Gateway Technology (CJ606)


I would like to share the experience of Mini CodeJam on ‘My First OData Service Using SAP Gateway Technology(CJ606)’. I conducted the session with Kranti on the first day of TechEd Bangalore, 2015. People were very interested about the topic and as a result the session was ‘Houseful’.


The attendees were very energetic. Most of the participants were new to OData and SAP Gateway. Few of them were already aware of the technology (and attended some of my other sessions) but attended the session to brush up the knowledge. Some participants could not get a seat or a workstation for hands on for limited availability. Some of you have been very generous and have shared the workstations with others. Like always, everyone attending the session did not come from similar technical background. No one left the session in between and that showed me your interest in this technology.


I consider this session was very successful for two reasons. The first reason is of course the successful completion of the hands on by ALL of YOU. The second reason is – YOU UNDERSTOOD IT.  This is very important. People asked us so many questions. We ask questions when we understand something and want to understand more. That made the session super interactive. Some of you had more question, but we could not take it due to Demojem announcements.


It was a great experience to meet all of you. Thank you for attending the session. We shall be glad if you share your feedback/opinion/feelings about CJ606. Here are some pictures from the session.







I met Virinchi, Soumyadeep andDhrubajyoti Rakshitand many others in the event.



Some of you had asked me to share the materials and the code snippets. Our session was based on blog How to Develop a Gateway Service using Code based Implementation. Please refer to the blog for more details. Some of you asked to share the code snippets for CREATE-UPDATE-DELETE operations. Please refer to the attachments for the snippet. For more, please  refer to our blogs and materials available in SAP Gateway Community in SCN.

How complex are your OData models? Need your Feedback !


Dear community,


today I am asking for your help to find out more about the nature of OData services you are working with. We are currently defining the Ux specification for tools that should visualize OData models.


We need to understand what is the most common case for customers in  terms of size of OData Models you as a customer work with.


  1. How many entity types typically customers work with in one service?
  2. How many entity sets typically customers work with in one service?
  3. How many complex types customer generally use in on model?
  4. How many function imports?
  5. What would be number of properties in each entity set customer would be using?


If you can provide some inputs based on the scenarios you have face, it would be helpful for us.


You can either post a comment to this message or you can contact me directly.


Best Regards,


Deep Insert - Request payload formats


Hi Everyone,

Below are the payload request details required to post complex business entities( 1 : N records) into gateway framework.


Scenario : Header with 1 product and multiple notes


XML payload:


<?xml version="1.0" encoding="UTF-8"?>

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<atom:content type="application/xml">



    <d:Category m:null="true"/>   

    <d:CommType m:null="true"/>





<atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Products" type="application/atom+xml;type=feed" title="Sales_Products">




            <atom:content type="application/xml">




                <d:ShortText m:null="true"/>


                <d:BaseCategoryDesc m:null="true"/>







<atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Notes" type="application/atom+xml;type=feed" title="Sales_Notes">




            <atom:content type="application/xml">



  <d:Tdline>[SUMMARY]Please check the functionality and correct the issues in both</d:Tdline>                  





            <atom:content type="application/xml">



  <d:Tdline>the products[SUMMARY][ACTIONS]Please check the functionality and correct</d:Tdline>                  





            <atom:content type="application/xml">



  <d:Tdline>the issues in both the products[ACTIONS]</d:Tdline>                  










JSON payload - Navigation property points to a multiple cardinality entity:Header with 1 product and 3 notes.(Separate first 2 notes by comma operator and last entry without comma)












"BaseCategoryDesc":"" }],



"Tdline":"[SUMMARY]Please check the functionality and correct the issues in both"




"Tdline":"the products[SUMMARY][ACTIONS]Please check the functionality and correct"




"Tdline":"the issues in both the products[ACTIONS]"





JSON payload - Navigation property points to a single cardinality entity:Header with 1 product and 1 note.










"BaseCategoryDesc":"Utility" }],



"Line":"[SUMMARY]Please check the functionality and correct the issues in both" }]



Note: Bold ones are the Navigation properties.



SOAP & REST based webservices. What are they ? When to use each of them or use both ?


Hello Experts,

We are aware that SAP Gateway is a product offering from SAP which has now close to 8K customer installations (may be higher than this). This is really a tremendous growth and achievement from both SAP as well as its customers/partners standpoint enabling technology simple to consume SAP data through any popular environment or device or browsers following REST principles. Prior to Gateway we had something called “Web services” to integrate SAP data with Microsoft etc.  We also have NW Mobile, BAPI, LMS but I am taking web services into the table.


Few advantages which I believe Gateway is preferable over SOAP based web services are

1.Easy consumption in all channels like browsers, mobile phones etc.

2. OData defines an abstract & common data model and a protocol that let any client access information exposed by any data source by using common libraries.




3.OData requests are simple as like a SQL DB query. However web services which use SOAP request are quite complex to consume in thin client like mobile. A typical SOAP request look like


4. SOAP exposes application –defined services but OData allows access to an entire application-defined data model.


5. Summarizing REST & SOAP features.



1.What are the ideal use cases for choosing Web services (SOAP) and for SAP Gateway(OData based REST services) from a customer perspective?

For Applications involving more users interactions like B2C(Business to Consumer), Multi-Channel consumption(Desktop ,Mobile,Tablets), Lightweight,Synchronous & Stateless applications chossing REST methodology is a wise option.For Integration scenarios,A2A(Application to Application),B2B(Business to Business), System-System communications, Asynchronous support, Connecting to NON-SAP backends, creating stateful & heavy weight applications SOAP based services could be used. So it depends upon the business requirements to choose developing a REST service or a SOAP service.  Below blog & Teched session discusses them in detail.

Gateway or Process Integration – which is the Right Tool for the Job :



SAP NetWeaver Process Integration and SAP NetWeaver Gateway: When to Use What (Dont miss the fun at the end of the video)



A typical customer who has both SAP Gateway and SAP Process orchestration installations enjoy the benefits of both the world.

Is ther any plans from SAP in the roadmap to bring this both product features into a single product offering either on-premise or on-demand ?

@ Experts ,Gateway topic leaders and everyone : Please share your thoughts !

References :




Prabaharan Asokan

Coming soon: SAP CodeJam in Bielefeld


logo CodeJam 2015.jpg


On Tuesday, May 5, 2015 from 10:00 AM to 4:00 PM (CEST)   there will be a SAP CodeJam in Bielefeld which will be conducted by my colleague Matthias Osswald and me.


The topic will be the end-2-end development of a SAP Fiori like application showing the development of a simple OData service and the development of a SAPUI5 application using the SAP Web IDE.


So the event is of interest for ABAP developers as well as for frontend developers. While ABAP developers will learn how to code an OData service using SEGW they have also the chance to see how to generate a simple SAPUI5 application using SAP Web IDE.


Frontend developers will have the chance to learn more about SAP Web IDE to speed up there development of a SAPUI5 based application and will also see what is happening behind the scenes in the ABAP stack when developing an OData service to shed some light on this black box.


As always this is not a classroom training but a chance to get your hands dirty, meet people and have fun with coding.


If you are interested here is the registration page link:



Best Regard,


Handling attachments in IE9 & Older version browsers from SAPUI5 application and uploading them to SAP via SAP Gateway RESTful services


Hi Everyone,

Use case:We need to upload the attachments from IE8/IE9 browser using SAP Gateway and SAPUI5. Many Enterprises still love to use legacy (old) browsers.



So enabling these functionality becomes critical for companies without doing major browser upgrade. Let’s get started by discussing the scenarios and subsequently explaining the solutions involved.

Problem statement: SAPUI5File uploader will work only with modern HTML5 browsers when using SAP Gateway as a backend to store files.

Issue: SAP Gateway OData service requires 2 custom headers to be set when handling attachment. (X-CSRF-Token and Slug). Only HTML5 compatible browsers will support setting these custom HTTP headers! In other words setting HTTP headers for a file upload request will not work in IE8 and IE9.


1.If you are using any Java server as frontend then below fix could be useful for you as suggested by W.Snoep ( Thank you Wim)


“Send parameters in the URL, and use the servlet to add the header parameters based on the URL parameters. The servlet already had the functionality of proxying but now also use it, to add the proper headers for slug and x-csrf/ x-requested-with header. This works and does add the file in the backend. However, since IE9 sends the file via an iframe as multipart/form data, it has extra header and footer data in the file in the backend. These need to be cut off in the backend ECC system. This functionality works smoothly now for IE9.


2.If we can’t solve using (1) then we can follow below approach. (When both our frontend & backend are SAP systems).

Create a custom handler to achieve this.This blog mainly focuses on this approach. Here are the steps involved.

The development activities for this scenario have been split into two steps:


  • Creation of custom handler - Setting up the Gateway environment (Steps covered in this blog)
  • Consuming the OData service from SAPUI5 application (Watch out for this in the next blog)


Creation of custom handler - Setting up the Gateway environment



Action Items:

Client side (UI5 ver 1.22.4):


- In the UI5 client, for IE8 and IE9, add the x-csrf-token and slug (if you need it) value as hidden input value to the upload form.  For newer browser (Chrome, IE10 etc.) , these values are added to the http request header.

- You can look up how to retrieve the upload form by looking at the upload method implementation for the FileUploader control in UI5 source code.

- For IE8 and IE9, set a different value (external alias defined below) for the uploadurl attribute of thefileuploader control.


Server side:


The problem for IE8 and IE9 is that the default handler class (/IWFND/CL_SODATA_HTTP_HANDLER) for ICF odata node only reads the x-csrf-token from the http header and it's not possible to set http header in IE8 and IE9.  The idea is to create a custom handler to read the x-csrf-token from the post data and add it to the http request header and resume the normal request flow.


- Create a new custom handler class that implements the interface IF_HTTP_EXTENSION.  This handler will read the x-csrf-token (or whatever name you use for the hidden input field) and set it in the http request header

- Since we cannot modify the handler list for the odata node because it's sap standard, we'll add the custom handler to the handler list in our application node which we have control.  Add the default odata handler (/IWFND/CL_SODATA_HTTP_HANDLER) as the next handler in the list.

- Create an external alias for the new custom handler (e.g. customhandler).  This value is used as the value for the uploadurl attribute on fileuploader control (pre-pend and append the value with '/', e.g. /customhandler/) before setting to uploadurl attribute.



In IE8 and IE9, the fileuploader uploadurl will point directly to the application node and our custom handler will be processed before the default odata handler.  Our custom handler reads the x-csrf-token from the post data and sets it to the http request handler thus allowing the default odata handler to read it.

Let’s start with coding and configuration stuffs. Assume we have created an OData service to handle attachments. Please refer below blogs if you want to know more on this.





Once we are done with the service you can notice our service will have a corresponding entry in the ICF application. Go to TCode SICF and check as shown below.


Click on the above highlighted entry and you can see the handlers involved.


The above handler will check the consistency of the X-CSRF-Token at runtime when we upload a file.


Now we need to manually set the X-CSRF-Token by creating a custom handler.

This must implement the interface “IF_HTTP_EXTENSION” and write logic in the method “IF_HTTP_EXTENSION~HANDLE_REQUEST”This will read the x-csrf-token and set it in the http request header





TYPE string.
*Read the Cross site forgetory token and Slug parameter from the POST data...
= server->request->GET_FORM_FIELD( name = 'X-CSRF-Token').
= server->request->GET_FORM_FIELD( name = 'Slug').
->request->set_header_field( name = 'X-CSRF-Token' value = token ).
->request->set_header_field( name = 'Slug' value = slug ).
->if_http_extension~lifetime_rc = if_http_extension=>co_lifetime_keep.
*Add below code so that subsequent handlers are called for the application node
->if_http_extension~flow_rc     = if_http_extension=>CO_FLOW_OK_OTHERS_OPT.


After done with creation of custom handler then we need to assign this to our OData service in the SICF application node as shown here.



Create an external alias for the new custom handler. This value is used as the value for the uploadurl attribute on file uploader control in the SAPUI5 app.


Click “External Aliases” and create a new alias pointing to our OData service we created in the beginning.


Make sure you prepend the alias name with forward slash ‘/’ otherwise you might encounter some error. After successful assignment alias structure will be like below one.


Test the alias:




Testing the application:

For testing purposes I am using Google chrome to simulate IE behavior and check whether our OData service is working by passing data in URL headers. (Instead of passing in HTTP headers).

Get the X-CSRF-Token first:



Now get the token from the above request and pass them as URL parameter. Do not pass them in HTTP header .Use below URL to POST data to the server. Also attach the file which you want to upload. So our request should look similar to this.


Ensure we call in the below format:


AliasName – External Alias which we created pointing to OData service

EntitySetname – OData service Entity which handle media stream. In our case it is ‘FileDetailSet’

Slug - This can be used to pass File name, File type, File length etc.

Once we hit “Send “we can see below how the flow will happen in ABAP system.



Set the HTTP header manually in our custom handler which will be triggered first before calling OData handler.


As a next step our OData handler will be triggered. We can verify whether it is validated correctly in the Gateway framework as shown below (Flag set to X).



Finally we can see our create stream method is triggered./IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_STREAM

File content and Slug parameters are retrieved successfully within the Gateway framework.



Many Thanks to Andrew Ng for proposing this solution which motivated me to write up this as a blog. In my next follow up I will illustrate how we can integrate this to a SAPUI5 app and execute this from a MSIE (IE9) browser.









Thanks for reading this. Appreciate your feedback ! Also please hit "Like" if you like the blog post.


Prabaharan Asokan

Creating Odata services out of CDS views



The purpose of this blog is to show how HANA Artifact CDS view can exposed as Odata service to consumer.

1 CDS (Core Data Services) Views

CDS(Core Data Service) views  is the newest kid in the block in HANA . It allows you to do much more compared to classical view


  • Push Code to Data  Base layer by allowing queries ,calculations and imperative statements at the DB layer(instead of application service layer)
  • Allows you to add associations with other business entities/tables
  • Annotations to semantically describe your data model


I am not going to get vociferous about CDS because there is enough documentation already available .


Please refer this ABAP on HANA open sap course for more details.



For creating CDS views there are some prerequisites


  • Eclipse should be installed
  • ADT(Abap Development Tools) add on should be installed
  • SAP NetWeaver AS ABAP 7.4 SP05 or higher running on a SAP HANA database SPS6 should be available


The ABAP system in which I am trying is NW7.4 SP8 system


Once we are done with prerequisites , we will create a CDS view .


This CDS view will join tables SNWD_SO(Sales Order) and SNWD_BPA (Business Partner) and find out sum of invoices whose gross amount is greater than 10000000.


@AbapCatalog.sqlViewName: 'ZDDLS_CDS_AGGR'
@EndUserText.label: 'CDS view for aggregation'
define view Zars_Cds_Aggr as select from snwd_so as so
inner join snwd_bpa as bpa
on so.buyer_guid = bpa.node_key
{ key bpa.bp_id as BusinessPartner,  bpa.company_name,  sum( so.gross_amount ) as  Total_Gross_Amount,  so.currency_code
group by
bpa.bp_id,    bpa.company_name,    so.currency_code    having sum(so.gross_amount) > 100000000

Here you can see there are two views - The View ZDDLS_CDS_AGGR is DDLS(DDL source view) name which can be viewed in SE11 and this object is integrated with the CTS (Change and transportation system) .The other view ZARS_CDS_AGGR is the CDS view name


Now we will check the results of the CDS Views. We can do it in two ways


a Open Data preview of CDS view in Eclipse




Now the results


b You can see the result in classical se11 transaction also. But this time we should give the DDL SQL view name ZDDLS_CDS_AGGR





2 Data Modelling in Gateway Builder

As we are done with CDS view building , we will move to Gateway data modeling part . The good thing here is we don't need to switch to GUI for Gateway builder transaction. We can run the SEGW transaction from eclipse itself as an embedded GUI. Just press CTRL+SHIFT+A and give SEGW.


We Create  data model based on DDLS view ZDDLS_CDS_AGGR




Click on Next button



select the properties we want in the entity( ignore the MANDT field)



Here we can see the property names of the entity has been automatically adjusted (Camel case) and we need to mark the Business Partner as the key property of the entity


Press finish to complete the data model part


3 Service implementation

Now we are done with Data model , we look into the data provisioning part.

Here we give the data source name as CDS view name ZARS_CDS_AGGR

Right click on the entity set SalesAggregationSet under service implementation and select Map to Data source . The important point here is we are not mapping the GetEntitySet operation of the entityset but the entityset itself.


We have to select type as Business Entity and use F4 help to select CDS view  ZARS_CDS_AGGR.


We then do the mapping of Entity properties with the CDS view fields. Strangely propose mapping button seems to be not there


Generate the model and do the service registration

4 Testing

Now we head to GW client for testing . We test the SalesAggregationSet.


In the above case we have not implemented the query operation but we use the URL of the query operation to get the CDS view results .

One more thing that comes free is the read operation .No separate implementation of READ (GET_ENTITY) required.

So if We put the below URL

/sap/opu/odata/SAP/ZARS_CDS_SIMPLE_SRV/SalesAggregationSet('100000014') also, we get the results



ABAP is not only 'ABAP' right now . For a complete End to End scenario , now we need to proficient across three layers (ABAP,Gateway,UI) which seems to be close to impossible .  But as  grey haired 'Abaper' , it is required that we at least keep up to date with  how ABAP is evolving itself for HANA DB and how its pushing the changes  in Gateway layer. The easiest solution will be to ignore all the changes happening around us and stick to the old classical style. But that will be a gap too big to bridge

Gizur OData Server – turn your MySQL database into an odata producer


April 22, 2015


I came across the odata standard while learning SAP:s new in-memory database technology called HANA. HANA makes it possible to create a backend API with CRUD operations without any coding. It is also possible to put logic in the backend using JavaScript (SAP HANA XS) and expose these functions with odata. And there is a model for managing users and privileges built into the database (there is also suport for oath2). Even though SAP HANA is a great platform it does take a significant effort to port existing databases running on other relational databases. It is also fairly costly to run HANA even though there are several cloud vendors that deliver hosted HANA instances. I can also see a need for a simple odata server based on traditional databases technology that it possible to run on a developer’s laptop.

The Gizur OData Server has been designed for development of web and mobile applications. We have web and mobile applications where the backends are developed with PHP and MySQL. It takes significant time and effort to develop backend API:s when developing web and mobile apps. It is often a challenge to achieve good performance and we also need to manage pictures. A re-usable model for managing users and privileges would also save a lot of time and effort. A simple solution that seamed to provide most of the required features was to put a odata API on top of a relational database like MySQL. The data model becomes the API for simple CRUD operations. Read, write and deletes for an entity becomes selects, insert/updates and deletes for tables. Users and privileges are managed with grant and revoke functions. We’ve also added functions for creating and deleting tables. Support for complex types and server side logic isn’t included now but can be added later on. We decided to manage pictures and other BLOBs in a leveldb database. Privileges for BLOBs are managed with the same functions as for tables for simplicity. The Gizur OData server is developed in NodeJS and the MySQL parts are separeated out in data access layer. This makes it fairly easy to support any database vendor that has NodeJS drivers (most RDBM:es does have NodeJS drivers). There is for instance a partial implementation for MS SQL Server in addition to MySQL included in the distribution.

Getting started

A sandbox server is available for anyone to play around with at http://appdev.gizur.com:9000 (the server is reset regularly). I use curl from the command line in this example. It should be easy to translate into whatever programming language you prefer. I’ll get back with a blog post on hwoto use the server in a simple web application.

Start with checking out: curl http://appdev.gizur.com:9000/help (or open the link in a browser if you prefer). This gives an overview of the API (similar to this post). This documentation will always be up-to-date with the version currently deployed on the sandbox server.

The first step is to create an account and get a password. The sandbox server will send the password in the open which is useful for testing. You should set RESET_PASSWORD_WITHOUT_LINK to false in config.js in your production system.

1. Create account. Note the account id that is returned. It is 12 characters and looks like this: 3ea8f06baf64. The account id is used in all subsequent functions.

$ curl -d '{"email":"joe@example.com"}' http://appdev.gizur.com:9000/create_account 

2. Get a password. The HTTP request looks like this: GET /[account id]/s/reset_password:

$ curl -d '{"accountId":"3ea8f06baf64","email":"joe@example.com"}' http://appdev.gizur.com:9000/3ea8f06baf64/s/reset_password 

3. A reset passwork link will sent in a mail. The sandbox server will respond with the password in the API call above so you don’t need the link. Also, the reset password link will generate a password when it is accessed so the password the API returned above will not be possible to use if the reset link is used.

$ curl http://appdev.gizur.com:9000/3ea8f06baf64/s/reset_password/1cf4843d-139f-49f1-b185-28400dad3cbd 

Working with BLOBs

Pictures and other binary data can be saved in buckets. Text can of course also be saved in these buckets. Buckets needs to be named with a prefix that is configurable. The prefix in the sandbox is b_. The example below shows how to save and get text.

$ curl -H "user: 3ea8f06baf64" -H "password: xxx" -d '{"bucketName":"b_mybycket"}' http://appdev.gizur.com:9000/3ea8f06baf64/s/create_bucket  $ curl -H "user: 3ea8f06baf64" -H "password: xxx" -d 'Just some data to store' http://appdev.gizur.com:9000/3ea8f06baf64/b_mybycket  $ curl -H "user: 3ea8f06baf64" -H "password: xxx" http://appdev.gizur.com:9000/3ea8f06baf64/b_mybycket 

Working with tables

It is easy to perform CRUD operations on MySQL tables. HTTP GET, POST, PUT and DELETE represents SELECT, INSERT, UPDATE and DELETE in the database. The following odata commands are supported:

  • $filter
  • $orderby
  • $skip
  • $select

Only JSON is supported. We currently have no plans of adding XML support since we mainly are targeting JacaScript developers.

$ curl -H "user: 3ea8f06baf64" -H "password: xxx" -d '{"tableDef":{"tableName":"mytable","columns":["col1 int","col2 varchar(255)"]}}' http://appdev.gizur.com:9000/3ea8f06baf64/s/create_table  $ curl -H "user: 3ea8f06baf64" -H "password: xxx" -d '{"col1":11,"col2":"11"}' http://appdev.gizur.com:9000/3ea8f06baf64/mytable  $ curl -H "user: 3ea8f06baf64" -H "password: xxx"  http://appdev.gizur.com:9000/3ea8f06baf64/mytable 

Service definitions

The odata standard does not contain any specification for service definitions in JSON. The internal representation of the database is returned as-is for now. This might change in future versions.

$ curl -H "user: 3ea8f06baf64" -H "password: xxx" http://appdev.gizur.com:9000/3ea8f06baf64 
$ curl -H "user: 3ea8f06baf64" -H "password: xxx" http://appdev.gizur.com:9000/3ea8f06baf64/mytable/$metadata 


The MySQL model for managing users is exposed in the API. There are grant and revoke methods in the API. See /help for more details. This model is used for both tables and BLOBs. This is not part of the odata standard though.

Concluding remarks

A note regarding the URL:s of the API. The account id is part of the URL for all API functions but /create_accountand /help. This makes it possible to setup a proxy in front of a group of NodeJS processes running Gizur OData Servers. Each account needs to be routed to the same process if BLOBs are used. The reason is that an in-process leveldb database is used. Leveldb does not have multi-process support.

The server is open source and can be downloaded here: https://github.com/gizur/odataserver. All input regarding the OData server is appreciated. Just create a github issue in the repository above. You can also reach me at jonas[at]gizur.com.

Browsing All 253 Articles Latest Live