Quantcast
Channel: SAP Gateway
Viewing all 137 articles
Browse latest View live

Test POST request to Gateway with SoapUI

$
0
0

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,

Setup.png

 

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

Groovy.png

 

''

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

 

log.info( headerValue[0] );

 

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

''

 

 

3: POST

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

POST.png


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

$
0
0

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.

 

APIMgtArchitecture.png

 

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


Session ID


Session Type


Dur


Title


Track


Speakers


Session Date/Time

INT204

Lecture

1 h

Cutting-Edge SAP API management leveraging REST

Orchestration, and Intelligent  Processes

Balakrishna

Gottipati

Fri/

15:15 - 16:15 pm

INT802

Product Roadmap

1 h

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

Integration on SAP HANA Cloud

Balakrishna

Gottipati

Wed/

14:00 - 15:00 pm

Thu/

12:00 -

1:00 pm

INT263

Hands-on

2 h

Consuming SAP Data in Google Apps by leveraging SAP
  Gateway

Orchestration, and Intelligent  Processes

Chandan V.A,

Balakrishna

Gottipati,

Vinayak Adkoli

Wed/

16:00 - 18:00 pm

INT260

Hands-on

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

Thu/

9:45 - 11:45 am

DEV360

Hands-on

2 h

Advanced OData Service Development with SAP Gateway

Development and extension
  platform for HANA and Cloud

Vinayak Adkoli,

Kranti Khilari,

Arun Bhaskaran Nair

Wed/

13:30 - 15:30 pm

CR704

Code review

30min

SAP Gateway – Tune Your OData Services

Development and extension  platform for HANA and Cloud

Arun Bhaskaran Nair

Thu/

9:45 - 10:15 am

 

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

 


Session

ID


Session Type


Dur


Title


Track


Speakers


Session Date/Time 

CJ605

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

Wed/

13:15 -

14:15 pm

CJ606

Mini codejam

1 h

Development and extension Platform for SAP HANA and Cloud

My first OData Service using SAP Gateway Technology

Kranti Khilari,

Atanu

Mallik

Wed/

17:00 -

18:00 pm

 

3. Relatedlecture and hands-on sessions

 


Session ID


Session Type


Dur


Title


Track


Speakers


Session Date/Time

INT262

Hands-on

2 hOData in SAP HANA Cloud IntegrationOrchestration, and Intelligent Processes

Arun Bhaskaran, Suresh

Pasumarthi,

Rakesh

Roy

Fri/

9:15 -

11:15 am

INT103

Lecture

1 h

OData in SAP Process Orchestration

Orchestration, and Intelligent
  Processes

Vikrant Patil, Suresh

Pasumarthi

Thu/

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).

visualTable.png

  • 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.

$
0
0

Hi,

 

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’.

               img1.png

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.

               img4.png

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.

img5.PNG

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

img6.PNG

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

img7.PNG

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.

Code:


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.

   SELECT SINGLE bsart

     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

     CALL FUNCTION 'INIT_TEXT'

       EXPORTING

         id       = l_thead-tdid

         language = sy-langu

         name     = l_thead-tdname

         object   = l_thead-tdobject

       IMPORTING

         header   = l_thead

       TABLES

         lines    = lt_tline

       EXCEPTIONS

         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.

     ENDLOOP.

 

     CALL FUNCTION 'SAVE_TEXT'

       EXPORTING

         header   = l_thead

       IMPORTING

         function = l_txfunction

       TABLES

         lines    = lt_tline

       EXCEPTIONS

         OTHERS   = 1.

   ENDIF.

ENDIF.


Regards,

Kiran.

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

$
0
0

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

$
0
0

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

 

1.PNG

 

2.PNG

 

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

 

35.PNG

 

36.PNG

 

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

 

5.png

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.

 

37.PNG

 

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.

 

6.PNG

 

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

 

38.PNG

 

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

 

12.PNG

 

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

 

39.PNG

 

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.


23.PNG


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.


21.PNG


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


22.PNG


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.


25.PNG

 

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

 

26.PNG

 

Select our service and click on the Gateway Client button

 

 

27.PNG

 

It will open up a new window

 

28.PNG

 

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

 

31.PNG

 

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

 

34.PNG

 

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

 

Thanks,

Rakshit Doshi

Simple steps to perform Batch Operations in SAP Gateway Services.

$
0
0

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.

                    SEGW.PNG

     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.

               Workbench.png

     5. Go to edit mode.

                    Edit_Mode.PNG

     6. Redefine methods.

          a.       /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_BEGIN.

          b.       /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CHANGESET_END.

          Steps:

          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.

               redefine.PNG

           Only redefine and comment the code inside.

               Changeset_begin.PNG

               changeset_end.PNG

     7.Activate the service.

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

---------------------------------------------------------------------------------------------------------


Batch Read :

     Steps:-


    1.  Check HTTP Method as POST.

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

          ------------/sap/ZEMPLOYEE_INFO_SRV/$batch

    3.  Click on Add Header.

         AddHeader.png

    4.  Enter Content-Type as

multipart/mixed; boundary=batch

    PopUpContentType.PNG

    5.     Paste the code in http request body.

   

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

     6. Replace Entity Set and Values according to yours.

     Batch_Read_Request _final.PNG

    7. Click Execute.

        BatchReadSuccess.PNG

         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.


--batch
 Content-Type: multipart/mixed; boundary=changeset
 --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: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"><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>
 --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: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"><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>
 --changeset--
 --batch—

     6. Click Execute.

          BatchCreateRequest.PNG


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

---------------------------------------------------------------------------------------------------------

 

Batch Update :

     Steps:-


Follow steps 1- 4 of Batch Read.

   5    . Paste the code in http request body.


    

--batch
 Content-Type: multipart/mixed; boundary=changeset
 --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: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"><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>
 --changeset
 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: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"><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>
 --changeset--
 --batch—

     6. Click Execute.

          BatchUpdateRequest.PNG

 

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

---------------------------------------------------------------------------------------------------------


Batch Delete :

     Steps:-


Follow steps 1- 4 of Batch Read.

    5    .Paste the code in http request body.


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

    6.Click Execute.

                         BatchDeleteRequest.PNG

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


  Thanks,

Arshad Shaikh --

OData Model Naming Conventions

$
0
0

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
examples

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
Reasoning:

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.

..............<ServiceName>/SalesOrderHeader('DummyKey')/SalesOrderItems

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

..............<ServiceName>/SalesOrderHeader('DummyKey')/Header_Item

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

$
0
0

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!

 

20150311_133414.jpg

 

 

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.

 

20150311_160942.jpg

 

 

 

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

$
0
0

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.

 

IMG_20150313_095732.jpg

 

 

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.

DSC_0087.JPG



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

$
0
0

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 to be 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 for us 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.

 

IMG-20150312-WA0000.jpg

 

IMG-20150312-WA0003.jpg

IMG-20150312-WA0005.jpg

 

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 !

$
0
0

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,

Andre

Deep Insert - Request payload formats

$
0
0

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">

<m:properties>

    <d:Partner>3602102164</d:Partner>

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

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

    <d:Telephone>9944380099</d:Telephone>

    <d:Email>prabaasokan@gmail.com</d:Email>

</m:properties>

</atom:content>

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

<m:inline>

    <atom:feed>

        <atom:entry>

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

            <m:properties>             

             <d:ProductId>G_CLEARSIMPLE</d:ProductId>

              <d:ProductGuid></d:ProductGuid>

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

                <d:BaseCategoryId>4545</d:BaseCategoryId>

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

            </m:properties>

        </atom:content>

    </atom:entry>

</atom:feed>

</m:inline>

</atom:link>

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

<m:inline>

    <atom:feed>

        <atom:entry>

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

            <m:properties>

                <d:Tdformat>*</d:Tdformat>

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

            </m:properties>

        </atom:content>

    </atom:entry>

      <atom:entry>

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

            <m:properties>

                <d:Tdformat>*</d:Tdformat>

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

            </m:properties>

        </atom:content>

    </atom:entry>

    <atom:entry>

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

            <m:properties>

                <d:Tdformat>*</d:Tdformat>

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

            </m:properties>

        </atom:content>

    </atom:entry>

</atom:feed>

</m:inline>

</atom:link>

</atom:entry>

 

 

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)

 

{

"Partner":"3602102164",

"CommType":"mobile",

"Telephone":"877845545",

"Email":"prabaasokan@gmail.com",

"Products":[{

"ProductId":"G_CLEARSIMPLE",

"ProductGuid":"0001",

"ShortText":"test",

"BaseCategoryId":"5656",

"BaseCategoryDesc":"" }],

"Notes":[{

"Tdformat":"*",

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

},

{

"Tdformat":"*",

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

},

{

"Tdformat":"*",

"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.


{

"BusPartner":"3602102164",

"Telephone":"9944380099",

"Email":"prabaasokan@gmail.com",

"Products":[{

"ProductId":"G_CLEARSIMPLE",

"ProductGuid":"0001",

"ShortText":"Test",

"BaseCategoryId":"5655",

"BaseCategoryDesc":"Utility" }],

"Notes":[{

"Format":"*",

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

}

 

Note: Bold ones are the Navigation properties.

 

Cheers

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

$
0
0

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.png

 

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.png

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

5.png


5. Summarizing REST & SOAP features.

6.png

 

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 :

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/10ce5cd7-7c55-2f10-aea0-b775b478258c?QuickLink=index&overridelayout=true&54417235657054

 

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

http://events.sap.com/teched/en/session/3596

 

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 :

https://msdn.microsoft.com/en-us/data/hh237663.aspx

http://www.infoq.com/articles/rest-soap-when-to-use-each


Cheers

Prabaharan Asokan

Coming soon: SAP CodeJam in Bielefeld

$
0
0

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:

https://www.eventbrite.com/e/sap-codejam-bielefeld-registration-16308663652

 

Best Regard,

Andre

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

$
0
0

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.

 

15.png

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.


Solutions/Workarounds:

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.

 

Summary:

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.

 

https://scn.sap.com/community/gateway/blog/2014/07/25/uploading-files-to-sap-gw-downloading-files-from-sap-gw--new-techniques

https://scn.sap.com/community/developer-center/front-end/blog/2014/07/28/upload-image-to-sap-gateway-and-display-image-in-ui5--using-new-fileuploader-with-sap-gateway

 

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.


16.png


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

1.png

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

2.png

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

17.png

 

10.png

Code:

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

 

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.

3.png

 

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.

4.png

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

18.png

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.

19.png

Test the alias:

http://abc.com:8030/customhandler/

 

20.png

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:

http://abc.com:8030/customhandler/FileDetailSet?X-CSRF-Token=Fetch

6.png


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.

http://abc.com:8030/customhandler/FileDetailSet?X-CSRF-Token=7Hsfl6bEdEsL64blrqByRQ==&Slug=JAVA|Application/MSWORD|797979


Ensure we call in the below format:

http://hostname:port/AliasName/EntitySetname?X-CSRF-Token=sslgjsdljg&Slug=TestFile

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.

8.png


9.png

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

10.png

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).

11.png

12.png

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.

13.png

14.png


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.


References:

http://scn.sap.com/thread/3386003

http://scn.sap.com/community/mobile/blog/2012/07/22/html5-mobile-with-sap--a-lot-easier-than-you-think-part-ii

http://scn.sap.com/people/brian.mckellar

http://scn.sap.com/community/gateway/blog/2014/02/28/gateway-the-icf-and-solving-the-same-origin-policy

http://scn.sap.com/community/web-dynpro-abap/blog/2013/08/10/how-to-find-the-implementation-of-an-icf-service

http://www.cnet.com/news/what-browser-wars-the-enterprise-still-loves-ie-6/

https://www.netmarketshare.com/browser-market-share.aspx?qprid=0&qpcustomd=0


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


Cheers

Prabaharan Asokan


Creating Odata services out of CDS views

$
0
0

Introduction

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.

https://open.sap.com/courses/a4h1

 

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


Eclipse_dp.jpg

 

 

Now the results

Eclipse_dp_1.jpg

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

 

 

 

ZARSse11_dp.jpg

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

 

GW_builder_Data_modeling_1.jpg

GW_builder_Data_modeling_2.jpg

Click on Next button

 

GW_builder_Data_modeling_3.jpg

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

 

GW_builder_Data_modeling_4.jpg

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.

service_impl_map_1.jpg

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

service_impl_map_2.jpg

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


service_impl_map_3.jpg

Generate the model and do the service registration


4 Testing

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

testing_1.jpg



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


testing_2.jpg



Conclusion

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

$
0
0

April 22, 2015

Introduction

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 

Priviledges

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.

Upcoming SAP CodeJam in Hannover

$
0
0

logo_codejam_hannover.jpg

On Thursday, May 21, 2015 from 10:00 AM to 4:00 PM (CEST)   there will be a SAP CodeJam in Hannover which will be conducted by my colleague Frederic Berg and me.

 

If you have not been able to make it to the CodeJam event in Bielefeld that will takes place on May the 5th this event is for you.

 

The topic will be again 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:

 

SAP CodeJam Hannover Registration, 30659 Hannover | Eventbrite

 

Best Regard,

Andre

Mobile Maintenance with Google Glass and SAP Netweaver Gateway

$
0
0

Mobile Computing is getting more and more integrated into our daily lives. In the last 10 years users went through tiny laptops up to netbooks and tablets, from common mobile phones up to smartphones and now we've finally arrived at the age of the so-called "Wearable Devices". It doesn't matter if you're wearing a Smartband, a Smartwatch or even Google's highlight product the Glass - With all those little devices you can do nearly everything what you could do with an ordinary computer. That means that you could call your friends or text them a small message or e-mail. You could go to the internet and search for the current cinema program or whatever you're looking for. It's also possible to monitor diverse physical functions, to take videos and pictures or to let you navigate through an unknown city all by just looking through a small monitor fixed on eyeglasses for example. Actually those features are quite cool for conventional home users but what if you're a business user and want to take advantage of them in your company? This is exactly the question with which businesses are struggling at the moment and also what I'm trying to answer you in this blog post.

 

My name is Stefan Heitzer and I'm a developer who works for the SAP consulting company T.CON GmbH & Co. KG in Plattling (Germany). We are always interested in new technologies and in things that can improve the user experience and the look and feel of applications. Due to this reason I dealt with scenarios for wearable computing in the field of ERP-Systems for my bachelor thesis. So we soon bought a Google Glass for our company and started with the first attempts of developing applications for the Glass which finally resulted in an app for mobile maintenance in connection with the SAP Netweaver Gateway. Our company has already developed the so-called “Mobile Maintenance Management” for Android phones. The app mainly helps technicians to overview and design the maintenance and repair proccesses much more efficient. For more information please check out the following link: Mobile Maintenance - T.CON Team Consulting. But let's start from the beginning. What I want to show you in this post consists out of the following points:

  • The general functionalities of the so-called „Mobile Maintenance Management Glass“
  • How to consume oData with the Glass
  • How to make pictures and videos with the Glass and send them to a SAP Backend

 

The General functionalities of the so-called “Mobile Maintenance Management Glass”

The app itself has two main menu items. It’s possible to review the current inspection and repair orders and to create confirmations for them. The other action is to generate new notifications for machine damages. As it’s the normal way of using the Glass you’re able to start the actions either by voice or by tapping and swiping through a normal menu. (For creating an uniform experience I decided to display all attached images in the way how it looks by tapping and swiping)

glass_blog01.jpg

The above picture shows you the main menu / start menu with the options you have. Let's have a look at the first option.

Via "Show orders" the User is able to get an overview of all the current inspection and repair orders. This means that the first step is to establish a connection with the SAP Backend and retreive all the orders. The process looks like the following:

glass_blog02.jpg
Each order can have one or more so-called "Suborders". The user should be able to explore each suborder and should be able to make full or partially confirmations for them due to the fact that he's wearing the Glass in his company and can fix the problem live. The confirmation itself can consist out of a confirmation text and also needs to have a valid time in minutes which was needed to fix the problem. All the required information can therefore entered by voice. To make sure that only valid values for the time can be entered, the app checks the corresponding voice input for a number. The menu for this process and the validator is been shown in the next screenshotsglass_blog03.jpg

glass_blog04.jpg

As already mentioned the user can make a partial or a full confirmation. The partial one should be made if technican has something done for fixing the problem. A full confirmation should only be done if the error is completly solved. When all the required information have been entered the following actions look like the following:

glass_blog05.jpg

glass_blog06.jpg

It doesn't matter which kind of confirmation the user makes. Always when this process is executed the app makes a connection to the SAP Netweaver Gateway and creates it with the entered information. For taking knowledge that there have already been made some partial confirmations for a suborder, each order has a small icon (circle) on the left corner. Red means that the erros hasn't been solved yet and yellow that there has already been made a partial confirmation.

 

A possible scenario can also be that the technican is on the shop floor and suddenly a problem appears. For this reason the second menu point "Create notification" exists. As well as "Show orders" the first step is to establish an connection to the SAP backend. Each notification has a specific damage code and of course a priority. Those information are going to be fetched at the beginning. The notification itself refers always to a functional location or to a equipment. This code can either be known by the technician or it can be found as a barcode on a maschine for example. So for entering it there are generally two possibilities: Either by voice or by scanning a barcode with the built-in camera of the Glass. While the codes are scanned or entered by voice it's of course possible that some errors can occur. Therefore all entered values are checked as well as it happens with the input in the "Create confirmation" process.The complete order of events looks like the following:glass_blog07.jpg

glass_blog08.jpg

glass_blog09.jpg

At the beginning of describing the second function I said that it's also important to enter a damage code and the priority of the fault notification. For a better user experience we designed a list consisting out of those elements. By swipping you can browse through the elements and via a simple tap you make your choice:

glass_blog10.jpg

After choosing the damage code, the priority and entering a valid code for a functional location / equipment the user reached the point where he's able to create the notification. But there can be more information and things be entered. For example the user is able to set a text, to make a picture or to record a video. All those information are transported later on to the SAP Backend:

glass_blog11.jpg

Now let's go on with the coding. In the next step I'm going to show you some relevant coding points which need to done for making the app work.

 

How to consume oData with the Glass

The app itself is an Android development project. This means that we coded with plain Java. Due to the fact that we consume data from a SAP Backend we had to look for a way how to connect with it and the best choice was to use the SAP Netweaver Gateway. The Gateway provides the data in the so-called oData format. For this reason it was necessary to create the corresponding entities and also the classes in the frontend. Let's have a look at the the entity for confirmations and at the entity for orders:

 

vorgang.jpgrueckmeldung.jpg

As you can see this are normal entities which can be created with the Netweaver Gateway. In the background we have coding for the needed CRUD-Operations. For the orders for example exists a GET_ENTITYSET-Method which is responsible for retrieving all the stored orders in the system and the redefined method for the confirmation is a simple CREATE-Method. When we would call the GET_ENTITYSET-Method in the browser we receive all the relevant data in the oData format. So we need to find a way to handle this format in our Java coding. Therefore we use odata4j. odata4j provides a toolkit with which we can build a complete consumer of oData inside our Android App. With this framework we create at first a new ODataConsumer. The builder for this consumer needs the URL which should be called. In many cases the services need a basic authentication so we also have to set a new so-called "ClientBehavior" ("BasicAuthenticationBehavior") which accepts a username and a password. In the following coding you'll see that we also have an instance of "SAPCSRFBehavior". This instance is needed due to the Cross-Site Request Forgery Protection. The SAP Netweaver Gateway is actually using for each modifying request like an insert, update or delete a so-called "CSRF-Token". This token needs to be included into an HTTP-Request because the gateway is checking for each request the validity of the token. If the validation fails you'll get an error 403. We do not want to get this kind of error so we have this class which tries to fetch the token while sending a normal GET-Request. After setting this "ClientBehavior" we actually haven't made the request yet. To finally execute the service call we have to choose the entityset which we want to receive and call the method "execute()". The whole coding for this looks like the following:

glass_blog12.jpg

As you can see we're looping over the found orders and for each order we create a new one and get the corresponding properties via methods of the class "OEntity". Afterwards we're able to store all found orders in for example an ArrayList and go on with displaying them.

Also the creation of a confirmation is no magic. Here we just have to call another method of our ODataConsumer:

glass_blog13.jpg

With the method "createEntity" we're able to say for which entityset we want to send the POST request. Afterwards we only have to set the properties and give them the right values. Actually all requests are handled in this way.

There is only one special thing. As I meantioned in the first point the user should be able to make pictures and also record a video for a notification. Here we have to do some special coding which I'm going to show you in the next section!

 

How to make pictures and videos with the Glass and send them to a SAP Backend

The process of taking the picture and sending it to the backend is just a bit easier than the video part so let's start with the picture. The Glass itself has a built-in camera which we use for this procedure. So actually the first thing what we have to do is to start with the shooting of the picture. Therefor we're using the following code:

glass_blog14.jpgglass_blog15.jpg

With the new instance of the "Intent" we can start the picture process. What we receive in the method "startActivityForResult" is - if it was successful - the path of the currently made picture. With this path we can create a new file. Afterwards we only have to check whether the picture really exists. Actually the best way to send the picture to the system is to convert it into a BASE64-String:

glass_blog16.jpg

The entityset for making a notification consists out of a property for the picture. This attribute get's the converted BASE64-String as a value. Afterwards the request is simply executed via the "createEntity" method.

A picture is for transporting in one request ok but there's going to be a problem with the video because it's way to huge for one single request. If you try to convert the video into a BASE64-String you would result in an OutOfMemory-Exception. Each Android application has a specific amount of memory which can be used for transactions, processing etc. Converting the video into the mentioned string or sending it in one single request is just way to much action for  the app and so this leads to the named exception. In order to counteract this phenomenon we created a loop which creates blocks of 1024 bytes and converts this blocks step by step into the BASE64-String. Afterwards you can put the complete string together and the conversion is finished. The corresponding code looks like the following:

glass_blog17.jpg

Now we made it to solve the OutOfMemory-Exception while converting the image but as already said the same problem can occur when the request is executed. Therefore we're using a streaming mechanism. This means that we've created a function which includes a recursion. The BASE64-String is again separated into blocks of 2000000 bytes and afterwards each block is transported and the function calls itself again until the whole request is finished:

glass_blog18.jpg

The entityset which is called at the request here has a special attribute called "Flag". This flag is used for recognizing whether the request is finally finished or not. If the request shouldn't be at the end the transported BASE64-String is added to the already received string which is stored in a database table. The coding for the whole procedure looks like the following:

video_request_finished.jpg

video_request_not_finished.jpg

This was the last coding snippet which I wanted to show you so we've actually reached the end of this blog post. If you need further information about MMM, the Glass development or SAP Netweaver Gateway check out the following links:

I really hope you enjoyed reading my new blog post and if you have additional questions don't hesitate to contact me!

 

Kind regards

Stefan

SAP CodeJam in Bielefeld 2015

$
0
0

This week it was the second time that I conducted a SAP CodeJam event in Bielefed at the location of our partner Lynx consulting. The location was the "knight's hall" of the Lynx building that offered a nice view into the spacious garden (see below).


Probably due to a strike of the train drivers in Germany not all participants that had registered were able to join this nice event.

 

WP_20150505_14_30_42_Pro.jpgIMG_5896.JPG

 

We nevertheless got 15 motivated participants that wanted to learn about the E2E development scenario of SAP Fiori like applications starting with the development of an OData service in SAP Gateway and consuming the same by a SAP UI5 based application.

 

What really impressed me was that we had customers and partners that came from the Netherlands as well as from the south of Germany to join the event in Bielefeld.  So I am thinking about offering such an event in or nearby Walldorf in the near future as well.

 

My colleague Matthias Osswald and I started with presentations about SAP Web IDE, SAP UI5 and SAP Gateway that showed the development process and finally the participants could get their hands dirty on to SAP Gateway instances and the SAP Web IDE.

 

Beside showing features and coding we also had time for interesting discussion amongst the participants. Also the wheather was fine and we could get out in the nice garden ...

WP_20150505_13_04_33_Pro.jpg

 

 

 

... and as always there was plenty to eat and to drink ...

 

IMG_5894.JPGFullSizeRender.jpg20150505_123232.jpg

 

So if you are interested in another CodeJam in Bielefeld there is an upcoming event about SAP HANA at Lynx in Bielefeld in June. SAP CodeJam Bielefeld Registration, 33615 Bielefeld | Eventbrite

 

If you missed this event and but are also interested in the E2E development process of a SAP Fiori like application you can join  my colleague Frederic Berg and me at the Upcoming SAP CodeJam in Hannover

Viewing all 137 articles
Browse latest View live