Sorting home made BADI
Hi,
Recently I am involve in a very big project and we are discussing ways to code in old fashion user exit (form exit ,functions).
One of the options is to use BADI within the enhancement framework .
I became aware of this idea from A framework for local/region specific requirements in user-exits using BAdIs and the new enhancement framework (revisited). by Bruno Esperança
This small blog post will present an idea how to sort the BADI implementation prior to execution.
For code See attache program Y_R_EITAN_TEST_51_18
The basis of the idea is based on the fact that internal table IMPS that contains the implementations is public.
In the BADI interface we can create a method that will give the implementation the option to return its sorting value .
FORM test_01 is “regular” call .
And the result:
FORM test_02 is “sorted” call .
From each implementation we get the result of get_sort_value to create the a sorting table .
We sort the implementation in descending order .
And the result:
It seems to be working .
Mind you that this sorting code was not tested in actual production environment .
Regards.
Hi,
May I ask why do you need to sort the implementations?
Anyway,
You have a standard way to achieve it:
For new BAdI, you have in the BAdI implementation a dedicated field called "Layer of a BAdI Implementation" (Data element /DBM/OE_ENHBADI_IMPL_LAYER_D) by default.
For classic BAdI you might need to work a little harder and first explicitly activate the sorting option via SE18 -> Utilities -> Sort (read further details in SAP Help). Then you should have a similar field in the BAdI implementation (SE19).
Hi,
I have no need for sorting at the moment.
I am on on ecc6 .
Maybe I missed that but I do not see any sort under ....
My phone is public can you call me please.
Regards.
You should see it.
This option is available in NW 7.0 (or earlier).
Hi,
Thi is what I have:
Found this:
See at the bottom..... 😕
This SORT feature is supported for classical BAdIs only. The one that you have defined is a Kernel BAdI and it can be sorted by BADI_SORTER only.
Suhas,
It seems you are right.
For some reason, I thought that this is default behaviour in new BAdI, but it seems it depends on implementation of BADI_SORTER.
Very valuable and helpful.
Thanks for sharing this Eitan!
Best regards,
Bruno
Hi Eitan,
Please could you share the code of Y_R_EITAN_TEST_51_18..is it available on github.
Thanks,
Subba
Hi,
I am retired now.
I do have some code at home.....
Thanks Eitan!!
Appreciate your response and surely trying your approach.I have a question...I have noticed in userexits like MV45AFZZ lot of global data is accessed and assigned to field symbols...
any suggestion on how to handle that in Object oriented way...do we need to handle them as a dynamic method without naming parameters
Regards,
Subba
Hi,
I have no access to any SAP system, so I am not qualified to answer.
I play a lot with Java these days....
Regard.