Badi - Sorter With Kernel Badi and Other Sorting Options
Badi - Sorter With Kernel Badi and Other Sorting Options
sorting options
Was trying to figure out how to implement BADI_SORTER to guarantee the
implementation sequence for the new kernel BADI. Searched SCN and other blogs and
could not get any information. So decided to do a self help and help others with this
blog.
In the enh spot, a BADI is defined by the name ‘DEMO_BADI‘ with an interface as
shown.
SAP doesn’t guarantee the sequence of implementations. However SAP has provided a
BADI called BADI_SORTER to achieve the order sequence.
The BADI has a interface with the following methods. The 3 major ones are marked
below.
The main central method is the SORT_IMPLS where the multiple implementations are
put in the sequence order.
How the sequence order is putforth? A subscreen with a input field takes an integer
value. The BADI_SORTER has a screen enhancement which calls up our subscreen
(with input field for sequence). This additional subscreen is then visible as shown below.
The layer value is nothing but the input order sequence.
Its quite simple. All you have to do is copy an SAP standard program(function group +
screen) to your target and use it.
The function group(Function Modules + Screen) are used to pass the input screen value
to the BADI_SORTER
Ok Implement the BADI – BADI_SORTER.
( The “How to implement BADI” details are not covered here as it is an pre-requisite to
this blog )
During the implementation process, if asked for the below screen, click on Copy sample
class. The Implementation class shall the have the coding of the example
implementation class CL_BADI_SORTER_LAYER.
Save the enhancement implementation at this point.
The use of function modules logic are very similar to a BADI screen logic which is used
to add additional subscreen to an SAP standard screen.
Enter the function group main program below and subscreen as 2000. Save so far
done.
Go to Sort Implementation class and double click on the
IF_BADI_SORTER~PUT_DATA_TO_SCREEN. Call the FM that was created above.
The Sort Implementation is ready. This implementation shall be called when we activate
our DEMO_BADI multiple implementation’s.
Its time to have a quick test and check. Go back to our BADI implementation in change
mode and double click on the implementation and enter a sort integer value.
Before proceeding further, set a break point in the Sort Implementation method
SORT_IMPLS. The debugger will display the sorting order of the 3 implementations at
line 21.
Click Save and Activate. The debugger should stop again.
Click Save and Activate. The debugger should stop at line 21 of SORT_IMPLS if
its set.
During Activation, the implementation sorting’s happen at line no 21. Observe how
sorting takes place in the SORT_IMPLS method.
Another approach for Sorting implementations is via Filter Type except that this is for
Custom Kernel BADI’s. The reason being
For Custom Kernel BADI, you can something like this to sort the implementation
sequence.
Here the 1st Implementation shall be called. Passing “SECOND” as filter values will
trigger 2nd Implementation.