Financial Management Blogs by SAP
Get financial management insights from blog posts by SAP experts. Find and share tips on how to increase efficiency, reduce risk, and optimize working capital.
cancel
Showing results for 
Search instead for 
Did you mean: 
dejan_kostic3
Associate
Associate
5,735

Introduction


SAP Profitability and Performance Management (PaPM), provides capability of writing result data directly to SAP BW infoprovider using Writer function. However, this option is available only in case  PaPM and SAP BW are residing on same SAP system. It is not possible to use writer function to write result data to infoprovider on remote SAP BW system.



This document will describe one of the ways that can be used to write PaPM data to remote SAP BW system. Data flow will have to be manually created on SAP BW system and data will be pulled from PaPM table and loaded to ADSO. It will also describe how to automate the entire process using Remote Function Adapter function and trigger execution from PaPM system. Single RFA function will be used to trigger PaPM calculation and execute data pull from remote SAP BW system.


In this example, copy of standard sample content environment SXI – IT Cost Management is used. However, any executable function from any PaPM environment can be used for same purpose.

Goal is to write results of allocation function ALSBU – Allocate Services to Business Units, from PaPM system to ADSO ZALSBU on remote SAP BW system.


To make it simpler, ADSO ZALSBU is created using same fields like in ALSBU function.

Idea is to create a data source on remote SAP BW system to access result data of ALSBU function from PaPM system using SAP HANA Smart Data Access. Datasource will then be connected to ADSO and data loaded like shown in dataflow bellow. Process chain will be used to automate the load. Process chain  will be executed from RFA function on PaPM system.


 

In order to be able to follow the steps described in the next section, apart from PaPM, user needs to have fundamental understanding and at least basic knowledge of SAP BW and ABAP. All required ABAP code is included in blog.

 

Prerequisites



 

Steps on SAP BW System


All bellow steps are performed using Modeling Tools for SAP BW for SAP HANA Studio or using transaction RSA1.

Create Data source


Datasource will be used to access data directly from result table of ALSBU allocation function. Settings should be maintained like shown below, using schema that PaPM uses for creating result tables, usually SAP<SID>. Generated DDIC table for function ALSBU should be selected. Table name can be found in modeling environment, locate the function in the function hierarchy and click on Function attributes button. In the dialog box, navigate to Runtime attributes tab to find the DDIC Table name.

Switch to the Fields tab, select FS_PER_PROC_ field and maintain selection properties as mentioned bellow. Result table of PaPM function could contain result sets for different Process id’s. During every function execution, data from result table are being refreshed. Data with same process id are deleted and new data inserted. Selection on process is is important to avoid duplication during data extraction. For every run we want do extract only data created for process id used in current run not all data from result table.


 

Create Transformation


Transformation connects datasource ZDSALSBU with ADSO ZALSBU.


Both objects use same field names and all transformation rules will be automatically created.


 

Create Data Transfer Process


Create Data Transfer Process to load data using proposed settings.

Select Filter Button and then select Create Routine to maintain filter routine for FS_PER_PROC_ID_ field like shown below. Routine will be used to restrict data extracted from result table and select only data for current process id. In case you are not using multiple process templates/instances in your PaPM environment this step can skipped.


Select button bellow to open routine editor.


Enter bellow code in editor screen of filter routine and Save.
*&---------------------------------------------------------------------*
*& Include RSBC_SEL_ROUTINE_TPL
*&---------------------------------------------------------------------*

program conversion_routine.
* Type pools used by conversion program
type-pools: rsarc, rsarr, rssm.
tables: rssdlrange.
* Global code used by conversion rules
*$*$ begin of global - insert your declaration only below this line *-*
DATA: l_req_id TYPE rsbc_requid,
ls_rssdlrange TYPE rssdlrange.
*$*$ end of global - insert your declaration only before this line *-*
* -------------------------------------------------------------------
* Fieldname = FS_PER_PROC_
* data type =
* length = 000000
* -------------------------------------------------------------------
form c_FS_PER_PROC_
tables l_t_range structure rssdlrange
using i_r_request type ref to IF_RSBK_REQUEST_ADMINTAB_VIEW
i_fieldnm type RSFIELDNM
changing p_subrc like sy-subrc.
* Insert source code to current selection field
*$*$ begin of routine - insert your code only below this line *-*

TRY.

i_r_request->get_requid( IMPORTING e_request_id = l_req_id ).

DATA(lr_request) = cl_rsbk_request=>create_from_db( l_req_id ).
DATA(l_logid) = lr_request->get_logid_pc( ).

CHECK l_logid IS NOT INITIAL.

SELECT SINGLE * FROM rspcrunvariables INTO @DATA(ls_var)
WHERE meta_log = @l_logid AND fnam = 'PROC_ID'.

ls_rssdlrange = VALUE #( fieldname = i_fieldnm option = 'EQ'
sign = 'I' low = ls_var-low ).


READ TABLE l_t_range ASSIGNING FIELD-SYMBOL(<ls_range>) WITH KEY
fieldname = i_fieldnm.
IF sy-subrc = 0.
<ls_range> = CORRESPONDING #( ls_rssdlrange ).
ELSE.
APPEND ls_rssdlrange TO l_t_range.
ENDIF.

CATCH cx_root.
ENDTRY.

*$*$ end of routine - insert your code only before this line *-*
endform.

 

Create Process Chain


Process chain contains only Start step and DTP execution. Depending on infoprovider, data activation step would be required in some cases. In case it’s planning ADSO, steps for switching real-time load behavior would be required as well.


 

Steps on PaPM System


Remote Function adapter function will be used to execute custom function module which will trigger process chain on SAP BW system, pull PaPM data and load it to ADSO. In this example RFA function uses allocation function as input, therefore, it will first execute allocation function, refresh data in result table and then execute Process chain on remote system. For this to work, it is required that allocation function ALSBU is set as executable. Allocation function should not be used as activity in any process template. In case ALSBU is used as an activity, it will have to be manually executed first, before executing RFA function.

 

Create Table Type


When External Function is used as Remote Function Adapter Type, it receives data from input function using input parameter IT_DATA. If you open rules tab, template will be created and you can see structure of IT_DATA. It basically corresponds to output table of input function ALSBU.


Therefore, you can use generated DDIC table for function ALSBU directly as a line type for your table type.


 

Create Function Module


Function module needs to have a signature like in RFA function template mentioned before and should be created with bellow source code. It receives IS_AL which will be used for getting process id selected during run. RFA function does not process any data, therefore, IT_DATA all though is necessary in function signature, will not be used in coding. Changing parameter CT_MSG table is used for passing messages to application log and it will propagate messages from process chain execution. Only thing that needs to be changed in coding is name of RFC destination and process chain that needs to be executed. Process ID will be taken from application log and passed as variable to Process Chain. Filter routine in DTP will get process id from process chain and use it to create a selection condition for data extraction.
FUNCTION zstartpc.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IS_AL) TYPE /NXI/TP1AL
*" REFERENCE(IT_DATA) TYPE ZT_ALSBU
*" CHANGING
*" REFERENCE(CT_MSG) TYPE /NXI/P1_TAB_ALMSG
*"----------------------------------------------------------------------
DATA: lv_chain TYPE rspc_chain,
lv_rfcdest TYPE rfcdest,
lv_logid TYPE rspc_logid,
lv_status TYPE rspc_state,
lt_variables TYPE rspc_t_variables,
lt_msg TYPE rspc_t_msg.

lv_chain = ''.”PC that should be executed
lv_rfcdest = ''.”RFC Destination
lt_variables = VALUE #( ( fnam = 'PROC_ID' opt = 'I' sign = 'EQ' low = is_al-proc_id ) ).

CALL FUNCTION 'RSPC_API_CHAIN_START' DESTINATION lv_rfcdest
EXPORTING
i_chain = lv_chain
i_synchronous = abap_true
i_t_variables = lt_variables
IMPORTING
e_logid = lv_logid
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

CALL FUNCTION 'RSPC_API_CHAIN_GET_STATUS' DESTINATION lv_rfcdest
EXPORTING
i_chain = lv_chain
i_logid = lv_logid
IMPORTING
e_status = lv_status.


CHECK lv_status CA 'RXJ'.

CALL FUNCTION 'RSPC_API_CHAIN_GET_ERRORS' DESTINATION lv_rfcdest
EXPORTING
i_chain = lv_chain
i_logid = lv_logid
i_dont_poll = abap_true
TABLES
e_t_log = lt_msg.


CHECK lt_msg IS NOT INITIAL.

ct_msg = CORRESPONDING #( lt_msg ).

ENDFUNCTION.

 

Creating Remote Function Adapter Function


Finally, RFA function can be added to the environment. This is the only change that needs to be done in existing PaPM environment. RFAWR function uses ALSBU as input function and calls the function module ZSTARTPC. Function itself does not do any data processing and result is not used, therefore, input data are not needed. To improve performances a bit, a condition that doesn’t select any data is added to the input tab.


Process chain of RFA function executes first ALSBU function and then RFAWR function itself. RFAWR function itself does not process any data but only triggers the process chain from remote SAP BW system to load ALSBU result data to ADSO.


 

 

Execution and Results


Once all previous steps are performed RFA function RFAWR can be executed.


After the RFAWR function is executed with process template SXI_P_, application log shows that function ALSBU created 126.515 records and Function RFAWR processed 0 records.


 

If you check ADSO  ZALSBU on SAP BW system, you will see that 126.515 records are loaded and DTP Selection FS_PER_PROC_ID_ = SXI_P_ was applied.


 

Hopefully, this blog gave you an idea how PaPM result data can be written to remote SAP BW system. PaPM doesn't directly support it since it would require generation of SAP BW objects on remote system, however, it can still be achieved and automized with a bit of an extra effort from users side.

ABAP code can be reused in your examples and adjusted to support some additional requirements. Data flow and Process Chain on remote SAP BW system can be further enhanced and executed using same Function Module.

 

Cheers,

Dejan
5 Comments