BADI Data Source Activation and Enhancement Process
BADI Data Source Activation and Enhancement 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.
->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 :-
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.
1) Go to SE18 -> BADI Builder - To create enh spot and Enh Badi.
SE19 -> Edit and create new BADI.
Actual code will be written between "method" and "endmethod" Data Transform.
CASE I_DATASOURCE
WHEN '2LIS_11_VAHDR'.
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.
New Syntex - FIRST provdie name of table th fields )fields a~ etc etc and every
variable has to be prefix with "@" to identify it.
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_
METHOD LIS_11_VAHDR.
*Method for 2lis_11_vahdr
*Copied from the _templete_Datasource
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.
Continue---
Continue
below code..
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
if sy_subrc <> 0.
message id sy-msgid....
......
ENDMETHOD.
ENDIF.
LV_METHOD = I_DATASOURCE.
*Do Nothing
ENDCASE.
GET "DATA_TRANSFORM" METHOD copy from class and paste and modify as below
reuirement.
...
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.