Skip to Content

Introduction

Twitter is the latest buzzword these days when it comes to talking about social networking and Web 2.0. While there are articles on the web which say that Twitter is just a fad, here is an interesting approach to use it as a strong notification tool by integrating it with your Portfolio Management processes using SAP RPM and Collaboration Projects.

For those who would like to know what Twitter is all about, here is a definition of Twitter from Wikipedia – 

a free social networking and micro-blogging service that enables its users to send and read messages known as tweets. Tweets are text-based posts of up to 140 characters displayed on the author’s profile page and delivered to the author’s subscribers who are known as followers. Senders can restrict delivery to those in their circle of friends or, by default, allow open access. Users can send and receive tweets via the Twitter website, Short Message Service (SMS) or external applications.”

 

Being among one of the most popular and promising services for information broadcasting, Twitter can be accessed via several APIs and is completely free to use. Twitter is being used by several businesses for promoting their products and services.

The Concept 

Integrating your RPM and cProjects application with Twitter can help the stakeholders be in touch with the latest updates on their respective portfolios and buckets over the web.  The application hence developed will allow sharing tiny pieces of information in form of SMS-like tweets. Stakeholders have option to setup SMS alerts over their phone as well. This is an alternative approach to enable notifications via e-mails in SAP.

 

Here are some of the examples of what can be tweeted to the stakeholders within the RPM Portfolio Hierarchy:

    

 

Since tweets are ‘broadcasted’ across the followers, it is a good approach to have separate twitters for each of the objects in hierarchy. Administrators can keep a check on the followers of these tweeting accounts to ensure that only selected group of people can follow these tweets. The accounts can be kept private so that the tweets do not appear in the public timeline.

Architectural Aspects

 

The set-up requires writing a small ‘Tweet Dispatcher’ program that fetches data from CPRXRPM and makes use of Twitter API to update information as tweets. This program can be made to run at desired intervals. The extract logic for pulling out data from CPRXRPM can be written in remote enabled function modules. These function modules can be called via the dispatcher program.

Based on the architectural requirements, the dispatcher program can either be written in ABAP or in any other platform that can communicate with SAP via RFC calls.

Coding Guidelines

Following are some simple steps to get this concept working. Since I am more familiar to Java, the Tweet Dispatcher program is written in Java using Twitter4J API and the SAP JCo Adapter. Here is a short walkthrough:

1. Import the relevant packages.    

 

import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import com.sap.mw.jco.*;
 

 

2. Create a connection to the CPRXRPM System and add function parameters. Perform data retrieval. 

 

mConnection.connect();
JCO.Repository mRepository = new JCO.Repository("Twitter",mConnection);
JCO.Function function = null;
IFunctionTemplate ft =
mRepository.getFunctionTemplate("/RPM/BUCKET_DISPLAY"); 
function = ft.getFunction();
JCO.Structure struct = 
function.getImportParameterList().getStructure("IS_CONTEXT");
 /* Insert your business logic of selecting the relevant bucket/portfolio
and update the Import Parameters  */

 

The Function Module ‘/RPM/BUCKET_DISPLAY’ is used for retrieving the detail data of a bucket within a Portfolio. Custom FMs/BAPIs can be written and deployed here based on business requirements.

 

3. Execute the function and extract the export parameters. Prepare the output to be tweeted in the next step.

 

mConnection.execute(function);
 JCO.Structure returnStructure =  
 function.getExportParameterList().getStructure("ES_ATTRIBUTES");
String tweet = "Bucket - "  
+ returnStructure.getString("DESCRIPTION")
+ " - Item count: "
          +  returnStructure.getString("CNT_ITEMS")                    
          +  "  |  Initiative Count: "                    
          + returnStructure.getString"CNT_INITIATIVES");    

 

4. And now it’s the time to call up the Twitter API and tweet the retrieved results.

 

Twitter user= new Twitter(<<username>>, <<password>>);
  /* Twitter login credentials */ 
user.setHttpProxy(<<proxy>>, <<port>>);  
/* if within a network proxy */
user.setHttpProxyAuth(<<username>>,<<password>>); 
 /* if within a network proxy */
Status BucketTweet =user.updateStatus(tweet); 

 

Results

Here is a screenshot of a sample tweet that was updated using this program. The approach is simple, does not consume much efforts and notifications will not clutter your mailboxes! Go ahead and give it a try!

 

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

    1. Vivek Pandey Post author
      Hi Steven,
      I suppose it is possible to call up JAVA functions via ABAP. You may find various blogs/forum links on SCN over this topic. You can thus try calling the Twitter API via ABAP.

      Do let me know on your results.

      Regards,
      Vivek

      (0) 
    2. Michael Nicholls
      Looking at one of the twitter tutorials here it appears that you just need to do an HTTP POST. If you can find an appropriate ABAP function module or class to do that, then you’re OK.

      Good luck!

      (0) 
  1. Mike Schernbeck
    DATA:
      http_client TYPE REF TO if_http_client,
      request TYPE string,
      message TYPE string,
      username TYPE string,
      password TYPE string.

    cl_http_client=>create_by_url( EXPORTING url = ‘http://www.twitter.com
    IMPORTING client = http_client ).

    http_client->authenticate( username = username
    password = password ).

    http_client->request->set_method( ‘POST’ ).

    http_client->request->set_header_field( name = ‘~REQUEST_URI’
    value = ‘/statuses/update.xml’ ).

    http_client->request->set_form_field( name = ‘status’
    value = message ).

    http_client->send( ).

    (0) 
  2. Matthew Delaney
    Thanks for writing about this topic. I was windering if anybody knows of any company’s that are currently using twitter for SAP alerts or notifications.
    Thanks
    (0) 

Leave a Reply