Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap...

- SAP Community

Community

SAP Community  Products and Technology  Technology  Technology Blogs by Members

 How to call a BW ABAP-Backend from SAC Analytic Ap...

Technology Blogs by Members


Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP
products, technology, and events. Get in the mix!

All community  What are you looking for today?

 We have re-enabled the option to post and create content. Email notifications are
currently still turned off while we finish up steps related to badges and content
retagging. Subscribe for more.

How to call a BW ABAP-Backend from SAC Analytic Application

vitvas_gpg
Explorer

‎04-11-2023 11:34 PM

 16 Kudos

Introduction
There are several blogs showing how to organize interaction between SAC and S/4HANA
using OData services. However, one cannot ignore the fact that SAC, as an analytical
tool, often uses data from SAP BW or BW/4HANA. This blog provides a simple example
of how an OData Service can be used to exchange information between a SAC Analytic
Application and BW over a live connection. It is important to note, that this exchange is
bi-directional.

Our scope does not include a detailed discussion of the rich features of OData, such as

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 1/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

the use of complex types in services. Only the necessary setup steps are shown. If
necessary, a specialist will be able to use much more complex Services, required in
practical tasks, following to the same scheme.

It should also be noted that described solution can be used to transfer data from SAC to
BW with subsequent processing in ABAP. This may be required in cases where the SAC
scripting language capabilities are insufficient for complex calculations. Also, this solution
is useful if the SAC Analytic Application is used as a replacement for the Web Dynpro
applications, where it was possible to initiate the execution of any actions at the
Application Server using standard ABAP tools.

Prerequisites

CORS Settings

The described scheme only works when using a live connection between SAC and BW.
When creating this connection, BASIS Team performs CORS settings on the AS ABAP
side. These settings are described in detail in the corresponding section of SAP Help. In
our example, SAC Analytic Application will be used. This will require additional CORS
settings(service path /sap/opu/odata4/ and allowed header if-match).

Authorizations

It is assumed that the developer of the OData service has the standard set of ABAP
development permissions. Including creating and editing ABAP classes and using the
debugger. Additionally, following permissions will be required:

- transaction SEGW

- transactions /IWFND/***

- transactions /IWBEP/***

These authorizations can be described as follows:

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 2/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

- SEGW development authorization: authorization object /IWBEP/SB. In our example, a


project (i.e. OData service) with the technical name ZODATAV4 will be created, it will be
placed in the local ABAP package $TMP. Corresponding authorization should look as
follows:

- authorizations to start the OData service. In our example, ZODATAV4_GROUP


service group will be created. To do this, you will first need to have the following
authorizations on the S_USER_STA object:

Here the choice is made from the list in the AUTHOBJNAM field. Please, note that you
must first select the type of object in the “Type” drop-down list

Then the required values can be selected from the list or the “Full Authorization” button is
pressed. After confirming the selection, AUTHOBJTYP and AUTHPGMID fields will be
filled in automatically according to the value selected in the “Type” drop-down list.

After that you should restart transaction PFCG and add the following S_START
authorization with the same way as previous:

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 3/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

S_USER_STA authorisations are required only while editing the S_START object. When it
is done, S_USER_STA can be deactivated or removed from the role profile.

Demo Scenario

1. OData Service creation and configuration in BW. For the service, an action will be
defined that “is able to” launch a BW process chain.

2. Creation of SAC Analytic Application.

3. An OData connection will be placed in Application to communicate with our


Service.

4. A button will be placed in Application. An onClick-script for this button will call the
action in OData Service.

OData Service creation


Press the “Create Project” button in SEGW transaction, enter project technical name and
description. Make sure that “OData 4.0 Service” is selected as project type. Also, select a
development package if necessary. Here and below, in all examples, objects are created
locally in the $TMP package:

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 4/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

You can ignore following pop-up message:

Select newly created Project and press the “Generate Runtime Objects” button:

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 5/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

All fields in this window will be filled in automatically, you don't have to change them.

The ZCL_ZODATAV4_MPC and ZCL_ZODATAV4_DPC classes contain standard code that


is automatically copied by the system. This code should not be changed. All custom logic
need to be implemented by descendant classes whose names end in _EXT.

The Model Provider Class will declare the actions available in OData Service. It also
should describe the returns produced by actions. If necessary, you can declare input
parameters for these actions. For our example, we will create a StartProcessChain action
with a ChainTechName input parameter. The SAP BW process chain technical name will
be passed to input parameter when the action is called. The action will have a string type
return, which will show the ID of the chain run that was started during the action
execution. This is an artificial example, only to demonstrate that input parameter and
return of action are provide a bi-directional data exchange between SAC and BW.

To implement the logic described, we’ll create the new method START_CHAIN in Model
Provider Class. Also, standard method /IWBEP/IF_V4_MP_BASIC~DEFINE should be
redefined. Our action will be called directly from the SAC Analytic Application without
instantiating any helper types. Therefore, it must be unbound, that is, described as an
Action Import. For explanations of this OData terminology see, for example, in
corresponding sections of SAP Help.

Let’s create the START_CHAIN method as follows:

I added a code comments to clarify the logic:

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 6/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

1 METHOD start_chain.
2 DATA:
3 lo_action TYPE REF TO /iwbep/if_v4_med_action,
4 lo_action_import TYPE REF TO /iwbep/if_v4_med_action_imp,
5 lo_parameter TYPE REF TO /iwbep/if_v4_med_act_param,
6 lo_return TYPE REF TO /iwbep/if_v4_med_act_return.
7
8 "Declare an Action Import to be implemented in this OData Service
9 lo_action = io_model->create_action( 'STARTCHAIN' ).
10 lo_action->set_edm_name( 'StartProcessChain' ).
11 lo_action_import = lo_action->create_action_import( iv_action_import_na
12 lo_action_import->set_edm_name( 'StartProcessChain' ).
13
14 "Declare a local parameter type from standard OData types
15 io_model->create_primitive_type( iv_primitive_type_name = 'STRING' )->s
16 "Define an import parameter of this type for action described above
17 lo_parameter = lo_action->create_parameter( 'CHAIN' ).
18 lo_parameter->set_edm_name( 'ChainTechName' ).
19 lo_parameter->set_primitive_type( 'STRING' ).
20
21 "Declare that action should have a return and of which type it will be
22 lo_return = lo_action->create_return( ).
23 lo_return->set_primitive_type( 'STRING' ).
24 ENDMETHOD.

The redefined DEFINE method first calls the ancestor class method with the same input
parameters. And then transfers control to the START_CHAIN method, specific to our task:

1 METHOD /iwbep/if_v4_mp_basic~define.
2 TRY.
3 CALL METHOD super->/iwbep/if_v4_mp_basic~define
4 EXPORTING
5 io_model = io_model
6 io_model_info = io_model_info.
7 CATCH /iwbep/cx_gateway .
8 ENDTRY.
9
10 start_chain( io_model ).
11
12 ENDMETHOD.

Data Provider Class implements the action return calculation logic. It will be enough to
https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 7/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

redefine the method /IWBEP/IF_V4_DP_ADVANCED~EXECUTE_ACTION for


ZCL_ZODATAV4_DPC_EXT class. In our example, a standard function module will be
used to start the chain in BW:

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 8/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

METHOD /iwbep/if_v4_dp_advanced~execute_action.
TYPES: BEGIN OF s_chain_action,
chain TYPE string,
END OF s_chain_action.

DATA: ls_chain_params TYPE s_chain_action,


l_chain TYPE rspc_chain,
l_logid TYPE rspc_logid,
l_response TYPE string.

DATA:
lv_action_name TYPE /iwbep/if_v4_med_element=>ty_e_med_interna
ls_done TYPE /iwbep/if_v4_requ_adv_action=>ty_s_todo_pr
ls_todo TYPE /iwbep/if_v4_requ_adv_action=>ty_s_todo_li

"Read todo list of requested operations


io_request->get_todos( IMPORTING es_todo_list = ls_todo ).

"Check that action import 'STARTCHAIN' was requested


IF ls_todo-process-action_import = abap_true.

io_request->get_action_import( IMPORTING ev_action_import_name = lv

IF lv_action_name = 'STARTCHAIN'.

io_request->get_parameter_data(
IMPORTING
es_parameter_data = ls_chain_params "Structure with the action
).

ls_done-parameter_data = abap_true. "Parameters reading was execute

l_chain = ls_chain_params-chain. "This is necessary for data types


CALL FUNCTION 'RSPC_API_CHAIN_START'
EXPORTING
i_chain = l_chain
i_dont_wait = 'X'
i_gui = 'N'
IMPORTING
e_logid = l_logid.

l_response = l_logid.
io_response->set_busi_data( ia_busi_data = l_response ). "logid tra
ls_done-action_import = abap_true. "Action import was executed
io_response->set_is_done( ls_done ). "We return a list of executed
https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 9/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

47
48 ENDIF.
49 ENDIF.
50 ENDMETHOD.

OData Service publishing


Service ZODATAV4 must be published in the system. Following steps are necessary for
this:

1. Create Service Group in transaction /IWBEP/V4_ADMIN, if there is no previously


created group relevant for our purposes.

2. Assign OData Service to Service Group.

3. Publish Service Group, that is to make the services assigned to Group available for
use by other users with the necessary authorizations (authorization object
S_START). For that, the /IWFND/V4_ADMIN transaction is used.

Start transaction /IWBEP/V4_ADMIN and press the “Register Group” button. Enter Service
Group technical name and description:

After creating a Group, the system will prompt you to immediately assign some Service to
this Group:

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 10/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

You can choose “Assign”. If the relevant Group has already been created earlier, or if you
want to assign a Service to a Group later, you can do so using the “Assign Service”
button. Here you can simply select a Service and a Group from the list:

Service Group with the services assigned to it will be listed in the transaction:

If the Service Group has been newly created, then it must be published. To do this, go to
transaction /IWFND/V4_ADMIN and click the “Publish Service Groups” button:

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 11/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

Since we are talking about objects in the current system, select LOCAL in the System
Alias field, and then click “Get Service Groups”. A list of all unpublished groups will
appear:

Highlight the desired group and click “Publish Service Groups”. Then return to the
previous window. Now it shows the published group and the services assigned to it:

OData Service testing

The published service can be tested. This testing, if necessary, will allow you to fix the
issues in the classes and methods described above by break-points enabling and
switching to ABAP debugger. Testing can be started by highlighting our service as shown
in the previous screenshot and selecting "Service Test -> Gateway Client":

First of all, please, note the path displayed in the Request URI field:

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 12/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

The starting part of this path upto the $ sign is the End-Point URL, which will be required
later in the SAC settings. In our example, the End-Point URL turns out to be as follows:
/sap/opu/odata4/sap/zodatav4_group/default/sap/zodatav4/0001/

To start testing, you must first switch the HTTP Method to POST. Secondly, in the
Request URI, after the End-Point URL, you need to specify the name of the action that
will be called. Thirdly, you need to pass the value of the input parameter to the action
using JSON-Syntax. To test the service, a dummy chain ZPC_ODATA4_TEST was
prepared. It simply calls a program that contains no code. Therefore, the launch of
testing in the end looks like this:

Now testing can be started by pressing the “Execute” button. The successful result looks
like this:

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 13/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

In the RSPC transaction we can verify that the service actually started the execution of
the chain and returned the run ID:

OData Service utilization in SAC Analytic Application

Now we can use our OData Service in the SAC Analytic Application. For the
demonstration, the simplest application was prepared. It contains three components:
OData Service named ZODATAV4, button PC_START_BUTTON (labeled "Start Process
Chain"), text field CHAIN_RUN_ID, designed to display the value of action return:

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 14/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

In the ZODATAV4 component settings you must specify the name of the Live Connection
to that BW system where the service was created. See above for the required CORS
settings for this system. You also need to specify the End-Point URL. The value of this
parameter, corresponding to our example, was also indicated earlier:

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 15/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

To check the connection to the Service, you need to click the “Refresh” button to the right
of the Metadata section. If SSO between SAC and BW is not configured, then an
additional window will appear at this moment asking for your BW credentials. If the
connection to the Service is successful, then the Metadata section will display OData
version used and a list of actions provided by this Service:

Now the action can be called with the onClick script for the PC_START_BUTTON button:

First line of the script shows how to call an action from the ZODATAV4 service connected
to the SAC, how to specify the name of this action, how to pass the technical name of the
chain to the input parameter of this action. Then, if there were no errors while calling the
action, return value from the action is stored in the logid local variable. It, in turn, is
displayed in the CHAIN_RUN_ID text field.

So, before the button is clicked, application window looks like this:

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 16/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

After clicking the button, chain run ID appears:

As before, we can check correctness of this number in the RSPC transaction.

SAP Managed Tags:

BW (SAP Business Warehouse), SAP Analytics Cloud, NW ABAP Gateway (OData)

8 Comments

Siva_Raju
Discoverer

‎04-12-2023 10:25 AM

 1 Kudo

Very good explanation vitvas_gpg

Raksha_SAP
Associate

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 17/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community
‎04-13-2023 4:48 AM

 2 Kudos

Very Well explained

Henry_Banks
Product and Topic Expert

‎04-20-2023 5:07 PM

 1 Kudo

Thanks for this vitvas_gpg very nicely worked out, i will recommend to my customers

hemanth89k
Discoverer

‎08-10-2023 8:34 PM

 0 Kudos

Hi Vitaly Vasilyev,

Thank you so much for the detailed blog, its very helpful. I was able to configure steps till
generating the URL.

I am stuck in adding the button in Application Designer layout. I have tested and added
the Odata service ZODATAV4 in the layout, but script functions like executeAction are not
showing(CTRL+Space) in the button, getting error message:
https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 18/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

executeAction is not a function

executeAction is an unused property.

I am trying this by selecting Application Designer -> New -> Classic Design Experience.

Please let me know how to resolve.

vitvas_gpg
Explorer

‎08-11-2023 10:02 AM

 0 Kudos

Hi Hemanth,

Thank you for your feedback.

I tried to reproduce the issue you described. It is of critical importance that OData Action
name should be listed in 'Metadata' section of ZODATAV4 settings:

If Action name is not visible here, than indeed error messages listed by you will arise. So,
my advice is to go through the following implementation sequence:

1. Add OData Service to SAC Application

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 19/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

2. Rename this Service as ZODATAV4, for example


3. Select a corresponding BW Live Connection from the list
4. Enter the End-Point URL
5. Press the 'Refresh' button to the right of 'Metadata' section. Probably (if SSO
between SAC and BW has not been configured) your BW credentials will be
requested at this moment
6. After a few seconds, OData Version and Action name should be displayed under
'Metadata' section, as it shown on my screenshot. If it is not the case, then there
could be two reasons for this. First reason is that your login has not necessary
authorizations on BW side to work with OData Service. Second possible reason is
that CORS settings are not configured properly. In that case SAC can not view any
OData services. My recommendations for setting of authorizations and CORS are
listed in 'Prerequisites' section of my blog. Probably, you will need help of your SAP
BASIS Team to check and configure these prerequisites.
7. If OData Version and Action name are not displayed in 'Metadata' section, then
indeed you will see error messages 'executeAction is not a function' and
'executeAction is an unused property'.
8. If you see the Action name in 'Metadata' section, then SAC also know that this
Action exists. Only then you can start to implement the onClick script for Button. In
this case you will see the executeAction function when pressing CTRL+Space.
Moreover, Action name and Parameter name also will be suggested with
CTRL+Space:

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 20/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

former_member466150
Participant

‎08-29-2023 11:35 PM

 0 Kudos

Thank you vitvas_gpg, that is very helpful, after fixing the BW Live Connection issue I
was able to get the metadata and set up the button to run the PC.

Can you please share how to setup the CSRF token validation issue in POST method.

Getting this below error while debugging the application


‎12-20-2023 12:43 PM

 0 Kudos

Hi Vitaly,

Thank you for a great blog - very useful functionality!

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 21/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

Unfortunately I'm struggling to fetch the metadata for the OData Service:

Access to fetch at
'https://<BW>/sap/opu/odata4/sap/zlm_gw_sacodatav4/default/sap/zlm_gw_sacodatav4/
0001/StartProcessChain/$metadata' from origin
'https://<company>.eu10.sapanalytics.cloud' has been blocked by CORS policy: No
'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque
response serves your needs, set the request's mode to 'no-cors' to fetch the resource
with CORS disabled.

Do you have any good guide for how to setup the additional configuration for CORS and
the allow if-match allow header? It looks very like adjustments are needed for the CORS
on BW, like https://userapps.support.sap.com/sap/support/knowledge/en/2748971 and
thereby
https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86
a7/39d0e79aa6a0480a90417... so step 7 and onwards?

Screenshot from F12

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 22/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

vitvas_gpg
Explorer

‎12-21-2023 8:51 AM

 0 Kudos

Hi Rasmus,

Thank you for your interest in my blog.

CORS settings, from my point of view, is more subject of BASIS Team, then for BI
specialist. Unfortunately, I don't have enough BASIS knowledge to install Cloud
Connectors, configure SSO, SSL, etc. While preparing this blog, I used a Live connection
from SAC to BW, that was already created in advance by my BASIS colleagues. As I see,
there are two methods of establishing of Direct CORS Connection. Method mentioned by
you uses an ICM script. In my case method with Unified Connectivity was used. I can't
say why BASIS team considered it preferable than ICM Script. But all I had to do was edit
existing CORS settings. Initially, CORS settings were configured for usual SAC reporting
based on Live BW Models. I only added more settings that necessary to use OData
Services. For example, I added a configuration for path /sap/opu/odata4/ via transaction
UCONCOCKPIT as described for Unified Connectivity.

 You must be a registered user to add a comment. If you've already registered,


sign in. Otherwise, register and sign in.

Comment

Labels In This Area


ABAP 1 AIML 1 Business Partner 1 CDQ 1 Data Governance 1

Data Quality 1 Data Quality Management 1 Data Value 1 Full Stack 1 GitHub 1

Kerberos for ABAP 1 Kerberos for JAVA 1 Master Data 1

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 23/24
1/29/24, 11:33 AM How to call a BW ABAP-Backend from SAC Analytic Ap... - SAP Community

Master Data Management 1 SAP AI Core 1 SAP AI Launchpad 1 SAP BTP 1


Follow
Secure Login Client Setup 1 Single Sign On 1

Related Content
Privacy Terms of Use

Currency Conversion 
Copyright Legal Disclosure
in Technology Q&A 2 weeks ago

https://community.sap.com/t5/technology-blogs-by-members/how-to-call-a-bw-abap-backend-from-sac-analytic-application/ba-p/13571309 24/24

You might also like