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

In interface - method parameter with general type (ABAP OO)

hagit
Active Participant
0 Likes
3,007

Hello experts,

I am not familiar with ABAP object oriented so please advise.

I want to write an interface to validate a user input. The interface has to include a method (is_values_exist) with an importing parameter. The parameter is a table. Every class, which implements this interface, has to deal with a different type of the parameter table. For example, one has to send BUKRS, another has to send BELNR etc… The problem is that in the interface I cannot leave the type of the parameter empty. (As I can in a Function Module). A workaround could be - In the interface create a parameter for every class (one parameter will have the type of BUKRS, the other BELNR, etc…) . All the parameters have to be optional. Disadvantages of this solution are:

1. The interface has to be changed (a new parameter has to be added) for every new class, which implements it.

2. The parameter should not be optional (but mandatory).

Thanks in advance

Hagit

1 ACCEPTED SOLUTION
Read only

joltdx
Active Contributor
2,399

There are some options. Please refer to the documentation of 'generic datatypes':

https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abenbuilt_in_types_generic...

5 REPLIES 5
Read only

joltdx
Active Contributor
2,400

There are some options. Please refer to the documentation of 'generic datatypes':

https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abenbuilt_in_types_generic...

Read only

hagit
Active Participant
0 Likes
2,399

Thank you for your answer

Hagit

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,399

It's not related to Object-Oriented, but you have generic types like "TYPE STANDARD TABLE" (without OF ...)

Read only

keremkoseoglu
Contributor
2,399

Some suggestions:

  • You can pass any variable with TYPE REF TO DATA if it comes to that.
  • You can use the PropertyBag design pattern and pass an object containing all the values you want to pass - similar to a workflow container
  • You can pass an ITAB similar to the AUSP table, having distinct columns for distinct data types
  • I don't suggest it, but technically you can pass a JSON string containing all the values and parse it in the class
Read only

hagit
Active Participant
0 Likes
2,399

Thank you for your answer

Hagit