Archive

Archive for July, 2009

My 4 hours

July 30th, 2009

I have been talking with Rasmus from http://my4hours.com/. He has the project of implementing Timothy Ferriss 4 hour work week. There is still some time to go but he has started the journey. I hope that I’ll be able to learn from him, and optimize my life.

I’m currently considering hiring someone from the Philippines to help with my work. I will have to see how it works.

 

Uncategorized

Using SFTP for windows in PI

July 29th, 2009

Last December I wrote about how to use SFTP SSH from a Unix server, without using a Seeburger Adapter. SAP PI/XI cannot be used to access SSH SFTP sites directly, but this script can help. There have been many requests for a version which also works on windows. I do not have access to a windows server with PI or XI so it is a little difficult to test for me.

I have now written the following script, which works on my Vista labtop. I have not tested it on Windows 2003 or Windows 2008, where most PI systems will run.

I have used Putty for creating the SSH connection. I have used the pscp (an SCP client, i.e. command-line secure file copy). To try something different then using SFTP. SCP makes it easier to get files which should exist in a directory. Pscp should be downloaded and saved in the same directory as the script.     

The script looks like the following.

@echo off
REM PARAMETERS
REM %1 target file  PI %F
REM %2 query for where the file is located ie. root@figaf.com:dir/*
REM %3 SSH Password

REM RESET the target file
echo '' >%1


SET TARGETDIR=%~d1%~p1download
echo %TARGETDIR%

IF EXIST %TARGETDIR% GOTO SKIPCREATEDIR
   mkdir  %TARGETDIR%
:SKIPCREATEDIR
del /Q %TARGETDIR%\*


pscp.exe -pw %3 %2 %TARGETDIR%

type  %TARGETDIR%\* > %1

The script takes the following parameters.

  1. The %F which is the name of the file, which the adapter is currently reading.
  2. A the location of the file on the server side in the form “user@server:path/[filter*] ie. root@sftp.figaf.com:dir/SKB*. This command logon with the user root on the host sftp.figaf.com. Then looks in the directory dir, relative to the login dir and the selects all files starting with SKB.
  3. The users password.

The command in the communication channel should look something like.

C:\scripts\sshftp.bat %F root@sftp.figaf.com:dir/SKB*.

I have only tested with password, but pscp might also work with using ssh keys.

pi , , ,

Search on SAP SDN/SCN with Ubiquity

July 27th, 2009

Last year I wrote about the SCN search plugin to Ubiquity, which made it easy to search on SCN. Ubiquity is a plugin for Firefox. The problem with writing such utilities is that they need to be updated when the unpublished API changes.

The SCN search has changed to a quite fancy web 2.0 search. It is now possible to filter the results based on type, and then subtype and other parameters. The old search just had the option of choosing between few options, which all were accessible via a GET parameter. The new search uses, as fair as I can see, Google Web Toolkit as javascript framework. It looks quite difficult to interact with this framework, so the new search script just take you to the search page.

Michael Koegel informed me that a new version of Ubiquity has been released. Version 0.5 can be installed here. This new version had some changes in the way scripts was written, so the script had to be changed.

The new script can be installed from Githup.

When the script is install, and the access keys (CTRL + SPACE standard) are pressed the following popup is created. First scn-search is typed and then the query phase is called. When Enter is pressed the query will be performed.

sap, sdn , , ,

Upgrades in WordPress is just to easy

July 22nd, 2009

I really like the upgrade feature of wordpress. It is impressive how smooth it is to upgrade wordpress. Just click a button and it is upgraded. The same is true for plugins.
This is something that other webapplications can learn from. It is probably not easy to implement, but makes is much easier for users to use the system.

Computer

Creating Google wave robots in Grails

July 22nd, 2009

Updated 17/11: A grails plugin for Wave have been released see MasteringWave for more information.

I just got access to Google wave, where I would like to create a robot. A robot is a participant in the wave conversation and can do the same as everyone else in the wave. Wave robots can currently only be used by applications running on Google App-engine, so you need access to App-Engine. You can get this access here.

The application that I’m using is running grails, so it needs to fit into that application. When you read the robot functional specification, robots should extend AbstractRobotServlet. In grails Apps you have Controllers and no servlets, so this is a bit tricky. But really easy, when you find the trick.

To create your app, you need to create a grails app, to be deployed in app-engine using the Grails app-engine plugin. Follow the guide on the page and you should have an app running on app-engine.

I’ll use the wave robot tutorial as starting point for the app. The first thing you need is to download the following files and place them in the ./lib folder of your project.

  • wave-robot-api.jar
  • json.jar
  • jsonrpc.jar

The you need to create a capabilities.xml file. This is a configuration file, telling wave what your app responds to. capabilities.xml should be placed in the folder ./web-app/_wave/

<?xml version="1.0"?>
<w:robot xmlns:w="http://wave.google.com/extensions/robots/1.0">
  <w:capabilities>
    <w:capability name="blip_submitted"/>
  </w:capabilities>
  <w:version>1</w:version>
</w:robot>

You can add as many capabilities as you want. Remember the version element should correspond to you application appspot version.

Update: For a clarification on the version numbering see http://www.masteringwave.com/2009/08/capabilities-xml

You can add the servlet file that need to be extended. This is done by placing the file in the ./src/groovy or ./src/java in your project. If it is a groovy file, it should probably be place4d in the groovy folder. You should maintain the package path within these folders. Create the following file ./src/groovy/com/wave/ParrotyServlet.groovy. (It is not very groovy code, but it is a start)

package com.wave
import com.google.wave.api.*;
class ParrotyServlet extends  AbstractRobotServlet {
  public void processEvents(RobotMessageBundle bundle) {
    Wavelet wavelet = bundle.getWavelet();

      if (bundle.wasSelfAdded()) {
        Blip blip = wavelet.appendBlip();
        TextView textView = blip.getDocument();
        textView.append("I'm alive!");
      }

      for (Event e: bundle.getEvents()) {
        if (e.getType() == EventType.BLIP_SUBMITTED) {
          Blip blip = wavelet.appendBlip();
          TextView textView = blip.getDocument();
          textView.append("Copying: " + e.getBlip().getDocument().text);
        }
      }

  }
}

Then you need to add the servlet mapping this is done by installing the template. Run the following command, when you are in your project.

grails install-templates

Then you can edit the file ./src/templates/war/web.xml and add the servlet and the serveletmapping. This is done with the following elements. Remember that two elements should be placed after corresponding elements; otherwise the XML is not valid.

   <servlet>
            <servlet-name>Parroty</servlet-name>
            <servlet-class>com.wave.ParrotyServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>Parroty</servlet-name>
        <url-pattern>/_wave/robot/jsonrpc</url-pattern>
    </servlet-mapping>

Deploy the service, and you can test you application. Create a new wave. Add you robot with the name <yourappspotname>@appspot.com. Try to add a comment and you should get something like this screencast.

This is not a very functional robot, but it works. To store data you can use a service, which can be called from the servlet.

Computer , , , ,

Formula one at Nürburgring

July 19th, 2009

I just got home from the German Formula One Grandprix at Nürburgring. The vacation was as always really nice and inspirational. So I wanted to share some of what I have learned from the trip.

We got to the camping place Wednesday around 13. If you want to stay at the Camping-am-ring place you should get to the place before 18 on Wednesday otherwise the number of places you can choose from is quite limited, but you can squeeze in to some place.

When we got to the place it was rainy, so we had to avoid the muddiest places. We found a spot at the top of places to choose from, and decided to pick a spot at the top. We therefore had to go shorter to the track and the Event center at night. The spot was also reasonably dry at the ground.

Our tent

We always go camping when going to a F1 race. It is much closer to the track, but most importantly it is more social and fun. The camping is much more fun compared to sitting in a hotel somewhere. We do not prefer the packaged tours, they are too basic. We just buy the ticket online by the track website. There seems to be greater innovations for people, how have not bought a packaged trip, because they can pack everything they need into their cars.

The Nürburgring track has been building a great new complex for events. This was not done on Wednesday, so the where working firmly on getting the last parts done to Thursday when the official program started. It seems like they managed to get mostly things done. There was still a couple of days work, but it was just the finishing.

There was still some parts of the sign missing

 

We had tickets to the T4 tribune section E. It was probably the best tickets that I have tried. We have had gold tickets at Spa-Francorchamps and at Hockenheim. But the view from the grandstand was great. It was possible to see the first corner and the whole Mercedes Arena. It was not possible to see all the way down the start and finish line. I think a better place would be at the Mercedes Tribune, where also a part of the start can been seen.

The view from the tribute T4 Section E

There was a lot of action at the corner and the arena in all the races. There was many fights of positions. I think the new regulations for F1 have meant more overtaking but the turn also seemed ideal.

The most fun part about the trip was the night life.

On the camping place event center was there a lot of music at night. The bands played cover numbers and did a really great job. They played for many hours and most members of the bands were singing. It looked really authentic and not like playback. Most importantly they got the whole tent ( a really large one) dancing and singing way.

The other interesting aspect was the way other campers had created their camps. It was nice to see groups bringing large truck to the campgrounds. They all had huge generators to power their sound and light shows. We both like watching what people have found they want to bring and show off. Unfortantly the night pictures was not very good because fo the light conditions and the camera. And then it was just to hang around and see what happened.

Now it is just to wait for the Belgium Grandprix.

Motorsport , ,

The difference between car vacation and backpacking

July 18th, 2009

My brother and his girlfriend went for three weeks in Greece, while we went for a week of camping at Formula one racing. There was a little difference in how much we each packed.

 

But we would like to have packed much more, if the car allowed it.

Motorsport ,

Echinopsis cactus blooming

July 17th, 2009

I finally caught our Echinopsis cactus blooming. It took around an hour from start to finish. It will bloom for a couple of days and then fade way. The Danish word is søpindsvinekaktus.

Green ,

Triathlon in Næstved

July 6th, 2009

Sunday I participated in my first Olympic length Triathlon (1500 m swimming, 40 biking, 10 km running) in Næstved, Denmark. It was the canal triathlon. I just had one problem, I had not trained my running to run to the full length, so I had to stop short after 5 km. I did the length in 2:03. The result can be found there. I did try the race to get to know more about, how Triathlons are performed.

I missed a triathlon handlebar for my bike. I would be much easier to drive with and requires less effort hopefully. I also needed some vaseline, so the swim suit did not create as many marks and was easier to get off. After the swimming, I did have problems with getting changed for the bike ride, it took too long time. I had not practiced the changes, so there is room for improvement.

The great thing was that I was in front of some of the triathletes (them with timetrials bikes), after the biking trip. That was quite interesting to not be the latest after the biking trip.

I’m looking forward to the next triathlon that I can participate in, and hope I’ll be able to run the full length.

sport , ,

SAP PI XML Mappings using groovy

July 3rd, 2009

Creating XML mapping in Java have for me always been difficult, it has been possible but I would prefer other tools. I was looking at scripting languages like Ruby/JRuby or Groovy for creating some web apps. Those languages seem quite hot right now. On the SCN Wiki a group has implemented the Grails (groovy on Rails) on the Netweaver system, as Composition on Grails. With this tool it is possible to applications with a Webdynpro look and feel. Grails is a framework for creating webapps with less coding.

Groovy is a scripting language designed on the basis of Java. Groovy script is compiled into Java classes, and both Java and Groovy can be mixed. This makes the implementation easier, just start writing Java and when you feel like use some of the smarter features of Groovy you can use them.

While I was looking at Grails, I thought that I would be possible to use it in PI. One place could be in java mappings. I’ll describe the steps that I have taken to implement this.

  1. Download and install the groovy library
  2. Get the Groovy plugin to Eclipse, this make developing much easier.
  3. Create a new Eclipse project
  4. Insert the aii_map_api.jar in the project, to be able to implement Streamtransformation service.
  5. Create a new Groovy file in the source folder, with the name GroovyMapIdoc.groovy, then Eclipse know that it is a groovy file.
  6. Create the mapping of your file. I have attached my example code bellow.
  7. Compile the Groovy files using the context menu on the GroovyMapIdoc.groovy file.
  8. Zip the content of the bin-groovy in the project folder and upload it, as an imported archive in the Integration builder. Alternative use ant build to create the zip files.
  9. Upload the two files Groovy-1.6.1.jar and asm-2.2.3.jar as imported archives. They can be found in <GROOVY_HOME>\lib
  10. Activate and use the mapping.

I would expect people trying this to have a good knowledge of using XI or PI Java mappings, because it is a requirement for the development of mappings.

One example I always have considered, was my first challenging mapping experience. Posting financial post with more than 1000 lines to the FIDCCP02 idoc. The FIDCCP02 only accepts 999 lines. The posting can be created multiply idocs with 998 lines and the post a balance on each item. This way all documents will balance.

The document is transformed from the left document to the right. I have for this example used a max size of 3 to make testing easier.

The code that I have used for the mapping is.

package com.figaf.mapping

import com.sap.aii.mapping.api.StreamTransformation;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;

import groovy.xml.MarkupBuilder

class GroovyMapIdoc implements StreamTransformation{

   Map param;
   
    void setParameter(Map param) {
        this.param = param;
    }
    // Number of lines pr idoc
    def step=3
   
    /**
     * Implementation of the execution method
     */
    void execute(InputStream input, OutputStream out) {

        // Parse the input using the XMLSlurper
        def FICCP01 = new XmlSlurper().parse(input)
        // get the different lines using the GPath
        def Lines = FICCP01.IDOC.LINE
        // create a writer example
        def writer = new OutputStreamWriter(out)
       
        def xml = new MarkupBuilder(writer)
        // create the root element and fill data into it.
        xml.FICCP01(){
            // get the number of idocs to be created.
            def numIdocs =   Lines.size()/step + (Lines.size()%step>0?1:0)  
            // loop for each idoc
            for ( i in 0..numIdocs-1 ) {
                // find the limit for the current idoc
                def max = Math.min( Lines.size(), i* step+2)
                // create sum ellement to create balances
                def sum = 0.0;
                 def lineno=1;
                IDOC(){
                    // create the number segment, using GPATH
                    NR(FICCP01.IDOC.NR )
                    // for each line in the range do the following
                    Lines[i*step..max].each{oldline->
                         // create a  new Line node, in the out put element
                         // with the following content
                        LINE(){
                        NO(lineno++)
                        Text(oldline.Text.text())
                        Amount(oldline.Amount.toBigDecimal())
                    }
                   // update the sum
                  sum +=oldline.Amount.toBigDecimal()
                }    
                    // create a balancing line, with balances the result
                    LINE(){
                        NO(step+1)
                        Text('Balance')
                        Amount(-sum)
                    }
                }
            }
        }

        // write the xml to output
         writer.flush()
         writer.close()
       
    }
   
}

Behind the scenes the Groovy file is changed in to java classes. Because Java does not support Closures natively different subclasses are created. Try to have a look on them using a decompiler like jad.

Conclusion

Groovy could be a way to improve the how java mappings are created. The XML generation is easier to handle then how it would have been created in Java and it is more powerful than XSLT. It takes some effort to get use to the closures concept of Groovy and the other notation, but it seems to work real well.

I don’t think the performance issue with the mapping is a problem. There is an overhead to load the groovy libraries and the code is probably not as optimized if it was written directly in java. I have not made any measurements for this.

pi, pi71 , , , , , , ,