Skip to Content

How to Integrate Text Analytics into an ABAP System

The contents of this paper are not subject to any license agreement with SAP. The concept / code outlined below is not intended to be binding upon SAP to any course of business / product strategy and / or development. This is subject to change and may be changed by SAP at any point in time. SAP assumes no responsibility for errors or omissions in this document.

I have written BLOGs around Web 2.0 and the integration of Social Media into CRM from a scenario and usage standpoint. The big question left open there is:

How is this possible to do with the existing tools and ABAP ?

In this post, I present something that allows integration of Text Analytics into an ABAP system.

For those who are not aware, Voice of Customer product (A derivative of ThingFinder / Text Analytics suite of products), in it’s most simplistic form, is an engine that takes in unstructured text as input and provides as an output Topics (Structured of of the Natural Language) and the possible Sentiment Analysis of the text (Is this very positive or negative) as one topic.

The core of this analysis is a corpus that is customized using the ThingFinder Workbench and served over a Web Service (SDX Server). A detailed discussion on this is not something that I intend in this post. The focus of the next parts of this post is going to be how to integrate the Web Service API provided by the SDX Server into ABAP as an API and how to extract purely the sentiment out of this.


  • An install of Voice of Customer / Text Analytics (VOC)
  • ABAP System (Needs to have Web Service Consumption Support)

The following are the steps that you will need to do in order to use VOC Sentiments in ABAP:

  1. Generate the Web Service Client Proxy in the ABAP System
  2. Define the endpoint for the WS call
  3. Create an ABAP Class that invokes the WS with the right parameters (Text to be analyzed)

1. Generate the Web Service Client Proxy in ABAP

Goto Transaction SE80 into your package where you want to create the client proxy (I used $TMP). On Enterprise Services, right click and choose Create. This brings up the creation wizard for a Service.

ES Wizard

Choose the type: Service Consumer and click Continue

You will see a dialog that asks you for the definition of a WSDL (I uploaded from my local, but you can add a URL / choose from ESR)

ES Wizard Step 2

Add the URL to the WSDL file, an example is:


Choose the package where you want the client proxy classes generated and complete the wizard. (You will be prompted for a prefix for the classes, I used ZGD) Netweaver will now generate the client proxies for you. (Do not forget to activate)

Voila ! you have the proxy class: ZGDCO_THING_FINDER

Proxy Class

2. Define the endpoint for the WS call

Goto transaction: LPCONFIG and create an endpoint for your generated class, say for logical port LP00. In the area for Call Parameters, enter the URL or HTTP Destination that you have created in SM59 for invoking this Web Service.

3. Create an ABAP Class to invoke the WS

Well, this is just an ABAP class. I created a simple class as per the below, 3 methods:

  • extract_sentiments(iv_string type string, rv_sentiment type i)
  • convertstring2xstring(iv_string type string, rv_xstring type xstring)
  • convertxstring2string(iv_xstring type xstring, rv_string type string)

The main method is extract_sentiments. It takes the inputted string and invokes the WS, processes the returned topics and converts the topic to a sentiment score. During this process, the format expected by the WS is encoded (BASE64), the utility methods just use the ABAP BASIS conversion classes to help out there.

Source Code for extract_sentiments


Code Part 1

Invoking the WS

Code Part 2

Transformation of Sentiment to a “Score” 

Sentiment Extraction

Source Code for convertstring2xstring

String to XString

Source Code for convertxstring2string

Convert XSTring to String

This may not be the neatest code, but it works…

Test It !!!


A detailed discussion on the concepts of ICM, Web Service Configuration is not part of the scope of this post, though you should be able to find several posts and training courses on each of those aspects of this post.

Many thanks to the CRM and Text Analytics team that took the time to help me with this post.

Be the first to leave a comment
You must be Logged on to comment or reply to a post.