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

Generic CLASS parameters

Former Member
0 Likes
1,525

Hi,

I have a function module with a TABLE parameter with generic type TABLE.

I have to pass these table parameter to a method in the class, then what should be the type of the corresponding parameter inside my class.

Regards,

Anoop

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
0 Likes
1,031

<b>STANDARD TABLE</b> should work from a function module table param. Otherwise <b>ANY TABLE</b>

If your function module table parameter is "<b>mytab</b>", you may have to call the method using <b>mytab[].</b>

matt

3 REPLIES 3
Read only

matt
Active Contributor
0 Likes
1,032

<b>STANDARD TABLE</b> should work from a function module table param. Otherwise <b>ANY TABLE</b>

If your function module table parameter is "<b>mytab</b>", you may have to call the method using <b>mytab[].</b>

matt

Read only

Former Member
0 Likes
1,031

As if now i had passed mytab from fn mod to the method.

Now i have to assign it to a class attribute

Could u please guide me to create a class attribute with generic type to assign this value.

[I have tried to create a class attribute with type STANDARD TABLE but it shows error msg like Generic type not possible for class attribute...]

Read only

matt
Active Contributor
0 Likes
1,031

Ah, you can't create a generic class attribute. But you <b>can</b> create a data reference to a generic object.

Instead of creating an attribute "mytab", create an attribute that is a reference to data,e.g. <b>ref_mytab</b>, of type REF TO DATA.

In your method, where you've received the table through the parameters (e.g. it_mytab TYPE STANDARD TABLE ), do this:

GET REFERENCE OF it_mytab INTO ref_mytab.

Whenever you need to do something with the table, do this:

FIELD-SYMBOLS: <mytab> TYPE STANDARD TABLE.
ASSIGN ref_mytab->* TO <mytab>.

matt