enhancing bw datasources through badi - rsu5_sapi_badi
Post on 16-Oct-2015
618 Views
Preview:
DESCRIPTION
TRANSCRIPT
-
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
1/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 1
Enhancing DataSources with BAdI RSU5_SAPI_BADI
Appl ies to:
As of SAP_BASIS 6.20 and PI_BASIS 2004_1 (R/3 Release 4.6C).
Summary
This white paper explains in details how to enhance DataSources with the new featured BAdIRSU5_SAPI_BADI.
It is shown how to implement each enhancement on a separated method of the BABI class, making the codemore organized and clear, then in the formerly user exits EXIT_SAPLRSAP_00X.
Author(s): Flvio Peres
Company:NetSoft Sistemas
Created on:02 febuary 2007
Author Bio
Flvio Peres is a SAP-BW Senior Consultant in NetSoft, So Paulo, Brasil.
-
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
2/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 2
Table of Contents
Enhancing DataSources with BAdI RSU5_SAPI_BADI .................................................................. 3Implementing the BADI.................................................................................................................... 3
On transaction SE19 .................................................................................................................... 3Define a implementation name for your class. ............................................................................. 4Then paste the following code: .................................................................................................... 6Create a new method and name it: _TEMPLATE_DATASOURCE. ........................................... 8Define the properties of this method as static and public ............................................................ 8
Creating a enhancemente of a datasource. .................................................................................. 10Declare on the code the structure to populate. .......................................................................... 10Bellow you have too examples of how to code your enhancement:.......................................... 11
Here a simple way to populate the fields of the structure straight from the select:................ 11And here a slight more complex example, using some functions inside the code:................ 11
Conclusion: .................................................................................................................................... 14Related Content............................................................................................................................. 15Disclaimer and Liability Notice....................................................................................................... 16
-
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
3/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 3
Enhancing DataSources wi th BAdI RSU5_SAPI_BADI
As of SAP_BASIS 6.20 and PI_BASIS 2004_1 (R/3 Release 4.6C) is available a more efficient way toenhance SAP standard content, using Business Add-Ins (BAdIs) rather than user exits.
The technical name of this BAdI is RSU5_SAPI_BADI, detailed on the SAP Note 691154.
Each enhancement will be implemented in a separated method of the BABI class, then the code will be moreorganized and clear.
Below, I describe in details, how it can be done, just following a simple few steps.
Before we begin, there are some pre conditions, that must be filled:
SAP_BASIS 6.20 and PI_BASIS 2004_1 must be installed on your system.
The BADI-definition RSU5_SAPI_BADI (SE18) must exists in your system.
Once the pre conditions ware verified, its time to go.
I will assume that the process of creating and enhancing extraction structures of a given datasource is knowby the reader.
If you have doubts about the creation and enhancement of data sources, consult the documentation on SDN.
Implementing the BADI.
SAP make available the definition of the BADI, the implementation must be created for us, as follows:
On transact ion SE19
Type
Click on
-
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
4/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 4
Define a implementation name for you r class.
Click to confirm.
Click on to activate de implementation.
Result: You have created the implementation of the BADI, that will used to create the datasourceenhancements.
-
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
5/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 5
Click on the TAB
Click on the link
You go to the class builder
-
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
6/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 6
On the class builder click on the method name:
Then paste the follow ing code:
method IF_EX_RSU5_SAPI_BADI~DATA_TRANSFORM.
**********************************************************
* To implement an exit for a
* datasource create your own method by copying the
* method _TEMPLATE_DATASOURCE and rename it to the name
* of your datasource. In case you enhance a Business
* Content datasource skip the 0 at the beginning (e.g.
* Datasource 0FI_AR_3 -> Method FI_AR_3
* The method is then called by the Exit Framework
*********************************************************
DATA: ls_oltpsource TYPE rsaot_s_osource,
lv_data TYPE REF TO data,
lv_method TYPE seocmpname.
FIELD-SYMBOLS: TYPE STANDARD TABLE.
* check BW system
check _check_bw_system( ) = 'X'.
* check if any data is extracted
CHECK c_t_data IS NOT INITIAL.
CALL FUNCTION 'RSA1_SINGLE_OLTPSOURCE_GET'
EXPORTING
i_oltpsource = i_datasource
i_objvers = 'A'
IMPORTING
e_s_oltpsource = ls_oltpsource
EXCEPTIONS
no_authority = 1
not_exist = 2
inconsistent = 3
OTHERS = 4.
IF sy-subrc 0.
-
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
7/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 7
EXIT.
ENDIF.
* create data for Extract Structure
CREATE DATA lv_data TYPE TABLE OF (ls_oltpsource-exstruct).
ASSIGN lv_data->* TO .
ASSIGN c_t_data TO .
* get method name for datasource
lv_method = i_datasource.
IF lv_method(1) = '0' or
lv_method(1) = '2'.
* shift by one character as methods can't start with a number
SHIFT lv_method.
ENDIF.
* check method is implemented
CHECK _check_method_exists( lv_method ) = 'X'.
CALL METHOD (lv_method)
EXPORTING
i_updmode = i_updmode
i_t_select = i_t_select
i_t_fields = i_t_fields
CHANGINGc_t_data =
c_t_messages = c_t_messages.
endmethod.
-
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
8/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 8
Create a new method and name it:_TEMPLATE_DATASOURCE.
Then click over the name of the new method and paste the following code:
method _TEMPLATE_DATASOURCE.
* Data Definition
* DATA: lth_vbak type hashed table of vbak
* with unique key vbeln,
* ls_vbak type vbak .
* FIELD-SYMBOLS: TYPE .
* Init
* Perform always a mass select into an internal table* SELECT * FROM VBAK INTO TABLE lth_vbak
* FOR ALL ENTRIES IN C_T_DATA
* WHERE VBELN = C_T_DATA_VBELN.
* map the data
* LOOP AT C_T_DATA ASSIGNING .
* READ TABLE lth_vbak into ls_vbak
* with table key vbeln = -vbeln.* if sy-subrc eq 0.
* -VKORG = ls_vbak-vkorg.
* !!! No MODIFY necessary as the field is changed immediatly in the
* internal table by using Field Symbols
* endif.
* ENDLOOP.
endmethod.
Define the properties of this method as static and public
-
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
9/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 9
At this point you have created the implementation class for the BADI RSU5_SAPI_BADI. That can be usedfor any extractor, standard or custom, to populate enhanced fields. And you have a template to build newenhancements for DataSources.
Result: You have created the methods needed to make enhancements of the datasources.
-
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
10/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 10
Creating a enhancemente of a datasource.
I will assume that you have enhanced the structure of the data source, and need to code to populate theenhanced fields of the structure.
Copy the method _TEMPLATE_DATASOURCE and rename it, with the same name of the datasource youwant to enhance. In case of standard datasource, omit the first character of the name (0 or 2).
ie. DataSource 2LIS_18_IOTASKMethod name: LIS_18_IOTASK
ie.
Declare on the code the structure to populate.
On the code, you have to declare the structure of the type of the enhancement sctructure ofyour data source, ie:
Trans: RSA6
As you see in the picture, the Extract Structure of the data source 2LIS_18_I0TASK is MC18I00TSK.
-
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
11/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 11
Declare:
FIELD-SYMBOLS: TYPE MC18I00TSK.
During the execution of the extraction process, when this method is called, the structure C_T_DATAwill bepopulated with packages of 100 records each time. So a loop must be declared to process these datapackages, as you see on the code examples bellow.
Bellow you have too examples of how to code your enhancement:
Here a simple way to populate the fields of the structure straight from the select:
method DS_FICA_VIEW_ZVDSFICACI.
FIELD-SYMBOLS: TYPE ZOXBND0152.
* map the data
LOOP AT C_T_DATA ASSIGNING .
SELECT SINGLE BETRH BETRW INTO (-BETRH, -BETRW)
FROM DFKKOP WHERE OPBEL = -OPBEL AND
OPUPW = -OPUPW AND
OPUPK = -OPUPK AND
OPUPZ = -OPUPZ.
ENDLOOP.
endmethod.
And here a slight more complex example, using some functions inside the code:
METHOD lis_18_i0task.
DATA: l_anw_stat_existing TYPE xfeld,
l_e_stsma TYPE jsto-stsma,l_line TYPE bsvx-sttxt,
l_user_line TYPE bsvx-sttxt,
l_stonr TYPE tj30-stonr.
*************************************************************************
* FIELD-SYMBOLS *
*************************************************************************
-
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
12/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 12
FIELD-SYMBOLS: TYPE MC18I00TSK .
*************************************************************************
* CONSTANTS *
*************************************************************************
CONSTANTS:
C_SPRAS TYPE SY-LANGU VALUE 'PT'.
*** Get the measures status, record by record
*** The DataSource loads a package of 100 records each time, then
*** we have to have a loop to process then.
LOOP AT c_t_data ASSIGNING .
*** Function measure status
CALL FUNCTION 'STATUS_TEXT_EDIT'
EXPORTING
client = sy-mandtflg_user_stat = 'X'
objnr = -objnr
only_active = 'X'
spras = c_spras
bypass_buffer = ' '
IMPORTING
anw_stat_existing = l_anw_stat_existing
e_stsma = l_e_stsma
line = l_line
user_line = l_user_linestonr = l_stonr
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
-zstssis = l_line.
-ZSTSUSU = L_USER_LINE(4).
*** SEARCH THE STRING 'ANUL'
search l_user_line for 'ANUL'.
IF sy-subrc = 0.
-zflanu = 'ANUL'.
ENDIF.
-
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
13/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 13
ENDIF.
ENDLOOP.
ENDMETHOD.
Go to the transaction RSA3 and test your data source.
-
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
14/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 14
Conclusion:
With this new method of creating enhancements, SAP makes available a more clear and effitient way toenhance datasources.
I hope this article be useful to help you to enhance standard, or develop this own datasources, using thisnew feature.
Flvio A. Peres
BW Senior Consultant.
flavio.amoedo@gmail.com
flavio_amoedo@yahoo.com.br
mailto:flavio_amoedo@yahoo.com.brmailto:flavio_amoedo@yahoo.com.brmailto:flavio_amoedo@yahoo.com.br -
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
15/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 15
Related Content
Note 691154 - SAPI with BADI: User exits in SAPI with BADI-interfaces
How to... Create a Generic Data Extractor
https://service.sap.com/sap/support/notes/691154https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/84bf4d68-0601-0010-13b5-b062adbb3e33https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/84bf4d68-0601-0010-13b5-b062adbb3e33https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/84bf4d68-0601-0010-13b5-b062adbb3e33https://service.sap.com/sap/support/notes/691154 -
5/26/2018 Enhancing BW Datasources Through BADI - RSU5_SAPI_BADI
16/16
Enhancing DataSources with BAdI RSU5_SAPI_BADI
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
2007 SAP AG 16
Disclaimer and Liabili ty Notice
This document may discuss sample coding or other information that does not include SAP official interfacesand therefore is not supported by SAP. Changes made based on this information are not supported and canbe overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or methodssuggested in this document, and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content ofthis technical article or code sample, including any liability resulting from incompatibility between the contentwithin this document and the materials and services offered by SAP. You agree that you will not hold, orseek to hold, SAP responsible or liable with respect to the content of this document.
top related