Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
peter_langner
Active Contributor

1 Introduction


When I tidied up my desk I found this little ABAP finger exercise which I did some years ago, when I had to take care of more than one SAP Solution Manager within a support organisation. I was irritated by the fact, that I had to login to and check within each single system, if anything had happened for me.

So the idea came to my mind, that it would be good, to have a little tool which does this for me. It should process a status list of tickets and change requests my user is related to and publish this in the iGoogle portal, which I was using heavily by that time.

2 Publishing Content using RSS feed


The basic technique used there as well as in many other web 2.0 platforms is the RSS 2.0 web feet format. “RSS” is an abbreviation for “Really Simple Syndication”. It is used to frequently publish frequently updated works — such as blog entries, news headlines, audio, and video — in a standardized format. An RSS document (which is called a "feed", "web feed", or "channel") includes full or summarized text, plus metadata such as publishing dates and authorship.

RSS feeds benefit publishers by letting them syndicate content automatically. A standardized XML file format allows the information to be published once and viewed by many different programs. They benefit readers who want to subscribe to timely updates from favoured websites or to aggregate feeds from many sites into one place. (See [RSS11])

iGoogle is the RSS reader I intended to use. But there are many other possibilities such as RSS feed readers integrated in your browser or MS Outlook. Also desktop panels like Google Desktop allow you to integrate RSS feeds.

After knowing the standard format we need the question is, how we can generate and access this using the SAP Netweaver AS ABAP.

2.1 Accessing the SAP Netweaver AS ABAP via HTTP


To add information to iGoogle via RSS means that we have to be able to access the SAP Netweaver AS ABAP via HTTP protocol. To do so, we use the internet connection framework (ICF), which you can configure using transaction SICF. I have defined my own virtual host there called zadventasand a service called z_rss_feed. This service can be called from the internet respectively the intranet with something like this: http://server.example.com:8000/zadventas/z_rss_feed/. It will then return the RSS XML file as a result, which will be displayed by the reader.



Figure 1 – Configuration of the ICF

The configuration of the ICF you can see in Figure 1. The named handler ZCL_RSS_FLIGHTS is a class, which is called, when the above mentioned URL is called. The class is one leaf of the class hierarchy shown in Figure 2. [1]



Figure 2 - class hierarchy

2.2 Implementing the object model


First I implemented the class ZCL_RSS_FEED. It inherits from the standard interface IF_HTTP_EXTENSION. Its method HANDLE_REQUEST is called, when the URL is processed. Furthermore the class has two more methods. The method GET_PUBDATE, which gets a time and a date as input parameter and returns the publishing date in a format requested by the RSS feed. The second method FILL_RSSFEED is the method where the RSS feed is build. It is declared abstract and must be redefined by the classes, which inherit from ZCL_RSS_FEED to implement the feed for a proper application.

In my case this is the class ZCL_RSS_FLIGHTS, but it can by any other class like e.g. ZCL_RSS_TICKETS which might display the open tickets within an SAP Solution Manager, which my user is related to.

The entry method HANDLE_REQUEST does the following:

  1. Get the parameters of the HTTP request (in our example there none. But you could for example put a language key here).

  2. Fill the RSS feed data structure

  3. Transform it to XML

  4. Send the result to the RSS reader


To build the RSS feed means to fill the data structure and convert it to XML.

2.3 Fill the RSS data structure


Before I continue to explain the details of the implementation, I have to tell you, what a RSS feed is. Simply speaking it is a XML formatted plain text, which can easily be read by human as well as automated processes. Instead of giving you with a formal definition [2], I want to provide you with the example shown in Figure 3.


Figure 3 - Example RSS feed


Each RSS feed consists of one or more channels. Each channel has header information, which contains a title, a description, a link, language code and can have an image. The header is followed by the feed items. Each item has a title, a link, a description, an author, a publishing date and guid, which uniquely identifies the item.

To represent this structure in ABAP I defined a structure ZRSS_FEED. It has nine strings, which represent the header information of the feed. Furthermore it has a table, which represents the list of items of a feed. Each item is again represented as a structure of strings, which are related to the attributes of an item.

In Figure 4 you can see the details of the channel header data structure and in Figure 5 you can see the details of the item data structure.



Figure 4 - RSS feed header data structure



Figure 5 - RSS feed item data structure

2.4 Transform the data structure to XML


To transform the RSS feed data structure to XML I am using the powerful so called simple transformation mechanism. You can create or edit it using transaction STRANS, but it is also integrated in the development workbench [3]. It takes a XML template and fills it with the ABAP data. If you have already worked with BSPs you are already familiar with the template technique. As with BSP transformations are supported by a special language editor.



Figure 6 - The RSS feed structure as a simple transformation

In Figure 6 you can see the beginning of the RSS template I have defined. It is displayed in a special layout editor, which comes along with the development environment. You can see the native XML and between simple transformation tags, which allow you to integrate ABAP statement such as e.g. assignments or loops.

To use them you just call them like this:

CALL TRANSFORMATION zrss_to_xml
SOURCE rssfeed = rssfeed
RESULT XML l_xml.

The source rssfeed is our defined ABAP data structure and as a result we receive the XML file l_xml build by executing the transformation of the defined template.

2.4 Publishing the content to iGoogle


So finally we are ready to publish everything to the iGoogle portal. To do so is quite easy. First you go to you iGoogle start page und press “ADD GADGETS”. Then on the right hand side you click on “Add feed or gadget”. In the opening window you enter your URL and press “Add”.



Figure 7 - Add the RSS feed to IGoogle

After a while (depending on the speed of your server) you will see the flight list in your portal.



Figure 8 - RSS feed in portal

3. Conclusion


So what have we done? We saw how to access the SAP Netweaver AS ABAP via http protocol. We implemented a handle, which is executed, when a specific URL is called. We read flight data into a specific RSS data structure and transformed it into a XML data feed, by using simple transformations. The feed can be consumed e.g. by iGoogle portal or other RSS feed readers.

If you want to try out the example shown in this article, please go to github.com.

If you are interested in other ways of integrating google applications to SAP ABAP, please go also to the very nice project abap2gapps. If you are interested in using XML in your project I also recommend you the book XML for developers by Tobias Trapp [TR10]. As far as I know it is only available in German.

Literature


[RSS11]    http://en.wikipedia.org/wiki/Rss_feed, 3. Oct. 2011.

[KK07]       Horst Keller, Sascha Krüger, ABAP Objects – ABAP Programming in SAPNetWeaver, SAP Press 2007

[TR10]       Tobias Trapp, XML für ABAP-Entwickler, SAP Press 2010







[1] For further instructions on how to use this interface please refer e.g. to the online help http://help.sap.com/saphelp_nw73/helpdata/en/48/d402801904154ee10000000a421937/frameset.htm




[2] This is the example I choose to implement. There is other information you can pass on. Here http://feed2.w3.org/docs/rss2.html you fined the complete definition as wells as examples for a RSS feed.




8 Comments