Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How could form routines in classic user exits be avoided?

BaerbelWinkler
Active Contributor
0 Kudos

This may be a stupid question, but a (quick) search didn't come up with an answer. jagdish.patil's blog post from earlier this year and the comments posted to it provide some pointers, but don't fit my particular case. So, here goes:

I recently had to apply changes to a typical userexit's Z-Include:

FUNCTION EXIT_SAPLV50E_003.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(I_DOCUMENT) LIKE RL50E-K_FLAG DEFAULT '2'
*" ....
*" CHANGING
*" VALUE(C_EXPORT_LINE_ITEM_DATA) LIKE EIPO
*" STRUCTURE EIPO DEFAULT ' '
*" ...
*"----------------------------------------------------------------------
INCLUDE ZXV50U03.
ENDFUNCTION.

The logic had thus far been added directly in ZXV50U03 and I wanted to a) create my new (small) logic in its own routine and b) move the existing code from the include into it's own routine. As I was working in the function module and user exit context I went the easy route and simply created new form routines which ended up in their own (new) include ZXV50F01 as is usually the case for these user exits. They now get called from within IF-statements which will make it possible to track how often they are executed via SCMON/SUSG:

IF i_sales_org EQ 'ABCD'.
PERFORM zz_determine_exart USING i_invoice_item
CHANGING c_exart.
ENDIF.

IF i_invoice_item-werks = 'ABCD'.
PERFORM zz_determine_verld USING i_invoice_item
CHANGING c_export_line_item_data-verld.
ENDIF.

Could I have easily avoided these PERFORMs and if so how? I just can't picture how working with classes and methods would look like in this particular context and how much "overhead" it would generate to set up. Especially given that I did this as part of a fairly quick code change and not some general clean-up task. In case, it's relevant, we are on NW 7.50 SP22.

Thanks much and cheers

Bärbel

4 REPLIES 4

FredericGirod
Active Contributor

Hi Bärbel,

for my point of view, if you want to use Class & method, you have to use a Design Pattern Factory and create for each block of logic their own class. It is more or less the logic used in the BADI.

In your example the code will be maybe complex, but it will help after some years with several changes.

BR

Fred

matt
Active Contributor
0 Kudos

This.
I instantiate and call a method. Where the same data is needed across multiple exists, then a singleton using get_instance might be in order.

Or I create a Z BADI.

Sandra_Rossi
Active Contributor
0 Kudos

Time to start with Test Driven Development? But of course lot of overhead when you start with TDD 😉

BaerbelWinkler
Active Contributor
0 Kudos

Good thing you added the smiley at the end, Sandra! No chance for TDD in our current environment as we basically have no ABAP OO in existing code. And given the issues I had when I tried to at least incorporate unit tests in parallel to doing development it's way too much of a time-hog to entertain TDD any time soon.