Application Development and Automation 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: 
Read only

substitute function module with OO method

Former Member
0 Likes
1,724


Hello,

is it possible to substitute a function module with OO-method? If yes are there any examples how this could work?

Many thanks in advance.

Ella

13 REPLIES 13
Read only

FredericGirod
Active Contributor
0 Likes
1,579

Hi Ella,

please specify if you speak about specific code or if you are searching for an Oo method that replace a useful function.

regards

Fred

Read only

0 Likes
1,579

Hello Fred,

I'd like to substitute the code in the include EXIT_SAPLRSAP_001 of FM EXIT_SAPLRSAP_001 with a Oo method.

Kind regards

Ella

Read only

0 Likes
1,579

Ella,

when you use user-exit, you use not Oo, you have to use FM.

If you want to play with Oo you have to use BADI. You could find your BADI using SE18 transaction and create a new implementation using SE19

CMOD / SMOD -> FM

SE18/SE19 -> Oo

regards

Fred

Read only

0 Likes
1,579

Fred,

I can't generate a class and method and call it in the function module? Why not?

kind regards

Ella

Read only

0 Likes
1,579

Why ?

if you want to have multi implementation of your code you could create include with FORM inside. and in the include of the function made a PERFORM ... IN PROGRAM ...  IF FOUND

so if you have problem with multi code and multi abapor you will not break your productive system ..

is it your problem ?

Fred

Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes
1,579

Sure you can. In EXIT_SAPLRSAP_001 in its "Z" include you can code any implementation you want. You can create global class and call its methods there without problem

For example:

CASE I_DATASOURCE

     WHEN 'Z1'.

          zcl_abc=>z1( EXPORTING data_you_need_work_with ).

     WHEN 'Z2'.

          zcl_abc=>z2( EXPORTING data_you_need_work_with ).

ENDCASE.

But not sure if static calls are good for this use.

-- Tomas --
Read only

0 Likes
1,579

I know there is more than one way to skin a cat. And our solution should be with classes and methods. I know this is not the prevalent solution. Are there any technical criteria which speak against this?

Ella

Read only

0 Likes
1,579

Hi Tomas,

thanks for your reply. I have a further question: How could I define the tables of the tab "tables" to the method? 

Thanks and kind regards

Ella

Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes
1,579

In method you can define it either as Importing, Exporting, Changing or Returning parameter. And TYPE parametr as "table type".

Which can be defined more ways:

- in DDIC (SE11) data type "Table type"

- in class itself, there is Types tab in SE24 (direct type entry) or in code of class definition:

TYPES: tt_sometable TYPE TABLE OF structure.

-- Tomas --
Read only

former_member227140
Active Participant
0 Likes
1,579

Hi,

If there is no class and method which suits your requirement then,

you can create a custom class in se24 and method . you can define your code in method and then you can call class and method in the program.

Read only

former_member227140
Active Participant
0 Likes
1,579

whats the reason you want to do that???

Read only

0 Likes
1,579

With the realized solution we have problems with transport and if the code is incorrect all extractors can't be loaded. I know there is a possibility to create for every extractor an own function module. But my boss want to have a solution with classes and methods.

Read only

Former Member
0 Likes
1,579

Hi Ella,

1 ) Create a custom BADI with class and interface.

2) The class whould have the method with similar code as that of FM.

3) Create BADI implementation

4) Create an include in the user EXIT.

5) Inside the include call the BADI by GET BADI and invoke the required method.

Thanks

Saurabh