BADI Data Source Activation and Enhancement Process

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 6

Data Source Activation Process:-

Note -
CNTRL +Shift + A to search Objects in ABAP S4 Eclips
CNTRL + Space - Very useful in CDS
CNTRL + S -> To Save
CNTRL + F -> To See consistencies or Warning
CNTRL + F3 -> To Activate

When ever work with s4 hana always work with ABAP dev
when ever work with b4 hana always work with B4 modeling unless structure.

1) RSA5 - Activation (2LIS_11VAHDR)


2) RSA6 - Check,Save and Generate - Change -> Do Selection,Hide,Inversion,Field
Only as per your require
3) LBWE (LO Cockpit)
1. Maintain Extract Structure
2. Maintain Datasource
3. Activate the Delta Mechanism
4. Delete Setup Table
5. Dummpy Entry in ODQ - Delta Subsripction
PGM: RODPS_REPL_TEST
6. Fill setup table
7. Check data(RSA3)

4) Release the Datasource for ODP


1. SAP Standard Datasources - BS_ANLY_DS_RELEASE_ODP
a. Table -> ROOSATTR and check flag should be "X"
2. Standard Datasources only for S4 will Automatically be exposed as ODP
Extractor.
For ECC/ECC on HANA , you'll have to expose even the standard datasources.
3. Custom Datasources - RODPS_OS_EXPOSE.

5)Enhance the Structure (MCVBAK)


1.Extract Structure - The list of fields which get transferred to BW
2.Communication Structure - For LO Cockpit , List of fields in the Parent
Structure.
6) Add the newly added field from Communication Structure to Extract Structure.
7) Write the logic to populate the values for new field via BADI (RSU5_SAPI_BADI)
8) RSA3 - Test the Logic.

**How to Check your strcuture in Enhanched ?


Just got o your structure exp-MCVBAK and press F5 for Refresh.
In 3rd line -> before define structure MCVBAK { ,you will see small icon to check
whether any enhancement has been taken placed or not. -> Click on that Icon.

->Anothe way to check clik on stucture -> MCVBAK and press F2 -> It will give you
list of fields.
In bottowm you will have one icon ->by clicking iot you will see fields by
structure or structures by fields (Check out Options).

If you want to feel /see SAP GUI (Old type) screen , right click on structure and
select Open with -> SAP GUI.

BADI :
Badi -> List of Interfaces.
Interface -> List of empty methods - Only Definition , No Implementation).
Implementin class for the Interface will be there.
Class which implements the methods of Interfaces.

Enhanchment Process :-

Enhancing DS with BADI RSU5_SAPI_BADI (Classic BADI).

2 Ways:-
(Inefficient way) - Each DS is implemented as a seprate BADI implementation
and Z Class - Multiple Implementation of BADI.
(Efficient way) - EACH ds IS IMPLEMENTED AS A seprtae method within the
same Implementation and Class.

2 most Important standard SAP given variables ->


C_T_DATA - This is where the DS stores all the extracted data.
I_DATASOURCE - This stores the name of the datasource.

Inefficient way for DS enh by BADI.

1) Go to SE18 -> BADI Builder - To create enh spot and Enh Badi.
SE19 -> Edit and create new BADI.

cREAT -> cLASSIC BADI NAME rsu5_sapi_badi


click create ZZRSU5_2LIS_11_VAHDR -> Go to Create.
Imp name and Imp short text. ->Save->Activate.
2) Copy Class name and find class into abap ->object and Click on that.
You will see in that class certain code will be added.
Interface has to be in public section -> automatically it will come correct.

Actual code will be written between "method" and "endmethod" Data Transform.

Declare field symbol ->

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~LAND1, A~NAME1
WHERE A~KUNNR = @<LS_DATA>-KUNNR
INTO (@<LS_DATA>-zLAND1 , @<LS_DATA>-zNAME1 ).

ENDSELECT.

If you do not mention case for data source, it will run for all data source and it
will get failed because field in Extract stru will not match with it.

Click F3 -> To Activate .

Fill setup tables to check enhanced fields' data.

New Syntex - FIRST provdie name of table th fields )fields a~ etc etc and every
variable has to be prefix with "@" to identify it.

Note: Prior to HANA version it was not suggested to do loop first.

With HANA no mendatory ,but Mendatory fro billions of data.

2) Efficent way to Enhance DS By BADI.


>We should create templete method for the developer to Copy from.
>Delclare the variables.
>Declare Field Symbol for extract structure
>Check if C_T_DATA is not initial
>Get details of darasource (Using FM RSA1_SINGLE_OLTPSOURCE_GET)
>If No Details fetched,then Exit.
>Create data for extract Structure.
>Get Method Name from Datasource.
>Remove the First Characters.
>Call the Datasource Method.

Step with explaination:-

>goto se19 ->create new implementation.


>Activate it -> see class name ZCL*
>GO TO SE24 to see class or direct search on esclips.
You can aslo find class in native esclips editer - CNTRL shift a and search by
Class name.
esclips right click on class and naviagate ->u will see data and hierarchy
transform editor.

1.We should create templete method for the developer to Copy from.
Se24 - enter class name and Edit it(change mode) - Paste mode and copy mode
activate.
Put curson on method and click copy-> come under blank data field and click on
Paste and save it as _TEMPLATE_DATASOURCE_ ->Warning of rename -> continue-
>Activate it Level - Static Method.(New Method)
Now when u lick on class ,there will be another method store as "templete data
source" and that copy will brought all the necessary code.
.
Req- enh 2LIS_11_VAHDR and
Goto se24-class name (common)-> write code under templete_DATASOURCE method in
code.
cOPY bELOW code.

mETHOD _Temp_datasource_

*****Commnet it****to do not execute**

**Templete method please do not modify


*copy this method for datasource specific

FIELD-SYMBOLS: <LS_DATA> TYPE MC11VA0HDR.

LOOP AT C_T_DATA ASSIGNING <LS_DATA>.


SELECT FROM KNA1 AS A
FIELDS A~LAND1, A~NAME
WHERE A~KUNNR = <LS_DATA>-KUNNR
INTO ( @<LS_DATA>-LAND1, @<LS_DATA>-NAME1 ).
ENDSELECT.

*****Commnet it****to do not execute**

Activate the Class

SE24->Class->Copy Tempalte_datasource and paste it with meaningful name and edit


it with require code.
naming conv. remove first char "LIS_11_VAHDR"
Edit ->Uncomment cpmmented code and mpifyt as per your requirement.
we use same code becuase requirement is same.
-

FIELD-SYMBOLS: <LS_DATA> TYPE MC11VA0HDR.

METHOD LIS_11_VAHDR.
*Method for 2lis_11_vahdr
*Copied from the _templete_Datasource

LOOP AT C_T_DATA ASSIGNING <LS_DATA>.

SELECT FROM KNA1 AS A


FIELDS A~LAND1, A~NAME
WHERE A~KUNNR = <LS_DATA>-KUNNR
INTO ( @<LS_DATA>-LAND1, @<LS_DATA>-NAME1 ).
ENDSELECT.
2.Delclare the variables--

Class ...
Method if_ex_rsu5_sapi_badi~data_transform.

Below Line :-

DATA: LS_OLTPSOURCE TYPE RSAOT_S_OSOURCE (sTRUCTURE WE WILL USE TO call FMor data
source)
LO_DATA TYPE REF TO DATA,
LV_METHOD TYPE SEOCMPNAME.

3.Declare Field Symbol for extract structure

Continue---

FIELD~SYMBOLS: <LT_DATA> TYPE STANDARD TABLE (generic enter require table)

4.Check c_t_data is initial

Continue
below code..

CHECK c_t_data is not initial.

5.Get details of darasource (Using FM RSA1_SINGLE_OLTPSOURCE_GET)


**get ds structure using standard FM**
CALL FUNCTION 'RSA1_SINGLE_OLTPSOURCE_GET' (
SHIFT ENTER to insert entire signature of FM or any object to native editor)

Code will look like after shift enter

EXPORTING
I_OLTPSOURCE = I_DATASOURCE
I_OBJVERS = 'A'
IMPORTING
E_S_OLTPSOURCE = LS_OLTPSOURCE **RETURN INTO THIS STRUCTURE**

EXCEPTIONS

no_authority = 1
not_exist = 2
inconsistent = 3
others =4

7.If No Details fetched,then Exit.

if sy_subrc <> 0.

message id sy-msgid....
......
ENDMETHOD.

ENDIF.

8.Create data for extract Structure.


Below code
*create data object using DS structure and Initialize the field Symbol**

CREATE DATA LO_DATA TYPE TABLE OF (LS_OLTPSOURCE-exstruct) **nOTE **tHIS HAS TO BE


YOUR data source EXTRACT STRUCTURE TYPE
assign lo_data->* to <lt_data>. **Assigning all structure to field symbol.
assign c_t_data to <lt_data>. **assig data to fild symbol

9.Get Method Name from Datasource.

***Get method name

LV_METHOD = I_DATASOURCE.

10.Remove the First Characters.

*gET METHOD NAME AND REMOVE THE 1ST DIGIT (0 OR 2) if applicable.


CASE LV_METHOD(1). **FIRST CHARACTER
WHEN '0' OR '2'
SHIFT LV_METHOD. (to compare it with give class name removed 0 and 2)
WHEN OTHERS.

*Do Nothing

ENDCASE.

11.Call the Datasource Specific Method.

**Call Data source specific Method

GET "DATA_TRANSFORM" METHOD copy from class and paste and modify as below
reuirement.
...

CALL METHOD (LV_METHOD)

Exporting
I_DATASOURCE = I_DATASOURCE
I_UPMODE = i_upmode
i_t_select = i_t_select
i_t_fields = i_t_fields

changing

C_T_DATA = <LT_DATA>
c_t_messages = c_t_messages.

endmethod.

Activate it.

You might also like