Saturday, December 22, 2007

Merry Christmas everyone

Everyone at would like to wish our readers a merry christmas and a happy new year.

In the new year we will look at exiting new topics such as information management and access and availability as we try to look at the host of information enterprises hold and how to make it available to the knowledge workers. This will be exiting.

Best wishes from the team.

Friday, November 9, 2007

Dynamic images in Web Dynpro for Java

It’s a common problem displaying dynamic images in Web Dynpro 4 Java. The image widget takes only an URL as source argument, and not an byte array as you might expect.

There is two solutions to that problem, one is to store the images on the web serves file system an generate an URL based on the filename and location. This solution involves setting up a HTTP Alias in the WAS and manually maintaining the image cache in the file system of the WAS. How to set up the alias and make it work is documented in detail in the blog of Renjith Andrews called Creating an HTTP Alias in WAS. As the seems to be the common approach, I cannot recommend it since the overhead of maintaining the image cache will be to much to handle.

In stead I will suggest another approach where you do not need the local file system nor do you need to maintain the image cache. My recommendation is utilizing the IWDResourse.

The following little piece of code will show you how to translate a byte array of an gif image to an URL:

// get the image data from somewhere
byte[] data = new byte[1024];

// Create a cached web resource using the WDResourceFactory
IWDResource res = WDResourceFactory.createCachedResource
(data, "image.gif", WDWebResourceType.GIF_IMAGE);

String url = res.getUrl(0); // 0 means "AUTO"

For a JPEG image the process is the same but use WDWebResourceType.JPG_IMAGE as the last argument of the the call to the factory.

It is as simple as that. Since it is a cached web resource, you can add it to your context for storage while the application is running so you won’t have to waste CPU cycles to create the same IWDResource over and over again. Ad by adding it to the context it will get automatically cleaned up when the application session ends.

Working with SDM with limited rights

As a portal developer, it is usually the standard, that you have unlimited rights to the development server you are working on.

But what happens when this isn’t the case? Well - SAP has provided a client tool for connecting client side to the SDM, without having OS access to the server you are working on.

Thus they eliminated the need for hacking the installation out from the server You are working with.

The old way of doing this, would be to extract - and package the SDMinstallation yourself, but when working with a client where you cannot access the server’s filesystem, the new method is preferred.

To install the SDM locally, go to - and browse the following tree:

SAP Support Portal -> Downloads -> Support Packages and Patches -> Entry by Application Group -> SAP NetWeaver -> SAP NETWEAVER -> SAP NETWEAVER 7.0 (2004S) -> Entry by Component -> Developer Workplace -> SAP SOFTW. DELIV. MANAGER 7.00 -> #OS Independent

Find the support stack level you need, and you will get the client installation (add it to your download basket, and download it with SAPDownload manager).

The installation is a .jar file, which is kinda strange - because of what you need to do next.

Unpack the archive to a temporary folder, for example c:\temp.

Open up the folder, and launch the file “Install.bat”.

Accept all default values (press ENTER 7 or 8 times), and the installation script will start.

After it’s done, the sdm can now be launched from c:\sdm_home\remotegui.bat

And that’s it :-)

Wednesday, October 31, 2007

Please use translation in your Web Dynpro for Java projects

As seen more and more, developers fail to use text the proper way when developing Web Dynpro for Java (WD4J) projects. I’ve written this post to clarify where it’s OK to use literals and where it’s not, as it’s rather confusing for the new WD4J developer (and sometimes for the experienced as well). First things first. When creating Web Dynpro projects in NetWeaver Developer Studio (NWDS), you should always use a development component (DC). The reason for that I’ll describe in another post, however there is good reason for it. On the creation screen you are asked to specify which language you’ll be writing the application in. Please mind that you set this property correct as it dictates the language setup.
If you fail to set this setting correctly, chances are that your translation settings will not work properly.

When you have completed creating you project you can use the Message Pool located in within Web Dynpro component in the Web Dynpro Explorer. The Message Pool is a component wide pool of messages to use in your component, these texts will be translatable via the Web Dynpro Console, but more about that later.

To use the Message Pool, simply double click it and the editor will appear. The message editor gives access to the texts in the pool and of course to create new ones.

If you look at the message text you’ll see it ending with {0}, this is a placeholder, you can use the same placeholder several times and you can have several placeholders numbered from zero and up. You’ll provide the data for these placeholders as an java.lang.Object array, therefore the numbering. Translating the texts
So when is it OK to use literals in your translation?
I have only one answer: When you type in texts in the property pane.
When you type in texts in the property pane, these will be extracted and put into an XLF file. You can See the XLF files if you open the navigator view and expand src -> packages and whatever you source package is called.

As you can see there are two xlf files, one for the message pool and one for the start view.
To translate the texts in the xlf file, you start with simply copying the file to the same location and editing the name of the file so the ISO 639 language code is post-fixed the file name together with an underscore. If the file is called LanguageTestStartView.wdView.xlf for the default locale, then the xlf file for Danish would be LanguageTestStartView.wdView_da.xlf. Search for “Internationalization of Web Dynpro Projects” in the NWDS documentation for further details.
Using the texts pragmatically
So now you got texts, and you got them in several languages. Now it’s time to use them.
First we’ll need a minimal setup:
I’ve created a Web Dynpro development component. Created a application called LanuguageTestApp with a default view called LanguageTestStartView.
In the LanguageTestStartView i have declared a context attribute called searchText. I’ve also created a input field called SearchTextInputField which has it’s text property bound to the context attribute. Lastly I’ve created a button called searchButton with the label text set to “Search”. This is to emulate a search iView of the portal ment for the detailed navigation section.
I’ve also created an action for the button called onActionSearchClicked.

When you create a Web Dynpro component, the NWDS also create a interface called IMessage which has a public static final IWDMessage for each and every entry in your message pool. This makes it easier to fetch the messages when you need them. For this mini application we only need two messages. Open your message editor by double clicking the Message Pool icon in your Web Dynpro component in the Web Dynpro Explorer and fill in the following:

As you can see, there is a placeholder for something in the top text. What we want to insert here is of course the search text that the user has entered prior to performing the search. Insert the following code in the onActionSearchClicked:

//@@begin onActionSearchClicked(ServerEvent)

String searchText = wdContext.currentContextElement().getSearchText();
IWDMessageManager messageManager = wdComponentAPI.getMessageManager();

if ("".equals(searchText)) {
* if we get to this, the user hassen't entered any text before clicking
* the Search button. This is an error, lets tell him:


* As we have no search, we'll just tell the user that we found nothing.

new Object[] { searchText }, // this will populate the {0} placeholder


In the if section we’ll raise a message if the searchText is empty and in the latter section we report a message telling the user that we found nothing. Notice the difference between the raising a message and reporting it. You should use raiseMessage for errors and warnings. When you’re raising errors then the third parameter specifies weather or not navigation should be canceled as a result of this error. This third option is only valid for errors and is ignored for all other message types.

Tuesday, September 11, 2007

Using SAP Gui for Java on Mac for development

A short article explaining some problems I ran into with the SAP Gui for Java for Mac. It turns out that the Gui for Java is useless when editing Web Dynpro ABAP applications. This is a mega bad sign considering I’m using a Mac platform.

To set the record straight, I have to say I had been warned a lot against choosing the Mac platform because of the lacking platform support from SAP. I my opinion, the Mac is a superior platform in every way, and since it can run a virtualised MS Windows installation simultaneously by the help from VMWare, I decided that lacking support from SAP was not going to prevent me from using the best platform ever.

My need for SAP Gui is modest so to say. I primarily do Web Dynpro Java development and hence does not need to use the SAP Gui for much other than fetching RFC and BAPI specs and of course the occasional test drive of the two. Transactions SE37 and BAPI work terrific in SAP Gui for Java. In fact I’ll rather use the Java version as it seems a little faster than the WinGUI.

One exception is when I’m developing Web Dynpro ABAP (WD4A). The I of course use the gui a bit more intensive. I have recently discovered that there are some minor glitches in the Java gui regarding the WD4A extension to SE80. These glitches is mostly regarding context menus and the initial layout of property inspectors and tables. This of course can related to the fact I’ve set Safari as the default browser and Safari isn’t supported by the Web Dynpro framework.

Installing SAP Gui for Java on Mac

Seriously, installing the SAP Gui for Java is a breeze. I went to the SWDC and downloaded a installer packed as a jar file. Once downloaded I ran the installer and it created a Mac-ified application which integrates with the Mac OS X just perfectly.

And then the problems started to kick in, not that there is anything wrong with the software, it just appears that I don’t know how to configure it. Things work a little different than in the WinGui. Here is hvat you need to do:

After installing Gui for Java, run it and click the New button. It should look something like this:

Click the advanced tab and check the check-box saying user expert…. and write a connection string in the textarea like what I’ve done below. Remember to substitute what is between the <> with something from reality.After this I was able to connect just perfectly.

When running the Java version of Gui, you won’t be able to use the new ABAP code editor with code-completion and syntax highlighting. I don’t see this as a loss as the ABAP code completion doesn’t really complete anything for me, and the syntax highlighting almost none existent when compared to Eclipse in which i used to work. I recognise the fact that a lot of ABAP’ers love and cherish the new features, so if you’re a highlighting completion lover, stay clear of Java GUI

The bapi transaction

As stated earlier, the BAPI transaction works beautifully. I only use it to read documentation and as a shortcut helper to the function builder where I can perform tests. This is also the intended usage I guess.

The function builder

The function builder also work OK. Btw I never use the function builder for anything else than testing RFCs and BAPIs. When I write RFCs, which I don’t do very often, I use the function builder under se80 (yeah it’s the same, i know).

Web Dynpro builder

This describes the most common problem with Gui for Java. All properties sections are totally collapsed by default and their state gets reset every time the window is re-painted. Very annoying.

If you were to right click the context node in the views context, you might expect to se a context menu giving you the relevant context manipulation choices. However this is not the case as nothing shows up! This is a complete show stopper as there is no other way to get to these functions.


There is still a way to go for SAP before they have a working client on other platforms than Windows, or at least one that can be used for development. Perhaps SAP should make a native client for Mac as well.

RIA forum on SDN

SDN has finally got a forum for RIAs (Rich Internet Applications). Even though the forum haven’t been around for too long, there’s still some activity in there. The forum is mainly targeted towards Flex applications, however since RIA is covering “web based applications with a rich desktop like experience” then we should also see some chat about DHTML / AJAX based applications as well.I’m looking forward to participate in some great discussions regarding the Flex part of RIA as it’s one of my biggest areas of interest.At the time of writing the forum have already covered
  • Accessing SAP Web Service using flex
  • SSO in flex
  • Crossdomain.xml placement