Quantcast
Channel: SCN : Blog List - SAP Gateway
Viewing all 245 articles
Browse latest View live

Uploading files to SAP using HTML5 /AJAX/Gateway media links with real-time progress bar

$
0
0

Dear All,

This blog will walk you through step-by-step to upload files from an HTML5 webapp.

Here is the short overview of what technologies we are going to use to successfully load a binary file from a client machine to a remote SAP server.

 

HTML5 File reader : The FileReader object lets web applications asynchronously read the contents of files (or raw data buffers) stored on the user's computer. We use readAsArrayBuffer method to read the contents of a specified Blob or File.

 

Jquery AJAX:To exchange data to and from server, and updating parts of a web page - without reloading the whole page.

Putting much simpler, AJAX is to load data in the background(asynchronous) and display it on the webpage.

 

HTML5 progress bar: To track real time progress when file is getting uploaded...

 

Gateway media links: The OData Channel from gateway provides us the interface to receive binary data from the front end and then

stored it in an SAP Business Suite backend system whatever applies.

 

Enough theory.Lets get started...

 

<!DOCTYPE html>

<html>

  <head>

  <script src="https://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" > </script>

    <script type="text/javascript">

    var token1 = '';

    var xhr = new window.XMLHttpRequest();

    var file = " ";

    function upload() {

         file = document.getElementById('attafh').files[0];

 

        if (file) {

            UploadMe(file);

        }

    }

 

    function UploadMe(readFile) {

        var reader = new FileReader();

        reader.readAsArrayBuffer(readFile); //array buffer

        reader.onload = loaded;

//         reader.onerror = errorHandler;

    }

 

    function loaded(evt) {

 

        var fileString = evt.target.result;                  

          ///**** Save Personal Details & Questions & Files *****/

         // Begin of Get X-CSRFT token

             $.ajax({

                 url: 'https://test.com:8080/sap/inv/opu/odata/sap/Z_GET_ATTACHMENTS_SRV/$metadata',

                 type: "GET",

                 contentType: "application/atom+xml;type\x3dentry;",

                 dataType: "",

                 headers: {

                     "x-csrf-token": "fetch",

                     Authorization: "Basic ZDDDDDDDDD="

                 },

             success: function (data, textStatus, request) {

             token1 = request.getResponseHeader('x-csrf-token');

    

    

                 $.ajax({       

                  type: 'POST',

                  url: "https://test.com:8080/sap/inv/opu/odata/sap/Z_GET_ATTACHMENTS_SRV/Documents/",                   

                   xhr: function()

                 {           

                    //Upload progress

                     xhr.upload.addEventListener("progress", function(evt){

                      if (evt.lengthComputable) {

                        var percentComplete = Math.round(evt.loaded * 100 / evt.total);

                     $('.progress').val(percentComplete);

                       //Do something with upload progress

                       console.log(percentComplete);

                      }

                    }, false);

                             

                  xhr.addEventListener("error", function(evt){

                alert("There was an error attempting to upload the file.");

                return;

                    }, false);

         

                    return xhr;

                 },

        

                contentType: "application/json",

                processData: false,                   

                data: fileString,

                dataType: "text",

                headers: {

                          "x-csrf-token" : token1,

                          "Authorization" : "Basic ZDDDDDDDDDD",

                          "slug": file.name + "|" + file.type + "|" + file.size + "|"

                },

                success: function(data){

                   alert("File uploaded successfully");

                  }

                });

           

                  }

             });

    };

 

    function abortRead() {

    xhr.abort();

    $('.progress').val(0);

      }

    </script>

  </head>

  <body>

    <input type="file" id="attafh"  class="AlltextAccount"  />

      <input type="button" value="upload" onclick="upload()" />

      <button onclick="abortRead();">Cancel</button>

      <progress class="progress" value="0" max="100"> </progress>

 

 

  </body>

</html>

 

What above code does is, we had a file placed in the Body and when choose file and upload, we extracted the contents using File reader.

For sending this to SAP gateway, we need X-CSRF-Token to make any modifications request. Please note the AJAX heaeders when making POST request.

"ProcessData" has to be set false. Also parameter "Slug" can be used to send file name, type and size. Later this can be split in the server using "SPLIT" statement.

For tracking progress in real time we make of this event. xhr.upload.addEventListener("progress", function(evt).

 

Upload_1.png

 

We can custom tailor the progress bar theme too...

HTML:

   <progress class="progress" value="0" max="100" class="html5">

  </progress>

 

CSS:

 

progress[value] {

  -webkit-appearance: none;

   appearance: none;

 

 

  width: 150px;

  height: 22px;

  padding-top: 5px;

  display:none

 

}

 

 

progress[value]::-webkit-progress-bar {

  background-color: #eee;

  border-radius: 2px;

  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) inset;

}

 

 

progress[value]::-webkit-progress-value {

background-image:

  -webkit-linear-gradient( 135deg,

  transparent,

  transparent 33%,

  rgba(0,0,0,.1) 33%,

  rgba(0,0,0,.1) 66%,

  transparent 66%),

    -webkit-linear-gradient( top,

  rgba(255, 255, 255, .25),

  rgba(0,0,0,.2)),

     -webkit-linear-gradient( left, #09c, #690);

     border-radius: 2px;

    background-size: 35px 20px, 100% 100%, 100% 100%;

}

 

 

Result:

Upload2.png

 

You can check below link to know more on this.

http://css-tricks.com/html5-progress-element/

http://lea.verou.me/polyfills/progress/

 

Coming to server side we just needd to create an Entity type with "Media" flag set. And implement the steps covered in these blogs.

How To Upload and Download Files Using SAP NW Gateway SP06

 

scn.sap.com/community/netweaver-gateway/blog/2013/02/22/how-to-read-photo-from-sap-system-using-sap-netweaver-gateway

 

Thanks to the above blogs for their valuable contributions.

 

Code :

method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_STREAM.

 

 

  FIELD-SYMBOLS:<FS_DOC> TYPE ZUPLOAD_DOC.

  Data:ls_doc type ZUPLOAD_DOC,

       lt_file_info type table of string,

       ls_file_info like line of lt_file_info,

       ls_result type ZBAPIRETURN,

       lv_file_info type string.

 

  Data:

       lv_file_name type /GC1/DTE_MSG_TXT,

       lv_file_type type /GC1/DTE_MSG_TXT,

       lv_file_length type string,

       lv_index type sy-tabix.

 

 

  data: lt_doc type table of ZUPLOAD_DOC.

 

 

  CREATE DATA ER_ENTITY TYPE ZUPLOAD_DOC.

  ASSIGN:ER_ENTITY->* TO <FS_DOC>.

 

//File name and other arguements will be received here..

  lv_file_info = iv_slug.

 

 

  split lv_file_info at '|' into table lt_file_info.

  IF sy-subrc eq 0.

    LOOP AT lt_file_info into ls_file_info.

      lv_index = sy-tabix.

      CASE  lv_index.

        WHEN 1.

          lv_applid = ls_file_info.

        WHEN 2.

          lv_file_name = ls_file_info.

        WHEN 3.

          lv_file_type = ls_file_info.

        WHEN 4.

          lv_file_length = ls_file_info.

        WHEN 5.

      ENDCASE.

      clear:ls_file_info,lv_index.

    ENDLOOP.

 

    ls_doc-FNAME = lv_file_name.

    ls_doc-FTYPE = lv_file_type.

    ls_doc-FLENGTH = lv_file_length.

    ls_doc-fcontent = is_media_resource-value."File content will be here.

   append ls_doc to lt_doc[].

        <FS_DOC> = ls_doc.

    endif.

  ENDIF.

 

endmethod.

 

 

Result after reaching server:

Upload3.png

 

Upload_4.png

 

File received successfully.

 

The above logic can handle filesof type .doc, .docx, .pdf, .png, .jpg, .xls, .xlsx.

Please note that this functionality only in modern browsers which supports HTML5 - File API.

I am planning to do a writeup on handling legacy browsers IE9 and below too and also to handle multiple files as well.

 

Please share your feedback and welcome your corrections to improve this content.

 

Cheers

Prabaharan


Disabling Cache for CRUD/FI OData scenarios for a UI5 Application using IE

$
0
0

This Blog attempts to make its audience understand the way to disable the cache content for UI5 Applications using SAP Netweaver Gateway/OData. It should be noted that there are mechanisms to disable the cache in a UI5 development environment but the blog focusses on disabling them using SAP Netweaver Gateway Implementation.

 

Understanding the Scenario/I'm Curious

 

Q: What is the need to disable the CACHE in a UI5 Application that consumes OData Services ?

A: While performing a specific change/functionality in a UI5 application, it is desired that the Application loads fresh data from the backend and does not display stale/unchanged data.

 

Q: When does this happen ?

A: Specifically, When an OData service is called to perform an UPDATE operation, A Read is not enforced to fetch the updated DATA.

 

Q: So Why use GATEWAY/OData to disable cache on a service layer, Why not UI5 environment on an application layer ?

A: UI5 applications are browser specific applications. For some of the browsers: IE, Firefox - The browser engine does not force a cache RE-READ and has its limitations when trying to READ the data after an update is performed.

 

Q: Is this a restriction on only CRUD Services ?

A: This behaviour is exhibited for CRUD and Function Import/Non CRUD Operations as well.

 

Q: Is this a common development to adapt for for all the browsers ?

A: IE specifically, Firefox and Chrome are scenario centric.

 

 

Feeling contented.... Read Further ...

 

~~ How do I do it ?

  • Ok, Let's get down to some Business. What OData scenario am I looking at ?

          How about a CRUD Operation : Let's say an Update !

       

  1. Navigate to your DPC Ext Implementation and locate the CORE_SRV_RUNTIME~READ_ENTITYSET Implementation.
  2. Redefine the method by clicking on the icon as shown in the snapshot.1.png
  3. Copy the code from below into the redefined method !

  

Code Snippet

 

data: ls_header type ihttpnvp.

 

ls_header-name = 'Cache-Control'.

ls_header-value = 'no-cache, no-store'.

APPEND ls_header TO ct_headers.

ls_header-name = 'Pragma'.

ls_header-value = 'no-cache'.

APPEND ls_header TO ct_headers.

 

CALL METHOD SUPER->/IWBEP/IF_MGW_CORE_SRV_RUNTIME~READ_ENTITYSET

    EXPORTING

      iv_entity_name                = iv_entity_name

      iv_source_name              = iv_source_name

      is_paging                          = is_paging

      it_order                               = it_order

      it_filter_select_options  = it_filter_select_options

      is_request_details           = is_request_details

    CHANGING

      ct_headers                         = ct_headers

      cr_entityset                       = cr_entityset     .

 

Looks Simple ? Does it solve my problem.......?

 

Wait !! This is a READ ENTITYSET Implementation.

What if the Data that I'm trying to update is expected from an Entity and not an Entity Set ??     .

As every problem has a solution so does this one ! 

 

4. Navigate to your DPC Ext implementation and Locate the CORE_SRV_RUNTIME~READ_ENTITY Implementation.

2.png

 

5. Redefine the method by clicking on the icon in the first snapshot as shown above.

 

6. Next, copy the code from below into the redefined method !

 

Code Snippet

 

data: ls_header type ihttpnvp.

 

ls_header-name = 'Cache-Control'.

ls_header-value = 'no-cache, no-store'.

APPEND ls_header TO ct_headers.

ls_header-name = 'Pragma'.

ls_header-value = 'no-cache'.

APPEND ls_header TO ct_headers.

 

CALL METHOD SUPER->/IWBEP/IF_MGW_CORE_SRV_RUNTIME~READ_ENTITY

   EXPORTING

     iv_entity_name       = iv_entity_name

     iv_source_name     = iv_source_name

     is_request_details  = is_request_details

   CHANGING

     ct_headers            = ct_headers

     cr_entity               = cr_entity.


Hmmm.....What If I'm calling a Function Import Service to update the Data ? Does the above Read Entity/Read Entity Set implementation takes care of the behaviour as well ?

Not Really. We need to implement something more now !

 

7. Navigate to your DPC Ext implementation and Locate the CORE_SRV_RUNTIME~EXEC_SERVICE_OPERATION Implementation.

3.png

 

8. Redefine the method by clicking on the icon in the first snapshot as shown above..

 

9. Copy the code from below into the redefined method !

 

Code Snippet

 

data: ls_header type ihttpnvp.

 

ls_header-name = 'Cache-Control'.

ls_header-value = 'no-cache, no-store'.

APPEND ls_header TO ct_headers.

ls_header-name = 'Pragma'.

ls_header-value = 'no-cache'.

APPEND ls_header TO ct_headers.

 

CALL METHOD SUPER->/IWBEP/IF_MGW_CORE_SRV_RUNTIME~EXEC_SERVICE_OPERATION

   EXPORTING

     iv_action_name     = iv_action_name

     iv_return_type     = iv_return_type

     iv_multiplicity    = iv_multiplicity

     is_request_details = is_request_details

   CHANGING

     ct_headers         = ct_headers

     cr_data            = cr_data.

 

10. Lastly, Remember to activate all the implementations.

 

That's it. That's all you need to implement.

You can access your UI5 OData application on Internet Explorer without pondering over - Why the Data was not getting updated ? !!!

 

Thank you for spending time on this space. Glad if it helped you !!

Upcoming Webinar: Integration Gateway in SAP Mobile Platform 3.0

$
0
0

This session will introduce you to Integration Gateway and the unique value it adds to SAP Mobile Platform 3.0.

 

Integration Gateway is a reusable technology component that brings SAP one step closer to realizing its vision of delivering, a REST based, harmonized integration layer amongst all the solutions in SAP portfolio and beyond. To achieve that, Integration Gateway implements a runtime that supports various protocols and standards such as HTTP, ODC, SOAP, JPA and JDBC to access data. Furthermore, it comes with design-time tools that allow modelling and provisioning of new RESTful (OData) web services based on the data sources supported by the runtime. As a result, Integration Gateway complements SAP Gateway by provisioning (RESTful) OData services that expose data not only from any SAP system, but also non-SAP. Best of all, as a reusable component, Integration Gateway capabilities will be available across many SAP solutions consistently.

 

Date/Time: June 18, 2014, 4:00pm-5:00pm (CEST)

 

Please join us by clicking the registration link: Integration Gateway in SAP Mobile Platform 3.0 - Adobe Connect

 

(Note: The registration will be closed midnight, June 17, 2014 and it is mandatory for the conference call details)

 

Please contactSAP Virtual Event Servicesif you have registration problems.

 

Cancellation Rules: 

Upcoming SAP CodeJam events around SAP Gateway in June in Germany and Switzerland

$
0
0

29.05. changed a typo since the links to both sessions were mixed up.

 

---------

 

After my last SAP CodeJam event around SAP Gateway and SAPUI5 in Antwerpen beginning of this year it's time to continue with additional SAP CodeJam sessions.


In June there will be two additional SAP CodeJam events around SAP Gateway.

 

The events will take place June 18, 2014 in in Bern (Switzerland) and June 25, 2014 in Bielefeld (Germany).

 

While the event in Bielefeld will be hosted by our partner Lynx-Consulting GmbH the event in Bern will be hosted by our partner NOVO Business Consultants AG.

 

In Bielefeld we will also cover the the development of SAP UI5 applications whereas the focus in Bern be solely on OData Service development.


So I am looking forward to see you there!

 

Best Regards,

André

Open Data Protocol

$
0
0

Open Data Protocol

Open Data Protocol (OData) is a data access protocol initially defined by Microsoft. Versions 1.0, 2.0, and 3.0 are released under the Microsoft Open Specification Promise. Version 4.0 is being standardized at OASIS,[1] and was released in March 2014.[2]

The protocol was designed to provide standard CRUD access to a data source via a website. It is similar to JDBC and ODBC although OData is not limited to SQL databases.

 

Architecture

OData is built on the AtomPub protocol and JSON where the Atom structure is the envelope that contains the data returned from each OData request. An OData request uses theREST model for all requests. Each REST command is a POST, GET, PUT, PATCH, or DELETE http request (mapping to CRUD) where the specifics of the command are in the url.

  • GET: Get a collection of entities (as a feed document) or a single entity(as an entry document).
  • POST: Create a new entity from an entry document.
  • PUT: Update an existing entity with an entry document.
  • PATCH: Update an existing entity with a partial entry document.
  • DELETE: Remove an entity.

Any platform that provides support for HTTP and XML is enough to form HTTP requests to interact with AtomPub. The OData specification defines how AtomPub is used to standardize a typed, resource-oriented CRUD interface for manipulating data sources.

 

Typical Workflow When Creating a New User Interface:-

For all browser based application data has to invoke from secure

diag.png


 

 

 

Service Builder – Data Model:-

Create / Model OData  

Artifacts --

  • Entity Types 
  • Entity Sets     
  • Complex Types
  • Associations
  • Association Sets
  • Function Imports    

1.png    

Can make association on principle to dependent entity with the key field (ex : cardinality 0 :M  maintain )

5.png                            

-

Generation of runtime objects :-

After generation of odata artifacts it will create 4 class (1 model provider class and 2 data provider class) and 2 service (technical model and service name) .

 

 

3.png2.png

 

 

Service implementation – CRUD methods:-

Direct navigation into the CRUD –

Methods--

  • Create
  • Read and Query
  • Update
  • Delete

On service implementation Node you can implement your business logic .  

 

6.png

 

 

Service Builder – runtime artifacts:-

ABAP classes for

  • Model definition
  • Service implementation

Service registration in the backend

Service registration in the backend. You need to maintain system alias In transaction SPRO open theSAP Reference IMG and navigate to SAP NetWeaverGateway Service Enablement  -Backend OData Channel -Service Development for Backend OData Channel-Maintain Modelsand Maintain Services.

4.png

 

/iwfnd/maint_service :-


Can call your service directly on browser and also on gateway client

7.png

 

Service document in the browser and entity types in

SEGW

There are 5 method you can use as per your business logic and execute .

As you see in below result association on ID . for more information on Odata links  

you can open your service on browser

http://<host>:<port>/sap/opu/odata/sap/<Service Name >

8.png

 

 

 

Summary - Transactions you should know as a developer:-


Gateway Node Activation

SICF

Includes various functions for monitoring, analysis, and troubleshooting in the ICF environment. You can also make use of the central Application Server analysis functions to identify issues such as performance problems in ICF applications.

Gateway Client

/IWFND/GW_CLIENT

SAP NetWeaver Gateway is a powerful tool that enhances the existing Error Log. Also allows you to simulate service execution. (Similar to tools like RESTClient for Firefox)

Error Log

/IWFND/ERROR_LOG

The Error Log for SAP NetWeaver Gateway hub systems is a helpful addition to the existing Application Log Viewer and provides detailed context information about errors that have occurred at runtime.

Gateway Service Builder

SEGW

A completely new design-time transaction, which provides developers with an easy-to-use set of tools for creating services. It has been conceived for the code-based OData Channel and supports developers throughout the entire development life cycle of a service.

Register/Test Backend System

SM59

Your backend system has to be registered as an SAP system alias in the SAP NetWeaver Gateway Implementation Guide (IMG) on your SAP NetWeaver Gateway system. In addition, an RFC destination has to be defined in transaction SM59.

 

Gateway Service Builder - development flow in detail

 

this image reference : CD204 presentation Teched @ 2012

 

15.png


Day 1 highlights for SAP Gateway at SAPPHIRE 2014

$
0
0

What a powerful keynote speech from SAP CEO Bill McDermott this morning to open the SAPPHIRE 2014! Speed, Simplicity and Personalization are the key success factors for SAP software as Bill outlined.


Over Crowded Google Glass Demo Theater Session

We had the first Google Glass demo theater session today. Over 100 people attended with standing room only at the end. This Google Glass demo enables a hands-free laptop repair scenario with connectivity through Cloud to SAP systems to retrieve laptop details, repair steps, parts inventory and order missing parts real-time via Gateway services. The app also provides video guide with repair procedure and the video conferencing ability to consult with 2nd level support. In this demo SAP Gateway plays a key role in the integration to SAP system.


If you missed today’s session, check out the other Google Glass demo sessions listed below. If you are at SAPPHIRE, you can even play with it yourself on Industry Campus at the Retail expert table (IN123) .

day1_googleglassdemo3.jpg

                              Glass view was projected on screen

 

day1_googleglassdemo4.jpg

                    Google Glass demo with standing room only

 


GoogleGlassDemoArchitecture.png

                 Google Glass demo architecture diagram (follow the yellow path for components in this demo)


 

This demo was developed together with SAP partner Quantilus. Here is a blog with more details written by Quantilus -Intelligent Automation for the Enterprise through SAP Gateway


Busy Middleware Expert Table on Technology Campus

Many customers came by the Middleware Expert table to discuss about SAP Gateway solution today. If you are onsite, definately check it out and get the latest news about SAP Middlware solutions. You can play with a cutting edge augmented reality app there as well.

day1_experttable.JPG

 

 

Upcoming Education and Demo Sessions

There are more SAP Gateway sessions coming up the next 2 days at ASUG and SAPPHIRE. Here is a snapshot of them.


ASUG or SAPPHIRE

Category

Speaker

Session ID

Title

Day

Time    

Room

ASUG

Education

Session

eBay: Ramesh Murugan 

SAP: 

Himanshu

Pande 

3707

Simplified user experience for
managers leveraging SAP Gateway

– eBay case study

Wed, June 4th 1:45-2:45 PM

S330E:

S. Concourse, L3

SAPPHIRE

Demo Theater

SAP: Joav Bally

TE16119

Deliver a World-Class User
Experience (Google Glass demo) 

Wed, June 4th 

5:00–5:20 PM

Technology Demo Theater TE301
SAPPHIREDemo TheaterSAP: Jeff Gebo

TE13966

Speed up App Integration with
  Mobile-First Middleware
Wed, June 4th9:30 – 9:50 AM

2:30 – 2:50 PM

Technology Demo Theater TE303
SAPPHIRE

Demo Theater

SAP: Himanshu Pande

LB16285

Use Machine Vision in your Enterprise (Google Glass demo)

Wed, June 4;


Thu, June 5

9:00 -9:20 AM; 

 

 

11:30 – 11:50 AM

Demo Theater LB207

 

 

To know more about the overall SAP Gateway SAPPHIRE program offering see this blog - What is Exciting about SAP Gateway at SAPPHIRE


Follow us online:

SAP GatewayTwitter| LinkedIn |Youtube | SCN


SAP Gateway Product Management Team

Day 2 Highlights for SAP Gateway at SAPPHIRE 2014

$
0
0

Yet another exciting day at SAPPHIRE 2014! The day started with an inspiring message from Dr. Hasso Plattner, SAP Founder and Chairman of the SAP Supervisory board - “If we simplify everything, we can do anything”. Later, Harvard School Prof. Clayton M. Christensen shared stage with Dr. Hasso Plattner during the SAP Keynote Presentation : The Future of Enterprise Applications | SAPPHIRE NOW, where they discussed how SAP HANA is leading the renewal  of enterprise  applications.

 

In the SAP Gateway news, the first session of the Google Glass demo was held yesterday, and we had an amazing turn out. More than 100 people attended the session! This session was followed by a session in the evening with CalPortland, where they shared 2 of their powerful live applications using SAP Gateway. To catch the complete story about SAP Gateway at SAPPHIRE on Day1, read the blog.

 

Day 2 Sessions Overview

Today was a busy day for the SAP Gateway team at SAPPHIRE. The Google Glass demo sessions started out  at 9 am in the Line of Business Campus.


p5.jpg

Himanshu Pande Presenting the Google Glass Demo


This was followed by our customer's session - Simplified User experience for managers Leveraging SAP Gateway : eBay Case Study, in the afternoon.

p8.JPG

Ramesh Murugan, Senior Manager HR Technologies eBay


Lastly, Jeff Gebo had a session "Speed up App Integration with Mobile-first Middleware, were he discussed about Integration Gateway.

p9.jpg


Saw our Google Glass App demos? Go play with the application and be prepared to be amazed!

SAP Gateway technology enables development of “Anywhere in the world class UX” on cutting edge devices. We have two new applications, Go To Work and Visual Showroom developed with our partners Quantilus. They are available to fiddle with at the Middleware Expert Table, Technology Campus and Retail Expert Table, Industry Campus.

p2.jpg

A busy day at the Middleware Expert Table


  • Go to Work is a Google Glass application for hands free laptop repair, with features such as Machine Vision, Voice Recognition, 3-D visualization, Step by Step help, video guidance and many more. It even allows you to check inventory and order parts online.
  • Visual Showroom is a tablet based application, using which a user can see the augmented reality of an interior design item such as furniture etc. User can pick the right size and design pattern from available catalog entries and trigger the orders in SAP easily from anywhere.

p3.jpgp4.jpg

Visual Showroom Application View


Upcoming Demo Session


ASUG/SAPPHIRECategorySession IDTitleDayTimeRoom
SAPPHIREDemo TheaterLB16285Use Machine Vision in your Enterprise (Google Glass demo)Thursday, June 511:30-11:50AMDemo Theater LB207

 

To know more about the overall SAP Gateway SAPPHIRE program offering see this blog - What is Exciting about SAP Gateway at SAPPHIRE


Follow us online:

SAP GatewayTwitter| LinkedIn |Youtube | SCN



SAP Gateway Product Management Team

Day 3 Highlights for SAP Gateway at SAPPHIRENOW 2014

$
0
0

After 2 days of jam packed sessions and exciting keynotes by SAP executives, I believe we can put away any doubts on SAP's transformation to a Cloud company after this year's SAPPHIRE NOW.

 

Why? "Becuase We Can"

 

 

 

Although it is the last day for SAPPHIRE NOW, conference attendees still made their way to the final stretch of the conference after a super-charged concert last night performed by Jon Bon Jovi and The Kings of Suburbia.

 

We kicked off the day with a special keynote by Rodolpho Cardenuto of SAP Global Partner Operation together with partners OpenText and Adobe. They talked about how SAP valued our partners to accelerate our customer engagement. Partners are certainly a key piece in the puzzle for SAP to become a Cloud company.  If you are a long-time SNL (Saturday Night Live) fan like me, you must love the presence of Dana Carvey, Dennis Miller and Kevin Nealon on stage. That really brought back a lot of good old memories from the ‘90s.

 

As mentioned by Ning-Jing and Supriya in their blogs in the past 2 days, our Google Glass demo was crowded with technology enthusiasts and Gateway developers. On its last showing today, it still drew a big crowd to check out what Gateway can do with Google Glass. Today, SAP’s Himanshu Pande and the staff from Quantilus presented in the session – “Use Machine Vision in your Enterprise” – and showcased the fascinating application (Go to Work) built by SAP Gateway and Google Glass.

 

image03.jpeg

 

The team from SAP Gateway for Microsoft also presented a session on how our customer, Hess, uses SAP Gateway for Microsoft to build an Invoice Approvals Solutions to improve the user experience for their field users. The session was jointly presented by SAP’s Jenny Lundberg, Capgemini (partner) and Hess (customer).

 

image05.jpeg

 

 

We would like to take this opportunity to thank all of you who stopped by our demo theater and talked to us. Let us know how you want SAP Gateway makes an impact in your workplace. Drop us a line in the following social media channels below. Yes, it is that SIMPLE! (As we learned how simplicity is so important to us)

 

If you are interested in any missing sessions, you can always check our website for the replays (click below).

 

SNAG-0200.jpg

Follow us online:

SAP GatewayTwitter| LinkedIn |Youtube | SCN


More pictures on Facebook here.

 

See you all next year!

 

SAP Gateway Product Management Team


SAP Gateway & Device Agnostic Reporting

$
0
0

In this blog I am going to share my experience in implementing multiple device agnostic reports and dashbords at one of our clients in partnership with SAP.

 

Every company wants to remain ahead of the competition in business practices and the internal processes. As part of this effort my client started looking for a solution to meet the requested reporting requirement for 5000 managers. Among the few criteria for the solution selection was scalability, security, reusability, low cost and high ROI.  When we proposed the solution using SAP Gateway, it found a natural ally and as the concept developed the greater traction it took with the client. Successes of the first solution lead to the development of multiple solutions across various platforms and greater adaptability across the complete enterprise landscape.

 

 

Since we are talking about the landscape here, let me talk about a little bit about the landscape which we developed to support this solution.  After the initial proof of concept, the initiative was taken to set up a dedicated landscape for SAP Gateway. The first step in this effort was the system sizing. Since the client is a SAP shop, so it was natural to accept the concept of three system landscape for SAP Gateway i.e. Development, Quality Assurance and Production systems; although sandbox system was also part of the landscape. The landscape systems were installed and configured as the solution went from one stage to another i.e. from development to quality assurance to production.

 

The solutions were built for BI running on an SAP HANA environment.  One of the client requirements was that the solution must use the existing BEx
queries. So the idea that the solution must be able to reuse the SAP delivered and custom objects was tested from very beginning. This adaptability is SAP Gateway very important features, so you are looking at a product which can use the standard and custom objects with the same ease. This is a big cost savings; look at it from the client side, how much they have invested in all these years to develop the SAP objects to meet their specific business needs. And here is a solution which is using those same objects to deliver a new age device agnostic solution. So you are moving from a blue screen to the new User Interface at fraction of the cost.

 

I will not say that the first implementation cycle was without any challenges, we had our share. A few stakeholders had their concerns; setting up the security roles was a major milestone. But once we had the SAP Gateway configured and setup the process was pretty clean with a few bumps on the way for which we had SAP team to support us (Thanks Tobias Griebe and Peter Ng for their help and support).

 

Once the services were setup for the backend components, we exposed them to the frontend as JSON instead of standard XML, they are more light weight and frontend team was able to absorb them to provide the required user interface.

 

We did move the SAP objects through the CTS layer using SAP transports so the client standard change management was applicable on all our changes. We also took every effort to create as much documentation as possible as this was a new technology introduction. Once we had our software components
in Quality System we did integration and regression testing. And after reaching production, since it was a new system, we did both regression and stress testing to make sure that the system can support the load of close to 5000 business users.

SAP River Rapid Development Experience, the Next IDE

$
0
0

Gateway Productivity Accelerator (GWPA) is a huge success among mobile developers who want to create fast, great looking, robust mobile apps that consume business data from SAP systems. GWPA consumption tools provide toolkits for creating native mobile apps for iOS and Android as well as HTML and PHP web applications.

 

However, in recent years more and more mobile developers are shifting from native apps to hybrid and web apps. The appeal of “develop once, deploy everywhere” has led to a fast pace adoption of technologies such as PhoneGap Cordova and Titanium Appcelerator.

 

Another trend that is sweeping the web development world in recent years is the move to cloud based IDEs such as Orion, Cloud9, ShiftEdit, CodeEnvy, and many more. The ease of use, zero installation, small footprint, and built-in integration, are huge benefits that draw developers into abandoning Eclipse-based tools and moving to the cloud.

 

The combination of these two mind shifts in the development world has led us to the conclusion that a rich, fully integrated web IDE is the way to go.

 

Introducing SAP River RDE– the new web-based development tool from SAP. With SAP River RDE you can easily create modern, responsive, elegant SAP UI5 applications that will look great on any screen. With support for OData service exploration and consumption, code generation, built-in application templates, SAP River RDE is the perfect tool for application developers. It offers a productive and simple approach to web development with code editors that offer code completion, syntax highlighting, wizards for creating starter apps, instant preview, mock-data, application extensibility, GIT client and much more.

 

SAP RDE is seamlessly integrated with SAP Hana Cloud Platform, and in the future will be integrated with the SAP Mobile Platform, so you can truly write your app once, and deploy it anywhere. This makes SAP River RDE is the natural successor of GWPA Consumption Tools.

 

SAP River RDE – the development tool of the future.

Recognize File name - Special characters and LOTE's(Foreign texts)

$
0
0

Hi All,

This blog is about identifying special characters and LOTE's (Langages Other Than English) in a file name when we upload a file from user's machine.

 

Scenario:

Upload a file name containing special chars. Ex:A Germanic file name.

 

Encode the file name using the below method:

encodeURIComponent(file.name)

 

Pass this value to the slug paramter as shown below.

 

File upload code:

 

<!DOCTYPE html>

<html>

  <head>

  <meta  charset="UTF-8">

  <script src="https://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" > </script>

    <script type="text/javascript">

    var token1 = '';

    var xhr = new window.XMLHttpRequest();

    var file = " ";

    function rundCode() {

         file = document.getElementById('attafh').files[0];

      

        if (file) {

            UploadMe(file);

        }

    }   

  

    function UploadMe(readFile) {

        var reader = new FileReader();

        reader.readAsArrayBuffer(readFile); //array buffer      

        reader.onload = loaded;

//         reader.onerror = errorHandler;

    }

  

    function loaded(evt) {

      

        var fileString = evt.target.result;                         

 

         // Begin of Get Token  

             $.ajax({

                 url: 'https://aa/sap/inv/opu/odata/sap/Y_GET_ATTACHMENT/$metadata',

                 type: "GET",

                 contentType: "application/atom+xml;type\x3dentry;",

                 dataType: "",

                 headers: {

                     "x-csrf-token": "fetch",

                     Authorization: "Basic ZGd1cnU6WWFsdGVjaDM="

                 },

             success: function (data, textStatus, request) {

             token1 = request.getResponseHeader('x-csrf-token');

                        

                 $.ajax({              

                  type: 'POST',

                  url: "https://aaa/sap/inv/opu/odata/sap/Y_GET_ATTACHMENT/Document/",                  

                   xhr: function()

                 {                  

                    //Upload progress

                     xhr.upload.addEventListener("progress", function(evt){

                      if (evt.lengthComputable) {

                        var percentComplete = Math.round(evt.loaded * 100 / evt.total);

                     $('.progress').val(percentComplete);

                       //Do something with upload progress

                       console.log(percentComplete);

                      }

                    }, false);       

                                    

                  xhr.addEventListener("error", function(evt){

                alert("There was an error attempting to upload the file.");

                return;

                    }, false);

                

                    return xhr;

                 },

               

                contentType: "application/json",

                processData: false,                          

                data: fileString,

                dataType: "text",

                headers: {

                          "x-csrf-token" : token1,

                          "Authorization" : "Basic ZGaaaaaa",

                          "slug":  encodeURIComponent(file.name)

                },

                success: function(data){

                   alert("File uploaded successfully");

                  }

                });

                  

                  }

             });

    };

  

    function abortRead() {

    xhr.abort();

    $('.progress').val(0);

      }

 

 

 

    </script>

  </head>

  <body>

    <input type="file" id="attafh"  class="AlltextAccount"  />

      <input type="button" value="upload" onclick="rundCode()" />

      <button onclick="abortRead();">Cancel</button>

      <progress class="progress" value="0" max="100"> </progress>

 

 

  </body>

</html>

 

 

 

The encodeURIComponent() method encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two "surrogate" characters).

 

Now submit the file the SAP Gateway server.

1.png

 

You can see the UTF-8(Unicodes) characters received and it is decoded using method as shown below.

2.png

 

data:v_unescaped type string,

  v_escaped   type string,

  v_return_code type i.

v_escaped = lv_file_info = iv_slug.

 

//Decode the Unicode texts to original string.

  CALL METHOD cl_http_utility=>unescape_url

    EXPORTING

      escaped   = v_escaped

    RECEIVING

      unescaped = v_unescaped.

 

References:

 

http://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=269418752

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent

 

 

Thats all. We are done !!!

 

Please share your feedback.

 

Regards

Prabaharan

Recorded Webinar Session: Integration Gateway in SAP Mobile Platform 3.0

$
0
0

In case you missed our webinar session about Integration Gateway in SAP Mobile Platform 3.0,you can watch the recording here: http://youtu.be/3Vh_wufh0vk. Integration Gateway is a reusable technology component that brings SAP one step closer to realizing its vision of delivering a REST based, harmonized integration layer amongst all the solutions in SAP portfolio and beyond. To achieve that, Integration Gateway implements a runtime that supports various protocols and standards such as HTTP, ODC, SOAP, JPA and JDBC to access data. Furthermore, it comes with design-time tools that allow modelling and provisioning of new RESTful (OData) web services based on the data sources supported by the runtime. As a result, Integration Gateway complements SAP Gateway by provisioning (RESTful) OData services that expose data not only from any SAP system, but also non-SAP. Best of all, as a reusable component, Integration Gateway capabilities will be available across many SAP solutions consistently.

SAP CodeJam in Bielefeld about SAP Gateway and SAPUI5

$
0
0

logo_SAP_CodeJam_Bielefeld.jpg

 

On June the 25th my colleague Jens Himmelrath and I conducted a SAP CodeJam event about SAP Gateway and SAPUI5. The event was organized and hosted by our partner Lynx at their subsidary in Bielefeld.

 

The idea of this event was to show what's needed in order to develop Fiori like applications by explaining both SAPUI5 development as well as OData service development using SAP Gateway end to end.

 

First I was a little bit unsure about the location because of the Bielefeld Conspiracy that claims that Bielefeld does not actually exist.

 

So we were curious of what to find ...


After having conducted the event I can now confirm that Bielefeld does really exist since I have been there ...

 

However some of you will now think that I belong to THEM that have conspired to create the illusion of the city’s existence ...

 

As a proof you can see the room that was packed with 37 participants from 18 different customers and partners.

 

IMG_1446.JPGIMG_1447.JPG

We started at 10 AM after a warm welcome of the managing director of Lynx with short presentations where we gave an introduction to SAPUI5 and SAP Gateway. We had lots of interesting discussions and got also interesting questions that we took back to our development teams.

WP_20140625_022.jpgIMG_1440.JPG

 

At noon there was time to get some food so that everybody could continue until the end of the event at 4 PM.

 

We are looking forward to run similar events elsewhere.

 

So if you are interested please let my colleagues from the SAP CodeJam team and me know.

 

How to run such an event has been described in this document How to host an SAP CodeJam.

 

Best Regards,
Andre

SAP Gateway Developer Tools – Bridging the Past, Present and Future

$
0
0

Most of you would already know that SAP has officially ended the support of Eclipse Juno in the end of June 2014. As SAP generally tries to support the current and the previous versions of Eclipse, we will soon remove references to https://tools.hana.ondemand.com/juno from the index pages. Only the tools which support Eclipse Kepler and Luna will be listed on “SAP Development Tools for Eclipse” update site.

 

Since SAP NetWeaver Gateway Productivity Accelerator(GWPA) toolkit is only available on Juno, as a developer working with Gateway platform should you be worried? Do Gateway tools support Kepler yet? When can you expect the new tools? Via this blog we would like to answer some of these questions which concern your day to day work.

 

First and foremost, until Kepler based tools are available you can continue to use the link https://tools.hana.ondemand.com/juno in the Eclipse environment via “Help à Install New Software”. This link will be active at least for the whole of 2014 even after end of support for Juno. Once Kepler based tools are available we recommend that you switch to Kepler version.

 

Secondly, with regards to Kepler we need to first explain a bit about “GWPA” package itself. GWPA is a bundle of multiple toolkits which cover both “provisioning” and “consumption” aspects, in addition to an “OData Modeler” which acts as a bridge between the two. Provisioning tools such as “Toolkit for Integration Gateway” help in creating and deploying services on a given target platform, and Consumption tools are platform specific SDKs to consume these services in different clients such as iOS, Android and Java.

 

Let’s talk about these three individual components of GWPA:

 

  • OData Modeler– We will have a new and improved tool in Kepler
  • Provisioning tools– Currently we have “Toolkit for Integration Gateway” which supports SAP Mobile Platform (SMP) 3.0. In Kepler we will have an improved toolkit called “API Toolkit for SAP Mobile Platform” offering similar functionality and more
  • Consumption tools– Please refer this link for more details

 

Thirdly, it is important to note that in Kepler the provisioning tools will be found under “SAP Mobile Platform tools” category. This is done keeping in view our long term vision of Gateway design tooling and its positioning across SAP ecosystem.

 

We expect to release Kepler based tools very soon. Stay tuned for additional communication on this, but until then we recommend that you continue to access Juno based tooling from https://tools.hana.ondemand.com/juno update site.

 

CC: SAP Mobile Platform Developer Center

Consuming OData in Python

$
0
0

Intro

Python is my favorite programming language, the reason for this blog post is just my curiosity.

 

There are few ways how to make python work with SAP.

 

But what about a connection to gateway using OData?

There are documents about connecting to gateway forPHP, Java Script, Flex, .NET, Objective C in SAP NetWeaver Gateway Developer Center. But where is Python?


 

OData library for python

I started to look for an odata library and found two reasonable options:

  1. OData-py is "OData provider for Google App Engine Datastore". Unfortunately, it can be probably used only in google app engine, has several limitations, and is not maintained since 2011.
  2. Pyslet is "Python for Standards in Learning Education & Training". It includes module which implements OData client and also server. Let's see what it can offer.



Running Pyslet on web.py

Web.py is a small python framework for creating web applications. Integration was simple - install pyslet, import a module and you are can start consuming an OData service. I created small hello world application that fetches product list and displays product names.

 

Header:

from pyslet.odata2.client import Client

 

Handling class:

class index:    def GET(self):    c=Client("http://services.odata.org/V2/Northwind/Northwind.svc/")    products=c.feeds['Products'].OpenCollection()    productNames = []    for k,p in products.iteritems():    productNames.append(p['ProductName'].value)        web.header('Content-Type', 'text/html')        return render_template('index.html', products = productNames)

 

Template:

<!DOCTYPE html><html lang="en">  <head>    <meta charset="utf-8">    <title>Python + ODATA</title>  </head>  <body>    <table border="1">    <tr><td><strong>Name</strong></td></tr>     {% for name in products %}     <tr><td>{{name}}</td></tr>     {% endfor %}  </table>  </body></html>

 

And the result:

python-data.jpg

 

Conclusion

I used information from author's blog - http://swl10.blogspot.com/. More useful and detail information can be found there.

 

This was just a simple experiment. Author claims that the module does not work with HTTPS OData service, so basically it cannot be used in real environment.

Next challenge? HTTPS source and more sophisticated application!

 

Looking for you feedback.


FaceSearch – Let's Build a HANA/Gateway/UI5 App

$
0
0

Back in February, I finished up the Matt Harding’s Fiori Like Challenge with a laundry list of items I wanted to get to in the future. Well I had a few days a couple of months or so ago and while I wait for my next break in deliverables, I better publish where I’m up to, hence the future is now (or last month…).

 

Scope of Work and Blog

 

I could spend days producing a final product and then blogging about the experience; but that has a few issues in my mind:

 

  • I could get too busy to finish (has already happened);
  • I may forget key aspects of the solution if wait to the end to document the solution (would have happened but luckily have my mind backed up in this blog);
  • The blog will become such a long blog with so many different facets that it misses the various audiences entirely (partly very likely, but let’s move on regardless).

 

So with that in mind, the blogs will be split up as follows:

 

Part 1 (This Blog) – FaceSearch Filter Screen


Build the initial FaceSearch page, hooking into a HANA query to provide near real-time feedback on number of faces found. This will involve:

      • Creation of the UI5 project based on the high resolution prototype but made production quality
      • Outside-In Service Design for just the search interface query (Using Gateway Productivity Accelerator oData modelling tools) – If I was splitting development between UI and back-end – this would be a good initial approach to agree on all the services – but a little superficial in this example
      • Getting the HANA NetWeaver instance up and running, including setting up my client.
      • Implementing the Service within Gateway using hard coded return values.
      • Building a mock HR name database for use in FaceSearch

Edit: The following was also scheduled for this blog, but my AWS instance got corrupted (no idea how), so I will move the following sections to my next blog, and wrap up with a teaser on how easy HANA can make Google-like queries.

      • Building a HANA Core Data Services (CDS) view to get my SQL logic just right.
      • Building an ABAP Managed Database Procedure (AMDP) for use with Gateway
      • Hooking up the Gateway implementation to the AMDP

 

Part 2 (Next Blog) – FaceSearch Results Screen


Build the results “Faces” page. This will involve:

      • Enhancing the Gateway service to handle photos
      • Mocking up a 100x100(?) faces into a single image using a command line interface (may or may not hook this up for real to the ABAP system, but this would be fairly straightforward). The objective is to take a large number of people’s photos at a high resolution, shrink them and then combine them into a single image with offsets to each person’s photo to minimise network overhead and make the FaceSearch results screen appear instantly (once cached)
        • Post SapphireNow – Am I meant to make all faces appear in circles (horrible idea in my opinion)???
      • Build a UI5 control to handle images with offsets and width/height for the above image
      • Build the results page

 

Part 3 (Last Blog) – Face Detail Screen and Optimisation


Build final page and optimise:

      • Build the Person details page including quick actions such as call number, email, etc;
      • Deploy UI5 content to HCP and connect via the backend connector and leverage HCP authentication options (try to get SSO?)
      • Play around with HTML5 offline options and optimisation of UI5 (I still don’t like how heavy it is to start)
      • Look at pre-cache of image files through async loading of manifest file containing images (hidden images)
      • Add Bookmark functionality

 

Okay – Let’s begin by going back to my notes from just over a month ago…


And because the SCN blog editor is really bad with copying and pasting images, I've decided to share the rest of this blog as a link to a pdf since there are way too many pictures to upload. Note - Anyone from SAP - Would really appreciate if someone would upload this pdf to SCN even though it's not allowed :-(


I hope you enjoy and/or get something out of it and even if you don't, I hope this inspires you to give yourself your own challenge to get to know SAP even better...

Implementing Expand Entity/Entity Set

$
0
0

Hi Folks,

 

Finally got some time to write a Blog on something which was a common question from a lot of audience here, so doing my bit of help here .. hope this helps a lot of beginners and not for experts

 

SAP Documentation for Expand Understanding

 

https://help.sap.com/saphelp_gateway20sp08/helpdata/en/ca/c683e803494b77a2e1290b987556e2/content.htm

 

Some of the Blogs already posted in SCN relevant to Expand and Deep Entity .

 

Improved Inside-Out Modelling

 

 

Step by Step development for CREATE_DEEP_ENTITY operation

 

 

Requirement

 

Considering a basic scenario where i am using  BAPI_PO_GETDETAIL which has multiple output tables and input is PO number

 

bapipo.JPG

 

Now we shall start with SAP Gateway

 

 

Create Project in SEGW

 

Create three entity types and Entity Sets


Entity Type-1- Header   

Entity Type-2- Item

Entity Type-3- Schedule


po1.JPG

Entity Set-1- HeaderSet

Entity Set-2- ItemSet

Entity Set-3- ScheduleSet


po2.JPG

Create Association


Association-1 -  AssItem (Without key fields mapping)

Association-2 -  AssSchedule (Without key fields mapping)


po3.JPG


Create Navigation


Navigation-1 -  NavItem

Navigation-2 -  NavSchedule


po4.JPG


Let’s generate runtime artifacts. Click on generate runtime objects button. It will display

popup . Keep the default class names as-is and click on enter button.

Once generation is successful, you will get 4 classes. 2 for Data provider and 2 for Model provider.


po5.JPG


we have to Redefine the method/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITYSET


po6.JPG


Code Snippet


METHOD /iwbep/if_mgw_appl_srv_runtime~get_expanded_entityset.

 

*-------------------------------------------------------------------------*

*             Deep Structure

*-------------------------------------------------------------------------*

   DATABEGIN OF ls_order_items.

   INCLUDE       TYPE zcl_zproj_982_mpc=>ts_header.

   DATA: navitem       TYPE STANDARD TABLE OF zcl_zproj_982_mpc=>ts_item WITH DEFAULT KEY.

   DATA: navschedule   TYPE STANDARD TABLE OF zcl_zproj_982_mpc=>ts_schedule WITH DEFAULT KEY,

        END OF ls_order_items,

        ls_item1       TYPE zcl_zproj_982_mpc=>ts_item,

        ls_schedle1    TYPE zcl_zproj_982_mpc=>ts_schedule.

 

*-------------------------------------------------------------------------*

*             Data Declarations

*-------------------------------------------------------------------------*

   DATA :   ls_item                    TYPE zcl_zproj_982_mpc_ext=>ts_item,

            lt_item                    TYPE TABLE OF zcl_zproj_982_mpc_ext=>ts_item,

            ls_sch                     TYPE zcl_zproj_982_mpc_ext=>ts_schedule,

            lt_sch                     TYPE TABLE OF zcl_zproj_982_mpc_ext=>ts_schedule,

            ls_header                  TYPE zcl_zproj_982_mpc_ext=>ty_header,

            lthead                     TYPE STANDARD TABLE OF bapiekkol,

            lshead                     TYPE bapiekkol,

            lsitem                     TYPE bapiekpo,

            ltitem                     TYPE STANDARD TABLE OF bapiekpo,

            lv_filter_str              TYPE string,

            lt_filter_select_options   TYPE /iwbep/t_mgw_select_option,

            ls_filter                  TYPE /iwbep/s_mgw_select_option,

            ls_filter_range            TYPE /iwbep/s_cod_select_option,

            ls_expanded_clause1        LIKE LINE OF           et_expanded_tech_clauses,

            ls_expanded_clause2        LIKE LINE OF           et_expanded_tech_clauses,

            lv_ebeln                   TYPE ebeln,

            lt_order_items             LIKE TABLE OF ls_order_items,

            ltsch                      TYPE STANDARD TABLE OF bapieket,

            lssch                      TYPE bapieket.

 

*-------------------------------------------------------------------------*

*             Entity Set - HeaderSet

*-------------------------------------------------------------------------*

   CASE iv_entity_set_name.

     WHEN 'HeaderSet'.

       LOOP AT it_filter_select_options INTO ls_filter.

 

         LOOP AT ls_filter-select_options INTO ls_filter_range.

           TRANSLATE ls_filter-property TO UPPER CASE.

           CASE ls_filter-property.

             WHEN 'PONUMBER'.

               lv_ebeln = ls_filter_range-low.

             WHEN OTHERS.

               " Log message in the application log

               me->/iwbep/if_sb_dpc_comm_services~log_message(

                 EXPORTING

                   iv_msg_type   = 'E'

                   iv_msg_id     = '/IWBEP/MC_SB_DPC_ADM'

                   iv_msg_number = 020

                   iv_msg_v1     = ls_filter-property ).

               " Raise Exception

               RAISE EXCEPTION TYPE /iwbep/cx_mgw_tech_exception

                 EXPORTING

                   textid = /iwbep/cx_mgw_tech_exception=>internal_error.

           ENDCASE.

         ENDLOOP.

 

       ENDLOOP.

*-------------------------------------------------------------------------*

*             Call Method-BAPI_PO_GETDETAIL

*-------------------------------------------------------------------------*

 

       CALL FUNCTION 'BAPI_PO_GETDETAIL'

         EXPORTING

           purchaseorder     = lv_ebeln

           items             = 'X'

           schedules         = 'X'

         IMPORTING

           po_header         = lshead

*         PO_ADDRESS        =

         TABLES

*         PO_HEADER_TEXTS   =

           po_items          = ltitem

           po_item_schedules = ltsch.

*-------------------------------------------------------------------------*

*             Fill Header Values to Deep Structure

*-------------------------------------------------------------------------*

       ls_order_items-ponumber = lshead-po_number.

       ls_order_items-ccode = lshead-co_code.

       ls_order_items-doctype = lshead-doc_type.

*-------------------------------------------------------------------------*

*             Fill Item values to Deep Structure

*-------------------------------------------------------------------------*

       LOOP AT ltitem INTO lsitem.

         CLEAR ls_item1.

         ls_item1-ponumber = lsitem-po_number.

         CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

           EXPORTING

             input  = ls_item1-ponumber

           IMPORTING

             output = ls_item1-ponumber.

 

         ls_item1-poitem = lsitem-po_item.

         ls_item1-material = lsitem-material.

         APPEND ls_item1 TO ls_order_items-navitem.

       ENDLOOP.

*-------------------------------------------------------------------------*

*             Fill Schedule values to Deep Strcture

*-------------------------------------------------------------------------*

       LOOP AT ltsch INTO lssch.

         CLEAR ls_item1.

*        ls_item1-ponumber = lsitem-po_number.

         ls_schedle1-poitem = lssch-po_item.

         ls_schedle1-serial = lssch-serial_no.

         APPEND ls_schedle1 TO ls_order_items-navschedule.

       ENDLOOP.

*-------------------------------------------------------------------------*

*             Assign the Navigation Proprties name to Expanded Tech clauses

*-------------------------------------------------------------------------*

       ls_expanded_clause1  = 'NAVITEM'.

       ls_expanded_clause2  = 'NAVSCHEDULE'.

       APPEND ls_expanded_clause1 TO et_expanded_tech_clauses.

       APPEND ls_expanded_clause2 TO et_expanded_tech_clauses.

*-------------------------------------------------------------------------*

*             Append Deep Strcture Values to Final Internal Table

*-------------------------------------------------------------------------*

       APPEND ls_order_items TO lt_order_items.

 

*-------------------------------------------------------------------------*

*             Send back Response to Consumer

*-------------------------------------------------------------------------*

 

       copy_data_to_ref(

         EXPORTING

           is_data = lt_order_items

         CHANGING

           cr_data = er_entityset ).

 

     WHEN OTHERS.

   ENDCASE.

ENDMETHOD.

 

Coding Part Done....Lets move to Testing

 

Test Case 1:

 

URI : /sap/opu/odata/sap/ZPROJ_982_SRV/HeaderSet?$filter=PoNumber eq '4500000163'&$expand=NavItem


po9.png

Test Case 2:

 

URI : /sap/opu/odata/sap/ZPROJ_982_SRV/HeaderSet?$filter=PoNumber eq '4500000163'&$expand=NavItem,NavSchedule


po8.JPG

 

 

For Expand Entity :-

 

From the modelling point of view there wont be any changes

but in DPC we need to Redefine the method /iwbep/if_mgw_appl_srv_runtime~get_expanded_entity.

Also there would be a small change in Code , Like Below

 

*-------------------------------------------------------------------------*

*             Deep Structure

*-------------------------------------------------------------------------*

   DATABEGIN OF ls_order_items.

   INCLUDE       TYPE zcl_zproj_982_mpc=>ts_header.

   DATA: navitem       TYPE STANDARD TABLE OF zcl_zproj_982_mpc=>ts_item WITH DEFAULT KEY.

   DATA: navschedule   TYPE STANDARD TABLE OF zcl_zproj_982_mpc=>ts_schedule WITH DEFAULT KEY,

        END OF ls_order_items,

        ls_item1       TYPE zcl_zproj_982_mpc=>ts_item,

        ls_schedle1    TYPE zcl_zproj_982_mpc=>ts_schedule.

 


       copy_data_to_ref(

         EXPORTING

           is_data = ls_order_items

         CHANGING

           cr_data = er_entity).


Hope this Blog now helps you to implement Expand Entity/Entityset


Waiting for your feed back and suggestions and more questions



Thanks

Sri





Uploading Files to SAP GW, Downloading Files from SAP GW - New Techniques

$
0
0

Introduction

Recently, I had time to revise my solution for uploading and downloading files using SAP gateway. I discovered some new techniques and improvements mainly here in SCN, I would like to share with you solution based on these findings. So thanks for all contributions and I hope I mentioned them all here in this blog post.

Most credits go to Jan Thomas Nygaard for his blog post How To Upload and Download Files Using SAP NW Gateway SP06 which became my most used bookmark in browser.

 

New techniques

These are the techniques I would like to share:

  • code based implementation
  • using two entities, separation of media and non-media data
  • sending key parameters to media entity through navigation property
  • storing XSTRING in SAP
  • supplying file name in response for browser

 

 

Steps to get it done

1. Code based implementation

Based on How to Develop a Gateway Service using Code based Implementation, I wrote blog post how to create project called ZSA_USERS and how to prepare entity User which can be accessed via oData service and can handle operations CREATE, GET, PUT, DELETE also with code snippets. So this is a prerequisite before we continue with creating media entity.

 

2. Two entity - creating media entity

In order to avoid sending too many parameters (via header parameters or slug header) into Media entity during file upload, let's divide entities. As in the example non-media entity stores all data about user, while media entity stores all relevant file data. This approach is based on suggestion by Ron in following discussion How to pass arguements to CREATE_STREAM?

 

Entity User is backed by db table zsa_users.

entity_users.JPG

table_users.jpg

Now same way as we created entity user, we are going to create entity UserPhoto. UserPhoto is backed by db table zsa_photos. Do not forget to set UserPhoto as media collection.

entities.JPG

entity_photos.JPG

table_photos.JPG

 

Also do not forget to (re)generate runtime objects, rather more time than never.

 

3. Creating association between entities

The reason behind this approach is that it is not possible to access to the key parameters when uploading file in CREATE_STREAM method. Thus, there are a workaround using slug HTTP header or custom HTTP headers to supply the key parameters. My former solution was implemented this way, but I reworked it as following. Again, this suggestion came from discussion Re: How to send additional parameters with file upload by Matt. Now you can see why it is good to follow discussion

 

Now let's create Associations between User and UserPhoto, cardinatily needs to be 1...N. (1...1 did not work for me, thanks to Krishna for helping me figure that out). I used email as a key in both cases so lets connect them by this key.

assocations.JPG

constraints.JPG

Now, there should be a navigation property in User entity called Photo:

datamodel.JPG

This enables us to post file to UserPhoto entity via User entity where we can supply key parameters! It means that after call like this /sap/opu/odata/SAP/ZSA_USERS_SRV/UserSet('john(at)doe.com')/Photo, it_key_tabs will be filled with key email and its value john(at)doe.com.

 

Again regenerate runtime objects.

 

4. Redefine USERS_MPC_EXT->define method

This is important step unless you want to get error message "Invalid or no mapping to system data types found" from Gateway. You need to specify mimetype property of your media set. See document with code snippets with implementation. Code snippets for Uploading Files to SAP GW, Downloading Files from SAP GW - New Techniques

 

5. Redefine CREATE_STREAM and GET_STREAM methods in USERS_DPC_EXT class

You can find those under inherited methods from interface /IWBEP/IF_MGW_APPL_SRV_RUNTIME. Again, check document with code snippets for  implementation. Code snippets for Uploading Files to SAP GW, Downloading Files from SAP GW - New Techniques

 

I just want to explain some pieces:

  • In order to store XSTRING in SAP, I used DB. According to SAP help, it is possible to store it as rawstring. It is not physically stored in DB, only the reference is. There are several limitations for rawstring and I am not sure how much is the performance affected. Other solution is written in my personal blog post using FM 'SO_DOCUMENT_INSERT_API1', there should be also maybe nicer way how to do it with GOS.
  • supplying file name in response for browser in described in my other blog post Recognizing file name and type in browser after downloading file from Netweaver Gateway. If we don't supply Content-Disposition HTTP response header, browser may see our file with name '$value' which is definitely not wanted.

 

6. Post your file to GW and download it back

Now we should be able to test the solution in SAP Gateway client using these URIs. In order to set file name of the photo, we need to add it as http header slug parameter, since it is expected in my CREATE_STREAM implementation.

POST method: your_service/UserSet('usermail')/Photo

gw1.JPG

 

GET method: your_service/UserPhotoSet('usermail')/$value

gw2.JPG

Remarks

Once again, thanks go to all contributors mentioned in this blog and also those whom I forgot. Please feel free to comment anything that you find wrong, missing or can be improved. I am looking forward to your feedback, as usual

 

There is no error handling in the code snippets, take this as a starting point for your implementation.

 

And keep tuned, I am going to show you how to use this service in UI5

 


Tips for Creating a Google Apps Script/SAP Gateway Mashup

$
0
0

Having spent the last few month with my head way inside the process to integrate Google docs with an SAP backend through NetWeaver Gateway, I humbly offer a few tips to the blogosphere for anyone wanting to do the same thing. 



SAP Gateway: Use JSON Whenever Possible

This little phrase is your best friend for almost any interaction with SAP Gateway: $format=json.  This will instruct Gateway to send the result of the URI to your application in json format, making it lighter-weight and easily supported by Apps Script. 


But!  You have to know which services will support a json format.  If you decide that your app needs to understand the $metadata endpoint of a particular service, you can't perform a $format=json: there are SAP annotations that require XML to see.  So your Apps Script code may have to deal with parsing both json and XML.  


Luckily, Apps Script has utilities that can handle either case.  To work with json, become familiar with JSON.parse() and JSON.stringify(), highlighted in the Apps Script documentation.  The same with XML - go through the tutorial on using the XML parsing utilities.  If you're smart with how you handle XML, it doesn't have to be too much more complicated than json. 



Google Apps Script: User Interface

If you decide to present a user interface on top of a Google document in your application, you have a couple options.  If the interaction paradigm calls for a user to make a set of decisions before they can interact with the actual editor, it is probably wise to use the UI Service.  If the interaction calls for the user to have some control over continuing use of the editor, think of using the sidebar HTML paradigm


The way I think about it is this: if your user interface has an interaction that is essentially saying "do something about this before you can do anything else", then choose the UI Service.  If your interaction is saying "here are some things you can do with what you're already doing", consider the HTML service.


Whichever paradigm you use, you should consider what you'll need to know.  Both the UI Service and the HTML Service depend on some knowledge of web applications; the UI service is structured and formalized with a well-documented API, while the HTML service is very flexible in what you can present and can include outside scripting libraries.  Both provide ways of handling client as well as server-side actions. 

 

And if you're using the HTML service, get to know jQuery.  I mean it.  Just go learn it already.


 

Google Apps Script: Be Thoughtful Using Services

There are a host of options for using Google APIs for common tasks: parsing XML, storing key-value pairs in your documents, calling external web APIs, and manyothers.  They make your life easier.  Know them.


But you should also know that in some cases, using them too frequently can cause issues in your add-on.  I stumbled across that myself when I started receiving an error: "Uncaught ScriptError: Service invoked too many times in a short time: properties rateMax. Try Utilities.sleep(1000) between calls." It took me longer than I'd like to admit to figure out that I was calling the PropertiesService too frequently. 


I wasn't able to find an official document telling me a rate limit for calling Google APIs from within an Apps Script project, so I just went through and really optimized how I was using the PropertiesService. The biggest thing I did was to put my settings into an ordered JSON object, stringify it, and store the entire object as one property. That way, when I would need several things from the properties service I would only have to read it once and then parse out the JSON into the pieces I needed. 


Here's an example of what I mean. I put a number of properties on a single javascript object, and store that single object as a property of the document in my application.

 

function exampleStoreSettings(){   //Store user settings at some point in your application   //First, a generic object   var userSettings = {};      //A couple of settings. Can really be anything you want, JSON is flexible   userSettings.userName = 'Bob';   userSettings.emailAddress = 'Bob@notreal.com';    userSettings.currentAction = 'READ';   userSettings.allowedActions = 'READ,UPDATE';      //Store the object to the properties service   PropertiesService    .getDocumentProperties()    .setProperty('USER_SETTINGS', JSON.stringify(userSettings)); 
}   
function exampleReadSettings(){   //Read those user settings at a different point in your application      //Pull the JSON from the properties service   var userSettings = JSON.parse(PropertiesService                   .getDocumentProperties()                   .getProperty('USER_SETTINGS')                  );      //Do whatever you want with the individual settings   var userName = userSettings.userName;   var emailAddress = userSettings.emailAddress;   var currentAction = userSettings.currentAction;   var allowedActions = userSettings.allowedActions; 
} 

 

That's all for now.  Hit me up in the comments or private messages for any questions!

Extending a service using the Gateway Service Builder

$
0
0

In this blog, I will introduce the service extensibility concept that was developed as part of the SP09 development for the SAP NetWeaver Gateway Service Builder.


Motivation: The motivation behind the service extensibility concept was to have a single service URL for both the original service and the new service (which is generated by redefining the original service). This will enable users to redefine a particular service as per the requirements but still access the new redefined service using the URL of the original service.

 

Prerequisites:

IW_BEP 200 SP09


Step-by-Step Procedure

Following are the step by step procedures to extend a particular service. I will redefine an original service into a new redefined one and then showcase the service extensibility functionality.

 

Creation of a “Service with SAP Annotations” or “Service with Vocabulary-Based Annotations” service


Create a new service by redefining the original service


Extend the service while generating the runtime artifacts


Check the service URLs


Creation of a “Service with SAP Annotations” or “Service with Vocabulary-Based Annotations” service

  1. Go to the transaction SEGW and create a new project by clicking on 1.png
  2. Enter the details for the Project, Description, and Generation Strategy. Select project type as “Service with SAP Annotations” or “Service with Vocabulary-Based Annotations” from the drop-down. I have mentioned the project name as “z_srvext_parent” for better comprehension.

     2.png

 

     3. Create few entities for this project by right clicking on “Data Model” and selecting “Create Entity”. Or you could also right-click on the “Data Model” and                select the “Import” mechanism to import a data source. I will import a RFC in this example.

        3.png

     4. I now have the service as follows. Let’s call this the “parent” service.

     4.png

     5. Generate the Runtime artifacts by clicking on 5.png. In the following dialog Click Continue.

     6.png

     The runtime artifacts for this “parent” service will be generated.

 

Create a new service by redefining the original service

  1. Let’s now create a new “Service with SAP Annotations project” and redefine it from the “parent” service. Navigate to the SEGW transaction and create a new service as follows.

     7.png

     Let’s call this the “child” service.

2. Right Click on the Data Model and select Redefine -> OData Service (GW).

8.png

3. In the following wizard, enter the values for the “parent” service and click “Next”.

9.png

4. Select the entity of the “parent” service in the next wizard as follows and click on “Finish”.

10.png

5. Add another entity to this service by right-clicking on Data Model and selecting Create -> Entity Type.

11.png

Add a property for this entity. (I have tried to keep the entities and properties to be as simple as possibleJ). The “child” project now has two entities as shown below.

12.png

 

6. The “child” project now looks like as follows:

13.png

The “parent” service appears under the Model References folder.

 

Extend the service while generating the runtime artifacts

1. Generate the runtime artifacts for this “child” service by clicking on 5.png. The following dialog opens up.

14.png

The Overwrite Base/Extended Service under “Service Extension” is by-default unchecked. Once checked, we get the warning “Base service will be inaccessible” and the Technical Service Name and the Service Version fields get filled with the values of the “parent” service that was entered in step 3.

 

(If the checkbox Overwrite Base/Extended Service is checked, the service extensibility concept comes into play. The service URL of the “parent” service (Z_SERVICEEXT_PARENT) will now be re-directed (i.e. fetch the service details) to the “child” service (Z_SERVICEEXT_CHILD).

 

2. We will now register this service in the SAP NetWeaver Gateway Hub system. Click on Service Maintenance and select the Hub system and click on Register.

15.png

   Click Ok and enter the system alias in the next dialog. Enter the package in the subsequent dialog and click Ok.

   16.png

3. Register the “parent” service as well by following the same steps as above. Now since we have both the “parent” as well as the “child” services registered, we       can check the service URLs.

 

 

Check the service URLs

  1. Navigate to the “parent” service -> Service Maintenance, select the Hub system and click on Gateway Client to check the service details.

   17.png

   2. In the Gateway Client window, enter the details as mentioned in the picture below and execute to see the service details.

   18.png

 

Now, in the metadata of the “parent” service, we can see the two entities associated with the “child” service. This happens because the service URL of the “parent” service gets redirected to the “child” service as the “child” service has extended the “parent” service.

 

Both the “parent” and the “child” service can be accessed using the URL of the “parent” service.

 

Hope this post helped you get a perspective on the service extensibility concept in service builder

Viewing all 245 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>