Monthly Archives: July 2013

Screen+Shot+2013-05-10+at+8.25.14+AM

Simple Sample: Writing an entry to SAP Netweaver Gateway using JSON

Skill Level: Beginner
Time Needed: 20 minutes

I recently assisted someone on the forums when they were having trouble creating records in their SAP ECC instance while using Gateway. I thought I would share some very simple code showing what it takes to write an entry into a service via JSON from iOS (Objective C). The reason the title of the document is “Simple Sample” – there are no frills. Whenever I develop a new app, I start small, get the basic functionality working, and proof out the process before getting too creative.

*** If you do not have your own gateway server, you might be able to connect this to the SAP Gateway System which can be found here. Create an account and utilize this service *** DISCLAIMER: Untested as the signup form does not work

The small application sample below uses this document as a starting point. It describes setting up CRUD (Create, Read, Update and Delete) operations for the Bank account list in your back-end, based on the Bank BAPI. For our example, we will be using the Read and Create functionality of the service. Our example will use a open source repository called AFNetworking. The download can be found here, is ARC compatible and is very easy to add and reference in your project. I will skip the basics of creating a iOS project and adding the reference to AFNetworking (but for reference I am using a “Single View” app template in XCode).

Read Operation from your iOS App

Reading from a OData service using JSON can be done in as little as 7 lines of code in objective C (When using the AFNetworking classes). Here is my example code which can be used to read from your service. In my case, I am returning a list of Banks. Below is the code and the output.

Screen Shot 2013-05-10 at 8.20.25 AM.png Screen Shot 2013-05-10 at 8.23.55 AM.png

Create Operation from your iOS App

Creating a new record adds a small requirement, in that a CSRF (Cross Site Request Forgery) Token needs to be added to the POST request header. If you notice above, I have added this “fetch” header to my GET request, thus returning the key we need along with our data. (2 birds, 1 stone). Here is the create request. Pending it is successful, it will return the record which have been added to your back-end system. Below is the code and output.

Screen Shot 2013-05-10 at 8.19.28 AM.png Screen Shot 2013-05-10 at 8.25.14 AM.png

Here is a link to the GitHub project to avoid you writing all of this out. Once again – download and follow this useful guide from Gateway team to create the Bank service in your Gateway system, download the project from GitHub, update your gateway server name and details and this will be a useful starting point for creating your next enterprise app.

Disclaimer: Keep in mind the code purposely simplifies the code needed. If you feeling more adventurous:

  1. Ensure your gateway server is using HTTPS.
  2. Instead of using a NSString *dataset, use NSDictionary object/Class to the Request using JSONRepresentation
  3. Add your username and password to the header request, Base64 encoding them.
  4. Instead of writing the JSON response out to a UITextView, add some UITextBoxes and parse the values out.

Can anyone spot the field I forgot to post?


icon_256x256

SAP Notes Viewer for Mac

Since I have been spending the last few weeks getting some Netweaver instances running on my new Hyper V server, I have spent a considerable amount of time on the SAP Notes website debugging and troubleshooting everything from installation to master guides. Since my SAP Note Viewer apps for iPhone and iPad are fairly popular and I was tired of having to login so many times, I figured I would develop a “clone” for the Mac.

The free app features a pretty basic status bar menu and when you open it for the first time, requests your s-id and password and your search language (German and English). Once opened, you can enter a Note number or search term, submitting will automatically bring up the note in your browser. If you enter a search term, the app will search and return a list of results which you can select, opening the note. The search is fairly slow, as it is, in essence, making two round trips (one for the page and the second for the results).

I have also submitted the app to Mac App Store and it is currently in review, but if you would like to get your hands on it and give me your thoughts, it would be greatly appreciated. Here is a link to a download page: http://www.li-labs.com/SNVMac.zip (450Kb), just unzip and drag into your “Applications” folder. You can also download the Mac Store here: https://itunes.apple.com/us/app/sap-note-viewer/id575046244?mt=12

Here are a couple screenshots.

icon_256x256.png Screen Shot 2012-09-27 at 10.16.45 PM.pngScreen Shot 2012-09-27 at 10.19.01 PM.png

pastedImage_4

Quick View for SAP Notes (Windows)

In my ever growing quest to provide quick and easy access to SAP Notes (which Dagfinn Parnas started a couple of years ago with the Android Note Viewer), I recently finished creating a windows version of a small app to make opening notes just a little easier.

When deciding if I should get this done, it was purely out of personal need. Having spent the last few months building up a couple of Gateway test, stage and Prod systems, the ability to open a SAP note quickly, always seemed to elude me. Open service.sap.com/support -> click on Help & Support -> Type the note and go. Albeit the app developed still has some user interaction (until Google Glass arrives?) … it does make it a little simpler. I also found a small cmd script online which looked helpful.

Currently, the SAP Note Viewer for iOS apps, and even the mac version (+- 1,000 downloads since, seem to be fairly widely used and popular, so it seems a natural progression that a windows version may be helpful to some people. This version is considerably simpler than the others which include searching, favorites, and centered more around note references, whereas this app is purely just a “quick launch” tool straight to the note itself.

A couple of the apps features:

  • Specify your username and password at startup and the url will include this to authenticate a little easier (you may still get prompted, as I do in Firefox)
  • Open the notes as PDF’s
  • Saves you last 5 recent notes making it easier to reopen one.
  • That’s about it

The source code to the app will be uploaded to Code Exchange and you can freely modify/distribute and share as you will.

Some ideas for the app:

  • Add the ability to search directly in the app (OSX version)
  • Save the note title to the recent menu item for easier visual reference

This is the “Beta” version – so please feel free to provide some feedback in the comments. As mentioned previously – I developed this to use as a personal tool but I think of could people may find it helpful

If you have an easier way, or have a tool to open your SAP Notes, please feel free to share it with us in the comments.

Install Instructions

Download the zip file here, unzip and execute. You will be prompted to specify your password each time the app loads to avoid any sensitive data being saved. A username and password is not required.

Important Notes

Internet Explorer 6.0+ will not allow you to specify the username and password in the URL which the app uses. if you are using IE, please leave S User and Password blank. (Reference: http://support.microsoft.com/kb/834489)



icon_128x128

xSync – Making HANA XS development easier

A couple of weeks ago, I started playing with HANA development after going through a couple of the opensap courses. One of my biggest surprises was that HANA Studio was windows only. As a Web/Mobile/App developer spending majority of my time on the Mac platform, having to get my Dell out was a walk down memory lane, and caused me to not spend as much time working on the projects as I would have liked. Since Rev 52 of HANA included a XS Engine Lite IDE, a useful web based IDE for your XSJS/SAPUI5 development. I was been looking forward to getting it installed on my AWS machine and giving it a test drive. Last weekend Juergen Schmerder posted a updated really easy to follow and simple guide of going through the process and within a hour, I was up and running on the newest available rev.

First off, the web IDE was great. Secondly, not having to use my old Dell was bliss. From a development perspective I am OK with the fact I need to do schema modeling/view generation input etc. through the Studio IDE, its well built for this and has functions and customizations which are not as necessarily as generic as web/java/jquery development. I spent the weekend working on a small POC/rewrite I have been working on and enjoyed the development experience. But after a while, found myself wondering about code completion, syntax highlighting, text formatting and a few more features which are generally available in your favorite IDE.

After some digging, I came up with the concept of being able to develop locally and yet still be able to execute the code online through my browser as if I was using either the Lite IDE or the Studio. I am not sure if #openSAP intend for students to hack HANA, but that’s exactly what happened …

icon_128x128.png

Enter xSync … xSync is a *little* like dropbox for your HANA repository. Its a Mac app which runs in the Status Bar and watches file system changes to a designated development folder. As soon as you save, it saves your file in XS Engine to your package repository. Development is no longer is choir of saving, syncing and activating Even if you are not a developer, it has some useful features, it shows if your HANA instance is online – avoiding unnecessary costs, and also allows you to easily download all files from a HANA package or development project. This is great for creating local backup/snapshots regularly. Below is a quick video of the app in action.

If you are interested in testing the app out, please download a copy here – all feedback and constructive criticism is welcome as usual. Please keep in mind, this is still *very* beta. I have done my best to test, but from conception to app in a couple spare hours is always a challenge = DISCLAIMER, use at own risk!

Some technical notes and features:

- Features:
- Use your favorite IDE to edit files locally
- Save, Create, Delete, Rename files locally and have them *sync* with your XS Engine package
- Quick way to ensure your Instance is available (watch costs on your cloud hosted system!)
- Download all package contents to your local HDD
- Easily upload files/folders to your packages

- Requirements:
- HANA Rev. 52

- Usage:

1.) Download the app here

2.) Enter your HANA XS Engine URL, package (I suggest creating a test package to test the app out with)

3.) Enter the folder location of your local development objects (I suggest a blank folder to start as it will not upload existing objects already in the folder)

3.) Enter HANA username/password

4.) The log will show that the folder is being watched

4.) copy/create a new file in the folder and check the log to ensure the file was synced

5.) develop something awesome …

- Bugs/Issues:
- Renaming/creating folders could be a little better, since XS engine does not require spaces, it can be problematic

- Future Ideas:
- Sync existing files
- Maintain a local “folder” structure db for reference
- Sync from XS Engine if changes made there
- Insert your idea here
- Less ‘buggy’ for release 1

For all the HANA hackers out there … how do *you* think the app is integrated with HANA XS Engine? Any guesses? I will follow up this blog in a couple of days with the technical details and how the app works.

Screen Shot 2013-06-15 at 8.43.30 AM.png

Image2

A peek inside xSync and the HANA XS Engine

icon_128x128.png

On saturday I published a blog about a small app I wrote called xSync – basically a XS Engine app for Mac developers where you can sync a local development folder with your HANA repository. This is for rapid development and to encourage the “bring your own IDE” approach to application development on HANA. Here is a look behind the scenes on how the app works and some of the challenges of the project.

Image.png

As mentioned in my previous blog – I started using the IDE Lightweight editor after doing the upgrade of my AWS HANA box last weekend. I enjoyed the experience but after working with it for nearly a full day was wanting a little more. Syntax highlighting, easy commenting, easy indentation, CSS autocomplete and hints, etc. etc. so I started doing some peaking around the editor itself and came to find the editor is something called ACE, a pretty nice little open source IDE (written in JS). This got me thinking … maybe I could insert text directly into the Lightweight IDE browser text box, and submit the form as a save …. hmmm …. not a terrible idea …. just need to scrape the page, find the elements and submit the form via some injected JS. Pretty simple …  I did some digging and found the HTML objects I needed by using Firebug when a lightbulb went off … instead of populating the form via a HTML page, why not rather check the HTTP methods it is calling when doing the actual save, since there must be some integration with HANA directly … which is when I came across the mother load … a small file called reposervice.xsjs It seemed that every time I was saving or modifying my objects through the IDE, it was calling this file. After checking out the parameters it was `, it was very clear that the methods and text were easy to simulate. I fired up REST Client and within a couple minutes the concept was POC’ed. Pass your file contents as your body with a path param and a POST and you were off to the races

Screen Shot 2013-06-09 at 4.39.png

Using Firefox Rest Client to monitor system calls showed each save, create, delete operation was using a small file called reposervice.xsjs, which references the libraries needed for the repository modifications.

Image2.png

The diagram above displays the HTTP call made when saving/creating a file, and how the IDE initially does a HEAD request for the XSRF token, followed by the HTTP PUT.

The initial HEAD request is to fetch the CSRF Token, secondly the token along with the parameter of mode, path and activate are passed to the URL. Pending you are successful, a JSON message is returned with the status. For those of you are not familiar with Cross-Site-Request-Forgery, you can read about it here: http://en.wikipedia.org/wiki/Cross-site_request_forgery

Once I had this done, I was wondering what the best integration option would be and weighed up a couple options of a simple check in type procedure, but wanted something faster, easier and “click free”. Being a bit of a highly iterative developer myself, I find it easier to develop “online”, which is why I decided it would be best to do a File System watch of a particular folder and save any changes automatically to my HANA instance. Similar to a dropbox type approach.

I had my POC working nicely, a integration goal defined and set out to start developing the UI/Application in Objective-C (Xcode). I had a template type of app from one of my little SAP Note Viewer applications which could act as a foundation. I threw some code out and pulled some very useful little open source packages in as helpers. Within a couple hours in my evenings each night the app was running nicely and doing what I had expected, modify a file or two in a predefined location and sync up to XS. easy.

Thats generally where development grinds to halt for me, as I envision feature after feature to build a Mac clone of HANA Studio Luckily my senses got the better of me, and I worked on doing a recursive package downloader, the ability to create, rename and delete files and folders and not a HANA Studio rewrite Once this was all done, ironing out the bugs was painful. The cocoa FSEvents stream (File System Events) Class on the mac is not easy to work with and a bear at best. Having to monitor a folder for any modifications, deletes and creates turned into a bit of a logic nightmare. One of the interesting challenges is that if you “delete” a file on the mac file system, it does not get a “delete” FS Event but rather a rename! (Since it goes to the trash/recycle bin!). This leads to having to do multiple … if exists then …. type statements around each file and folder event

UI is another interesting one, I like apps to look somewhat decent … and I spent a good amount of time working on each of the elements in Adobe Photoshop as usual … (Whenever I do a mobile app development talk I mention that I spend close to 40% of entire project time in apps like Photoshop with design work! Most are surprised!)

If you are interested in incorporating some these types of features into your own app, I will be posting a copy of the integration classes on GitHub shortly.

PLEASE KEEP IN MIND: This is exploratory type work with undocumented API’s, I would not recommend using this in production, or any important production work (or your important opensap homework!). The reason I shared this was to encourage people to look under the hood and understand the how’s and why’s of how some of these great new tools work.

I would be interested to hear if anyone has any interesting use-cases for being able to manipulate both HANA repository and DB artifacts from outside of the Studio? Does anyone have any challenges with the HANA Studio today they would like to see changed?


placeholder2

SAP Netweaver Gateway T-Code Summary

Here is a list of useful SAP Netweaver Gateway TCodes, please add a comment for any I am missing and I will gladly update. The intent of this post is to summarize the relevant TCodes for posterity and to be used as a quick lookup.

Gateway Runtime

Title

T Code

Description

SP Required

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) SP04 +
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.
Application Log /IWFND/APPS_LOG (Gateway Hub System) Log and Trace Filesa specific viewer for application log entries created by SAP NetWeaver Gateway processes.
Application Log /IWBEP/VIEW_LOG (Business Suite Backend) Log and Trace Filesa specific viewer for application log entries created by SAP NetWeaver Gateway processes.
Application Log Cleanup /IWFND/CLEANUP_APPSLOG Over time the application log amasses a lot of entries, which periodically need to be cleared. As default the application log should only store one entry per request. In addition, there is no need to store these entries for more than a day or a few days. Application log cleanup is a standard requirement in productive systems and helps to improve the performance of the systems in your system landscape.
Clear Cache /IWFND/CACHE_CLEANUP Cleanup Gateway Metadata Cache
Disable Cache /IWFND/MED_ACTIVATE Disable Gateway Metadata Cache
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.
Alert Monitoring RZ20 SAP NetWeaver Gateway is monitored automatically within the Computing Center Management System (CCMS) in SAP CCMS Monitors for Optional Components for Information Worker.In the monitoring process, information is collected about SAP NetWeaver Gateway. Here you can see which applications are in use, and how often they are called up. The information is updated hourly and relates to today’s date, since on the first collection after midnight all values are initialized once they have been read out.
Performance Trace /IWFND/TRACES The Support Utilities offering for SAP NetWeaver Gateway has been extended to include a Performance Trace tool. This tool enables developers, administrators, support consultants, and end users to monitor system performance at service call level. You can trace the performance of both the SAP Business Suite backend system and the SAP NetWeaver Gateway hub system.

Gateway Design

Title

T Code

Description

SP Required

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. SP04+
Model Composition for Integration /IWFND/BD_MGW_MDL_COMPOSITION Model composition is provided for complex scenarios for the integration topics, such as SAP Business Warehouse, GenIL and SPI. It allows mashing up multiple services within IW-BEP.
Service Validation /IWFND/SRV_VALIDATE SAP NetWeaver Gateway Service Validation Tool validates the runtime for all the SAP NetWeaver Gateway services to ensure that all the services work fine. Service Validation tool runs without user intervention and performs the runtime validation on a single service document.
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.
Create a Service SE80 Design time ABAP Workbench
Register a Service /IWFND/REG_SERVICE Replaced with SEGW
Maintain a Service /IWFND/MAINT_SERVICE Replaced with SEGW
Activate a Service /IWFND/IWF_ACTIVATE Activate or Deactivate a service
MOC /IWFND/MOC_PARALLEL Parallelize Multi-Origin Composition
WebGUI Workflow /IWFND/WF_WEBGUI WebGUI For Executing Workflow Item
Configure Message based Authentication /IWFND/WSS_SETUP Configure Web Service Message-Based Authentication
GenIL Generator /IWGIL/GENIL_SRV_GEN Gateway Service Generator for GenIL