Skip to Content

In this blog I would like to share how I created a simple WebService to select and read data from a InfoProvider defined in SAP Netweaver 7.0. The InfoProvider is a write optimized DataStore Object in this case, but could be exchanged with any other InfoProvider type.

First of all I would like to point you to the Interface Matrix blog:
SAP NetWeaver BI Interfaces – Overview II

In the Interface Matrix you can find the interfaces that can be used in SAP NetWeaver BI.
The interface that I have used in this example can be found in the overview for the Interfaces for Enterprise Data Warehouse.
http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e21fa3c1-0d01-0010-38ba-a8fba451d6ac

Let’s get started. First of all somebody defined the write optimized DataStore and I got the requirement to make the data available in a WebService. The WebService is being used in an external Web Application.

The name of the DataStore Object is DSO5. You can see the definition of the DataStore in the Screenshot below.
DataStore Definition

I was not told which fields need to be selectable and which fields need to be transfered. So, I decided to create a more flexible WebService.
Before I started to create the WebService I thought about the input and export parameters. I decided to use a range table as an Input parameter. The type of the range table I have used is RSDRI_T_RANGE. The structure is RSDRI_S_RANGE. This input parameter allows me to send different filter criteria’s for different InfoObject as a single input table. Please find the structure definition below.

Range table

 The first field CHANM is the parameter for InfoObject. For instance: 0OI_EQUITU (Equipment number)
The second field SIGN defines if the filter does (I)nclude or (E)xclude the values.
The third parameter is COMOP. This parameter defines how the filter is used:

EQ Equal: Single Value
NE Not Equal: Everything Apart from the Specified Single Value
BT Between: Range of Values
NB Not Between: Everything Outside the Range
LE Less or Equal: Everything <= Value in Field LOW
GT Greater Than: Everything > Value in Field LOW
GE Greater or Equal: Everything >= Value in Field LOW
LT Less Than: Everything < Value in Field LOW
CP Contains Pattern: Masked Input: Find Pattern
NP Not Contains Pattern: Masked Input: Reject Pattern
HI Hierarchy Node Selection

The fourth and five parameter LOW and HIGH are used for the values.
Please find an example below.

Range table example

The export parameter of the WebService has to be a flat table. Since the write optimized DataStore Object is technically a flat table I decided to use the table type of the DSO5 InfoProvider. In this case it is: /BIC/AZDSO500. The pattern of the generated name is ‘/BIC’ for the customer namespace ‘A’ for active table ‘ZDSO5′ the technical name of the DataStore Object and ’00’,
If you wanna select the data from a InfoCube you would need to choose the structure of the InfoCube. For example /BIC/VZCUBE_12 if the name of the InfoCube is ZCUBE_1.

Now I have got the definitions of the Input and Export parameters of the WebService. 
Since I’m using the ABAP Workbench to define the WebService I will create a Function Module first and when I generate out of this function module the WebService.

So let’s create the function module.
I go to the ABAP Workbech I create a Function Module. The name of the function module I used is ZINFOPROVDATA_ZDSO5
I define the Input Parameter I_RANGE with type RSDRI_T_RANGE and a table parameter E_T_DATA with type  /BIC/AZDSO500.
See Screenshots below.

Export Parameter

Import Parameter

Import ParameterNow we have created the Function Module.
But the coding of the Function Module is missing.

I have identified 3 Interface to get the data out of the DataStore Object.
First we need to get the list of the InfoObjects in the DataStore Object.

***************************************
* get DataStore Object details (BAPI) *
***************************************
  CALL FUNCTION ‘BAPI_ODSO_GETDETAIL’

Second we need the field names of the InfoObjects.
***************************************
* get DataStore Object details (BAPI) *
***************************************
   CALL FUNCTION ‘BAPI_IOBJ_GETDETAIL’

Thrird, we need to select the data.
*****************************
* Data selection RSDRI (API) *
*****************************
  CALL FUNCTION ‘RSDRI_INFOPROV_READ’

If you want to read the data from an InfoCube you would exchange the Interface CALL FUNCTION ‘BAPI_ODSO_GETDETAIL’ with  CALL FUNCTION ‘BAPI_CUBE_GETDETAIL’.

Once we know the interfaces it is easy to implement the WebService.
Please find the coding below of this blog.

After activating the Function Module we are able to generate a WebService out of this function module. How this can be done you can find in my blog:
SAP NetWeaver 7.0 BI: How to create a simple Master Data update WebService
SAP NetWeaver 7.0 BI: How to create a simple Master Data update WebService

The WebService can be tested in Transaction WSADMIN. Here you can find the WSDL for the WebService, too.

I hope you have fun using this possibility.  Please feel free to send me any comments etc. Keep in mind that this WebService does not support Mass Data.

Please find the coding of the function module below:

FUNCTION ZINFOPROVDATA_ZDSO5.
*”———————————————————————-
*”*”Local Interface:
*”  IMPORTING
*”     VALUE(I_RANGE) TYPE  RSDRI_T_RANGE
*”  TABLES
*”      E_T_DATA STRUCTURE  /BIC/AZDSO500
*”———————————————————————-
TYPE-POOLS: rs, rsdrc.
************************************************
* Data selection                               *
* RSDRI InforProv read including Authorization *
************************************************
  Data:
      l_th_sfc       TYPE rsdri_th_sfc,
      l_th_sfk       TYPE rsdri_th_sfk,
      l_s_sfc        TYPE rsdri_s_sfc,
      l_s_sfk        TYPE rsdri_s_sfk,
      l_t_range      TYPE rsdri_t_range,
      l_s_range      TYPE rsdri_s_range,
      l_first_call   TYPE rs_bool VALUE ‘X’,
      l_s_iobjdetails type BAPI6108,
      l_t_iobjdetails type table of BAPI6108,
      l_t_infoobjects type table of BAPI6116IO,
      l_s_infoobjects type BAPI6116IO,
      m_s_infoobjects TYPE rsdo_s_odso_iobj,
*      g_s_data        TYPE /BIC/AZDSO500,
  g_s_data        TYPE /BIC/AZDSO500,

  g_t_data        TYPE STANDARD TABLE OF /BIC/AZDSO500
                  WITH DEFAULT KEY INITIAL SIZE 10,

          i_dso type BAPI6116-ODSOBJECT value ‘ZDSO5’.

***************************************
* get DataStore Object details (BAPI) *
***************************************
  CALL FUNCTION ‘BAPI_ODSO_GETDETAIL’
    EXPORTING
      OBJVERS                    =  ‘A’
      ODSOBJECT                  = i_dso
    TABLES
      INFOOBJECTS                = l_t_infoobjects.

* built InfoObject list for RSDRI API *
  LOOP AT l_t_infoobjects INTO l_s_infoobjects.
    if l_s_infoobjects-INFOOBJECT NE ‘0REQUEST’ and
       l_s_infoobjects-INFOOBJECT NE ‘0DATAPAKID’ and
       l_s_infoobjects-INFOOBJECT NE ‘0RECORD’ and
       l_s_infoobjects-INFOOBJECT NE ‘0RECORDMODE’.
*   (BAPI)
    CALL FUNCTION ‘BAPI_IOBJ_GETDETAIL’
      EXPORTING
        VERSION    = ‘A’
        INFOOBJECT = l_s_infoobjects-infoobject
      IMPORTING
        DETAILS    = l_s_iobjdetails.

*   append l_s_iobjdetails to l_t_iobjdetails.

    IF l_s_infoobjects-iobjtp = ‘KYF’.
      l_s_sfk-kyfnm    = l_s_infoobjects-infoobject.
      l_s_sfk-kyfalias = l_s_iobjdetails-fieldnm.
      l_s_sfk-aggr     = ‘SUM’.
      INSERT l_s_sfk INTO TABLE l_th_sfk.
    ELSE.
      l_s_sfc-chanm    = l_s_infoobjects-infoobject.
      l_s_sfc-chaalias = l_s_iobjdetails-fieldnm..
      INSERT l_s_sfc INTO TABLE l_th_sfc.

    ENDIF.
    endif.
  ENDLOOP.

DATA: g_end_of_data  TYPE rs_bool,
      g_first_call   TYPE rs_bool.

* — this variable will be set to TRUE when the last data
*     package is read
g_end_of_data = rs_c_false.
* — this variable indicates whether this is an initial
*     call to the reading module or a follow-up call (which
*     simply retrieves already selected data)
g_first_call  = rs_c_true.

* WHILE g_end_of_data = rs_c_false.

*****************************
* Data selection RSDRI (API) *
*****************************
  CALL FUNCTION ‘RSDRI_INFOPROV_READ’
    EXPORTING
      I_INFOPROV             = i_dso
      I_TH_SFC               = l_th_sfc
      I_TH_SFK               = l_th_sfk
      I_T_RANGE              = I_RANGE
      I_PACKAGESIZE          = 100000
    IMPORTING
      E_T_DATA               = g_t_data
    CHANGING
      C_FIRST_CALL           = g_first_call
    EXCEPTIONS
      ILLEGAL_INPUT          = 1
      ILLEGAL_INPUT_SFC      = 2
      ILLEGAL_INPUT_SFK      = 3
      ILLEGAL_INPUT_RANGE    = 4
      ILLEGAL_INPUT_TABLESEL = 5
      NO_AUTHORIZATION       = 6
      ILLEGAL_DOWNLOAD       = 7
      ILLEGAL_TABLENAME      = 8
      TRANS_NO_WRITE_MODE    = 9
      INHERITED_ERROR        = 10
      X_MESSAGE              = 11
      OTHERS                 = 12.
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  move g_t_data[] to e_T_DATA[].
ENDFUNCTION.

To report this post you need to login first.

2 Comments

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

  1. Former Member
    Thanks for the great Blog Michael, I am looking at using few function Module in Function Group RS_VC, can you please let me know if this are published for external customer?
    (0) 
    1. Hi,
      those functions are used for the Visual Composer communication. I believe that SAP is going to change the VC and BI integration. So this function will not published. Thanks for your understanding, Michael
      (0) 

Leave a Reply