BW/4HANA Datasource Enhancement
- LO Cockpit DS activation.
- LO Cockpit DS Enhancement RSU5_SAPI_BADI
What is BADI?
BADI stands for business addin.
It is based on Object Oriented Programming model in ABAP.
BADI consists of Interfaces and classes.
Interface is a collection of empty methods.
Class contains logic for implementing those methods.
LO Cockpit:
Transaction LBWE is still relevant in BW/4HANA
Datasource Activation Procedure:
- Go to transaction RSA5 to activate the standard datasource
- Go to transaction RSA6 to check, save and generate the datasource
- Transaction LBWE (LO Cockpit)
- Maintain extract structure
- Maintain datasource
- Select delta mechanism (queued delta or direct delta or unserialized V3)
- Schedule V3 jobs
4. Delete set up tables (transaction LBWG)
5. Fill set up tables (transaction OLI*BW)
6. If first time loading delta for the datasource, create dummy entry in ODQ by running the program RODPS_REPL_TEST
7. Release the datasource for ODP
- For SAP Standard datasources run the program BS_ANLY_DS_RELEASE_ODP
- ROOSATTR table: Flag should be 'X' for the datasource.
- Standard datasources in S4HANA will automatically will be exposed (For ECC or ECC on HANA, you have to expose the standard datasources manually)
- For custom datasources, run the program RODPS_OS_EXPOSE to expose them to ODP
8. For enhancing the extract structure (MCVBAK)
Extract structure is the list of fields transferred to BW. Communication structure can be seen in LO cockpit for an application is the fields in the parent structure.
9. The fields can be added from the communication structure to the extract structure
10. Write the logic to populate the value of the newly added fields via BADI (RSU5_SAPI_BADI)
11. Test the logic in RSA3 transaction code.
Datasource Enhancement
Steps:
- Check in communication structure if the field is present (transaction LBWE)
- If yes, first deactivate the datasource, then add the field in the extract structure, reactivate the datasource
- Write the code to populate the new field in extract structure using BADI
- Traditionally enhancement was done in transaction CMOD
Transaction data | exit_saplrsap_001 |
Attributes | exit_saplrsap_002 |
Texts | exit_saplrsap_003 |
Hierarchies | exit_saplrsap_004 |
- As of SAP_BASIS 6.20 and PI_BASIS 2004_1 (R/3 Release 4.6C), a new way is available to enhance a standard datasources which is a more efficient way to enhance 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.
- There are two ways to enhance the datasource using BADI-
- Each datasource is implemented as a separate BADI implementation and Z Class.
- Each datasource is implemented as a separate method within the same implementation and class.
- Declare the variables
- Declare Field Symbol for extract structure
- Check if C_T_DATA is not initial.
- Get details of datasource (RSA1_SINGLE_OLTPSOURCE_GET)
- If no details fetched, then exit.
- Create data for extract structure
- Get Method Name from datasource.
- Remove the first character.
- Call the datasource method.
Important variables to remember
C_T_DATA: This is where the datasource stores all the extracted data.
I_DATASOURCE: This stores the name of the datasource.
Code Blocks
- Enhancing MCVBAK
@EndUserText.label : 'Adding Material Attributes'
@AbapCatalog.enhancementCategory : #EXTENSIBLE_CHARACTER_NUMERIC
extend type mcvbak with zmat_attr {
mtart : mtart;
name1 : name1;
land1 : land1;
}
- Datasource specific ZCLASS
class ZCL_IM_ZRSU5_2LIS_11_VAHDR definition
public
final
create public .
public section.
interfaces IF_EX_RSU5_SAPI_BADI .
protected section.
private section.
ENDCLASS.
CLASS ZCL_IM_ZRSU5_2LIS_11_VAHDR IMPLEMENTATION.
method IF_EX_RSU5_SAPI_BADI~DATA_TRANSFORM.
* FIELD-SYMBOLS: <ls_data> TYPE mc11va0hdr.
*
* CASE i_datasource.
* when '2LIS_11_VAHDR'.
*
* LOOP AT C_T_DATA ASSIGNING <ls_data>.
*
* SELECT from kna1 as a
* FIELDS a~name1, a~land1
* where a~kunnr = @<ls_data>-kunnr
* into ( @<ls_data>-name1, @<ls_data>-land1 ).
* ENDSELECT.
*
* ENDLOOP.
*
* WHEN OTHERS.
** Don't do anything'
*
* endcase.
endmethod.
method IF_EX_RSU5_SAPI_BADI~HIER_TRANSFORM.
endmethod.
ENDCLASS.
- Common ZClass
Class Complete code
class ZCL_IM_ZRSU5_BW_EXTRACTION definition
public
final
create public .
public section.
interfaces IF_EX_RSU5_SAPI_BADI .
class-methods _DATASOURCE_TEMPLATE
importing
value(I_DATASOURCE) type RSAOT_OLTPSOURCE
value(I_UPDMODE) type SBIWA_S_INTERFACE-UPDMODE
value(I_T_SELECT) type SBIWA_T_SELECT
value(I_T_FIELDS) type SBIWA_T_FIELDS
changing
!C_T_DATA type ANY TABLE
!C_T_MESSAGES type RSU5_T_MESSAGES optional
exceptions
RSAP_BADI_EXIT_ERROR .
**********************************************************************
*Definition for 2LIS_11_VAHDR
**********************************************************************
class-methods LIS_11_VAHDR
importing
value(I_DATASOURCE) type RSAOT_OLTPSOURCE
value(I_UPDMODE) type SBIWA_S_INTERFACE-UPDMODE
value(I_T_SELECT) type SBIWA_T_SELECT
value(I_T_FIELDS) type SBIWA_T_FIELDS
changing
!C_T_DATA type ANY TABLE
!C_T_MESSAGES type RSU5_T_MESSAGES optional
exceptions
RSAP_BADI_EXIT_ERROR .
**********************************************************************
*Definition for 2LIS_11_VAITM
**********************************************************************
class-methods LIS_11_VAITM
importing
value(I_DATASOURCE) type RSAOT_OLTPSOURCE
value(I_UPDMODE) type SBIWA_S_INTERFACE-UPDMODE
value(I_T_SELECT) type SBIWA_T_SELECT
value(I_T_FIELDS) type SBIWA_T_FIELDS
changing
!C_T_DATA type ANY TABLE
!C_T_MESSAGES type RSU5_T_MESSAGES optional
exceptions
RSAP_BADI_EXIT_ERROR .
**********************************************************************
*Definition for 2LIS_11_VAKON
**********************************************************************
class-methods LIS_11_VAKON
importing
value(I_DATASOURCE) type RSAOT_OLTPSOURCE
value(I_UPDMODE) type SBIWA_S_INTERFACE-UPDMODE
value(I_T_SELECT) type SBIWA_T_SELECT
value(I_T_FIELDS) type SBIWA_T_FIELDS
changing
!C_T_DATA type ANY TABLE
!C_T_MESSAGES type RSU5_T_MESSAGES optional
exceptions
RSAP_BADI_EXIT_ERROR .
class-methods LIS_02_HDR
importing
value(I_DATASOURCE) type RSAOT_OLTPSOURCE
value(I_UPDMODE) type SBIWA_S_INTERFACE-UPDMODE
value(I_T_SELECT) type SBIWA_T_SELECT
value(I_T_FIELDS) type SBIWA_T_FIELDS
changing
!C_T_DATA type ANY TABLE
!C_T_MESSAGES type RSU5_T_MESSAGES optional
exceptions
RSAP_BADI_EXIT_ERROR .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS ZCL_IM_ZRSU5_BW_EXTRACTION IMPLEMENTATION.
METHOD if_ex_rsu5_sapi_badi~data_transform.
DATA: ls_OLTPSOURCE TYPE rsaot_s_osource,
lo_data TYPE REF TO data,
lv_method TYPE seocmpname.
FIELD-SYMBOLS: <lt_data> TYPE STANDARD TABLE.
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.
EXIT.
ENDIF.
CREATE DATA lo_data TYPE TABLE OF (ls_oltpsource-exstruct).
ASSIGN lo_data->* TO <lt_data>.
ASSIGN c_t_data TO <lt_data>.
* Get method name
lv_method = i_datasource.
CASE lv_method(1).
WHEN '0' OR '2'.
SHIFT lv_method.
WHEN OTHERS.
* Do Nothing
ENDCASE.
* Call the datasource specific method
try.
CALL METHOD (lv_method)
EXPORTING
i_datasource = i_datasource
i_updmode = i_updmode
i_t_select = i_t_select
i_t_fields = i_t_fields
CHANGING
c_t_data = <lt_data>
c_t_messages = c_t_messages.
CATCH cx_sy_dyn_call_illegal_method.
ENDTRY.
ENDMETHOD.
METHOD if_ex_rsu5_sapi_badi~hier_transform.
ENDMETHOD.
METHOD LIS_02_HDR.
**********************************************************************
* Copy this template 2LIS_02_HDR method and
* implement the code according to the requirement
* Don't change the code here.
**********************************************************************
FIELD-SYMBOLS: <ls_data> TYPE mc02m_0hdr.
LOOP AT c_t_data ASSIGNING <ls_data>.
SELECT FROM ekko AS a
FIELDS a~zterm, a~inco1, a~procstat
WHERE a~ebeln = @<ls_data>-ebeln
INTO ( @<ls_data>-zzterm, @<ls_data>-zzico1, @<ls_data>-zzprocstat ).
ENDSELECT.
SELECT FROM ekpa AS b
FIELDS b~lifn2
WHERE b~ebeln = @<ls_data>-ebeln
INTO ( @<ls_data>-zzlifn2 ).
ENDSELECT.
ENDLOOP.
ENDMETHOD.
METHOD lis_11_vahdr.
**********************************************************************
*Logic for 2LIS_11_VAHDR
**********************************************************************
FIELD-SYMBOLS: <ls_data> TYPE mc11va0hdr.
LOOP AT c_t_data ASSIGNING <ls_data>.
SELECT FROM kna1 AS a
FIELDS a~name1, a~land1, a~regio
WHERE a~kunnr = @<ls_data>-kunnr
INTO ( @<ls_data>-name1, @<ls_data>-land1, @<ls_data>-regio ).
ENDSELECT.
ENDLOOP.
ENDMETHOD.
METHOD lis_11_vaitm.
**********************************************************************
*Logic for 2LIS_11_VAITM
**********************************************************************
FIELD-SYMBOLS: <ls_data> TYPE mc11va0ITM.
LOOP AT c_t_data ASSIGNING <ls_data>.
SELECT FROM mara AS a
FIELDS a~mtart
WHERE a~matnr = @<ls_data>-matnr
INTO ( @<ls_data>-mtart ).
ENDSELECT.
ENDLOOP.
ENDMETHOD.
METHOD lis_11_vakon.
FIELD-SYMBOLS: <ls_data> TYPE mc11va0kon.
LOOP AT c_t_data ASSIGNING <ls_data>.
SELECT FROM mara AS a
FIELDS a~magrv
WHERE a~matnr = @<ls_data>-matnr
INTO ( @<ls_data>-magrv ).
ENDSELECT.
ENDLOOP.
ENDMETHOD.
METHOD _datasource_template.
**********************************************************************
* Copy this template datasource method and
* implement the code according to the requirement
* Don't change the code here.
**********************************************************************
* FIELD-SYMBOLS: <ls_data> TYPE mc11va0hdr.
*
* LOOP AT c_t_data ASSIGNING <ls_data>.
*
* SELECT FROM kna1 AS a
* FIELDS a~name1, a~land1
* WHERE a~kunnr = @<ls_data>-kunnr
* INTO ( @<ls_data>-name1, @<ls_data>-land1 ).
* ENDSELECT.
*
* ENDLOOP.
ENDMETHOD.
ENDCLASS.
Comments
Post a Comment