Multi-language messages in SAP

The title of this post says it all.  It is known that usually international companies can afford to implement SAP and that part of the correspondence that they will have will be in several languages. So here is a simple procedure that can be used when a message to customers from different countries should be sent.

Step 1 -> Open the transaction s010 for Standard text creation

Step 2 ->  In the field add descriptive

TEXT NAME – (in this case – Z_CUST_MSG)

TEXD ID – ST

LANGUAGE – any.

Step 3 ->  Write the content of the message in the text editor and save it.

Step 4 ->  Repeat Steps 1-3 for all the languages that you would like to use.

Step 4 -> Using the text via ABAP code.

* t_lines to hold the text
  data: t_lines type table of tline with header line.
* CUSTOMER COMMUNICATION LANGUAGE
  select spras
    into cust_lang
    from kna1
    where kunnr = p_kunnr.
  endselect.
* GET THE TEXT FOR THE BODY OF THE MESSAGE
  CALL FUNCTION 'READ_TEXT'
    EXPORTING
      CLIENT   = SY-MANDT
      ID       = 'ST'
      LANGUAGE = cust_lang
      NAME     = 'Z_CUST_MSG'
      OBJECT   = 'TEXT'
    TABLES
      LINES    = t_lines.
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* IF THERE IS NO TRANSLATION OF THE LANGUAGE ASK USER
  ENDIF.
  DATA: counter type i.
 counter = 0.
 loop at t_lines.
 if counter = 0.
* in this case the first line of the text is used as a subject text for the message
      REPLACE ALL OCCURRENCES OF '/' IN t_lines WITH ''.
      modify t_lines.
      msg_sub = t_lines.
      counter = counter + 1.
    else.
      REPLACE ALL OCCURRENCES OF '/' IN t_lines WITH ''.
      modify t_lines.
      concatenate msg_body t_lines CL_ABAP_CHAR_UTILITIES=>NEWLINE into msg_body.
      counter = counter + 1.
    endif.
  endloop.

Outlook messages from SAP system

This is a sample code that can be used to create draft messages in your Outlook through SAP. Of course it is important to understand what it does so I tried to comment as much I can.

The VB code that can be used to create draft message is given here:

Sub create_draftmsg()
  Dim oApp As Outlook.Application
    Dim oEmail As Outlook.MailItem
    Set oApp = New Outlook.Application
    Set oEmail = oApp.CreateItem(olMailItem)
With oEmail
        .To = "to@mail.com"
        .CC = ""
        .Subject = "SUBJECT"
        .Body = "BODY TEXT"
        .Attachments.Add "C:\Cat.bmp", olByValue
        .Save
    End With
    Set oEmail = Nothing
End Sub

The ABAP code is given below.

INCLUDE OLE2INCL.
* they are all OLE2_OBJECTS so it is important to know the real classes
DATA: OUTLOOK TYPE OLE2_OBJECT,
MAILITEM TYPE OLE2_OBJECT,
ATTACHMENTS TYPE OLE2_OBJECT,
APPT TYPE OLE2_OBJECT,
DESTI TYPE OLE2_OBJECT,
BODYMAIL(600) TYPE C.
CREATE OBJECT OUTLOOK 'OUTLOOK.APPLICATION'.
* Get the outlook namespace
CALL METHOD OF OUTLOOK 'GetNamespace' = NAMESPACE
EXPORTING
#1 = 'MAPI'.
* Get outlook folders and create a reference to sent mail folder
* (myfolder)
* If this is not used than a draft message is not created when Outlook is not running
CALL METHOD OF NAMESPACE 'GetDefaultFolder' = MYFOLDER  EXPORTING     #1 = 16.    "olFolderDraftMail (value from a short debugging in VB)
CALL METHOD OF OUTLOOK 'CreateItem' = OUTMAIL EXPORTING #1 = 0. " 0 - MailItem
SET PROPERTY OF OUTMAIL 'SUBJECT' = 'SUBJECT'.
SET PROPERTY OF OUTMAIL 'BODY' = BODYMAIL.
CALL METHOD OF OUTMAIL 'RECIPIENTS' = DESTI.
CALL METHOD OF DESTI 'ADD' EXPORTING #1 = 'recipient@mail.com'.
CALL METHOD OF OUTMAIL 'ATTACHMENTS' = ATTS.
CALL METHOD OF ATTS 'ADD' EXPORTING #1 = 'filepath:\file.type'.
CALL METHOD OF OUTMAIL 'SAVE'.
FREE OBJECT DESTI.
FREE OBJECT ATTS.
FREE OBJECT OUTMAIL.
FREE OBJECT OUTLOOK.

Today’s wisdom: Use Macro recorder to discover the classes needed in order to use Microsoft goodies in ABAP! 🙂

Testing my thesis apps in a local primary school

After the first version of the apps is done it was time to test them with kids and see if they like them. I visited a primary school here in Skopje and had a chance to test them in 3 different classes. Total 75 kids tested the apps. The interesting fact was that 34 out of 75 kids (or their parents) had smartphones but only 7 of them had game consoles at home.

It is obvious that the second application is not motivating too much physical activity but this was due to the limited space we had in the classroom since now they have PC for every child in primary schools and tables couldn’t be moved around. But we were invited by the gym teacher to join them on a gym lesson next time.

SAP Technical sites/blogs I often consult…

The best technical  ones

http://www.saptechnical.com

http://abap4.tripod.com

http://abaplovers.blogspot.com

http://sap.ittoolbox.com

http://www.erpdb.info

http://www.freesaptutorial.com/

http://www.erpgenie.com

I’ll update this list every time I find a site/blog that will help me.

Simple shape detector – Android Application

Again a little more on the apps that I am developing for my master thesis… While checking what’s new in the exergaming area and the solutions that are offered on the market I learned about interactive walls and I really liked their purpose. There are ones where a part of the wall lights and the player has to hit there and then another different part of the wall lights and the player has to hit that as soon as possible.  More about them can be read here http://www.exergamefitness.com/twall.htm  or wherever you can find on the internet.

It was all nice and great until I saw the prices of these walls… One of them was about 15k dollars which seemed too much! This is why these walls are only available in the labs or special playing rooms.  OK I am not saying that there are no such walls sold maybe all over America or other parts of the world but schools in Macedonia wouldn’t agree to buy one such wall. So I thought can’t this be somehow done using a simple mobile phone? It would cost not more than 500 dollars (if we take in consideration the most expensive smart phones on the market).  It would be available at any time and any place and there would be no need for children to go in special places intended for exergaming but they could do it whenever they feel like it…

So I started working on a mobile app that would make any white wall interactive. This should be done by sticking papers with different colors and shapes on it and make a shape detecting app.  So the first thing that I thought of was the OpenCV library and the miracles it can do but after a couple of simple tests I did on the phone that I have for testing purposes -T-Mobile Pulse I realized that I couldn’t make it real-time. This device is just not fast enough. Then I checked for some other libraries available and I found jjil – Jon’s Java Imaging Library, for mobile image processing but that didn’t help me as well. It was still not real-time…* It was time for me to read some more about shape detection. The book that helped me the most was Digital image processing – An Algorithmic introduction using Java. Having a white wall and colored shapes I went straight to the part that talked about Regions in Binary images and got couple of ideas about how current shapes can be determined. Actually the process turned out to be really simple. I think that anyone would understand when seeing this picture.

The first and last black pixels are determined and the black pixels are counted. If we compare the math formulas for areas of square, circle and triangle (a^a, a^2Π/4, a^2√3/4)  we could see that the square is more than 85%, circle between 85% and 70% and the triangle is between 70% and 55% of the area between the two pixels. After I finished writing the code doing all this simple math and did the first tests I was surprised that it worked immediately! 🙂

There is the making-of the testing wall in my room.

Here you can see a video of the app.

This app is later extended as a memory game showing the player an array of shapes that he has to remember and “hit” with the phone. ASA I have some more free time I’ll post the code on GitHub so that people having more creative ideas than me could use it. In the next posts I’ll write something more about how the testing of the apps went with primary school students.

*NOTE: I still encourage people to test this libraries further and use them since they are pretty cool! 🙂

Browsing SAP workplace messages via Android phone

If I want to claim that I am an SAP enthusiast I have to prove that somehow…

The video below is a demo app that I submitted at the SAP TECHED 2010 contest. It is really more of a test on the capabilities that some tools offer like the good and old SAP .NET connector ( I’d prefer using the SAP Java connector but this was what I had at the moment of making the app) and the lightweight SOAP library for Android phones – ksoap-2. I got 2-in-1 with this app- learned a lot about connecting SAP with external systems and started my Android development journey.

Hopefully I’ll make something more useful for this year’s SAP TECHED.  🙂

What the app does and how it does it is done in the video. It is subtitled because I had some difficulties with the sound.

It is a bit slow but if you are patient enough you’ll see the steps needed to get it done. I might add some parts of the code in future posts or if you really need it mail me and I’ll send it to you.

Since there was a lot of SAP wisdom in this post I am free for a whole week 🙂

Mobile phone applications for motivating physical activity

Since I am getting close to the end of my master thesis project named “Mobile phone applications for motivating physical activity” I decided to name my first post the same.  I am doing my last project in this area because of my childish nature and the fact that parents are neglecting their children’s physical activity. So I decided to make applications that could be used on one more device and maybe influence a bit on their behavior.

I have spent the last couple of months going through the solutions offered to the public that motivate physical activities and I am very happy that there is a lot of interest for them.  Game consoles like Sony Playstation, Xbox, Nintendo Wii, Kinect and even the good old Dance pad are projects that I really appreciate. So I started with the idea of making the phone a game controller for a game that can generally be played while sitting in front of a PC, then tried to make the phone the only device needed for the kids to play and at the end made an app that has user interface where kids/parents/players can make their own games.

I will try to describe each one of them in the future posts and give just a sneak preview in the first one in this.

Here is a youtube video showing the first presentation of one of the apps.

More info…

coming soon…