Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
craigcmehil
Community Manager
Community Manager
0 Kudos
I presented at the Walldorf SDN Meets Labs, what I presented was nothing new. In fact most web developers have been doing for years with multiple other languages. Myself coming from this background found the ability to due this in ABAP and BSP quite lacking. What I didn't realize was that it was not lacking, only my understanding was lacking.

Thus the quest began.

Over the last year and half on SDN there has been quite a bit of work done on this topic but not nearly enough to point out the simple fact "It's a lot easier than it looks".

Now with those items in mind let's take a look at the main code segment you will need to accomplish the task at hand. That task of course being the ability to integrate external content into your system in what appears to the user as a seamless manner. The idea is that the user has no idea the server has just gone out to another website and retrieved a piece of data.

HTTP Client


This one simple bit of code is your key to unlocking any external content retrievalable by a URL.

That's it, you need that and nothing more.

Now that we have that, let's take a look at a single example from the presentation I used, the rest will of course be available for download here on SDN, a link will follow containing the content of the presentation as well as hopefully a link to a video of the presentation.

Exchange Rates

Now personllay the value of the dollar to the Euro is a huge thing for me as I get paid in the US but I live in Germany. I loose quite a bit right now when I transfer money over.



Therefore let's grab the exchange rate for the Euro. To do this here we will build just a simple little ABAP program. Again the presentation will show other possibilites. But again I want to show one main point, "It's a lot easier than it looks".




So as you can see quite easy. Now let's take this apart, there are a few pieces you have to have in place for this to work:
  • The HTTP Client Code
  • The ability for your server to access to the internet
  • The target, perferably and what I love are the websites like www.x-rates.com who have a "developers" link
  • Starting point of your text
  • Ending point of your text
Once you have those pieces in place then you are ready to go. For this example we needed our first starting point follwed by an end point and then our final end point and those 3 points are what we use to manipulate our string.



Now once you have those starting points we use some simple but powerful ABAP string commands to get rid of the rest of what we don't want.

> * Get your data
  data: tmp TYPE STRING,
    p TYPE STRING.

* Find start point
  tmp = content.
  p = cur.
  FIND p IN tmp MATCH OFFSET off.

* New content
  content = tmp+off.

* Find end point
  tmp = content.
  p = '<'.
  FIND p IN tmp MATCH OFFSET off.

* New content
  off = off + 1.
  content = tmp+off.

* Find final end point
  tmp = content.
  p = ''.
  FIND p IN tmp MATCH OFFSET off.

* New content
  content = tmp+0(off).



There you have it, nice short and easy. For more in depth info please refer to the uploaded content as well as the video presentation.


20 Comments