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

passing select-options to class methods

Former Member
0 Likes
16,516

Hi,

I want to pass a select-option filled in the selection screen by the user to a method of my class. Since select-options are hold as an internal table with fields sign option low high, and passing internal tables to methods require typing, what should I write as the name of this internal table type?

For example;

select-options: so_carid for spfli-carrid.

I want to pass the contents of so_carid to my method defined in a class

1 ACCEPTED SOLUTION
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
7,908

Hi,

Create a table type for the SAME Data element that you use for your SELECT-OPTIONS.

1)Goto Se11-> Select Datatype-> Enter the name.

2) Click create select Table type in the dialog.

3) Enter the description for the tabletype.

4) Use menu Edit->Define as ranges table type.

5) Then give the Data element name there.

Then use this TABLE TYPE as your methods IMPORTING parameter's TYPE.

Regards,

Sesh

Hi,

Create a table type for the SAME Data element that you use for your SELECT-OPTIONS.

1)Goto Se11-> Select Datatype-> Enter the name.

2) Click create select Table type in the dialog.

3) Enter the description for the tabletype.

4) Use menu Edit->Define as ranges table type.

5) Then give the Data element name there.

Then use this TABLE TYPE as your methods IMPORTING parameter's TYPE.

Regards,

Sesh

11 REPLIES 11
Read only

Former Member
0 Likes
7,908

hI

Triggering and Handling events

At the moment of implementation, a class defines its:

Instance events (using the EVENTS statement)

   Static events (using the CLASS-EVENTS statement)

Classes or their instances that receive a message when an event is triggered at runtime and want to react to this event define event handler methods. Statement: METHODS

CLASS IC1_VEICHLE DEFINATION.

PUBLIC SECTION.

METHOD CONSTRUCTOR IMPORTING

EVENTS VEICHEL_CREATION.

ENDCLASS

CLASS LC1_VEICHLE IMPLIMENTATION.

METHOD CONSTRUCTOR

RAISE EVENT VEICHLE_CREATION.

REWARD IF USEFULL

Read only

0 Likes
7,908

Thanks for your answer. Unfortunately I couldn't establish the link between events and passing the parameters.

Can you send a very simle working example?

I just want to populate an internal table in a class using the restrictions taken from the select-options.

Read only

0 Likes
7,908

Hi Ferhat..

You cannot pass Select-options directly to a Method .

Bcoz ABAP Objects does not support internal table with Header line.

Select-options will create an internal table with Header line.

So you can declare another itab to store the select options

using the Data type.

DDSHSELOPT

then pass it to the method.

<b>reward if Helpful</b>

Read only

Former Member
0 Likes
7,908

Hi Ferhat,

- define a tabletype object in the DDIC (SE11)

- go via menu EDIT -> Define as Range Table Type

- enter CARID as data element.

As method input parameter refer to that tabletype object

Then you can call your method:

zcl_my_class=>my_method( EXPORTING it_carid = so_carid[] ).

Didn't test it yet, but I think this works.

Regards, Uwe

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
7,909

Hi,

Create a table type for the SAME Data element that you use for your SELECT-OPTIONS.

1)Goto Se11-> Select Datatype-> Enter the name.

2) Click create select Table type in the dialog.

3) Enter the description for the tabletype.

4) Use menu Edit->Define as ranges table type.

5) Then give the Data element name there.

Then use this TABLE TYPE as your methods IMPORTING parameter's TYPE.

Regards,

Sesh

Read only

0 Likes
7,908

Hi Sesh,

too late

Uwe

Read only

0 Likes
7,908

Forgive me for interrupting

but it also asks a structured row type for the range table.

How am I going to deal with it?

Read only

0 Likes
7,908

Hi,

Then you need to create the ROW TYPE , that is nothing but a Structure.

In SE11 when you are creating the table type using Edit->Define as ranges tabletype after entering the Data element, enter some name in the field "Structred row type" and click create and then activate the structure and come back to table type and activate it.

After this you can use this table type.

@Uwe: Both of us missed out mentioning the ROW-TYPE.

Regards,

Sesh

Read only

0 Likes
7,908

Hi Uwe,

Its important to see that we address all the problems of the poster ;-).

Regards,

Sesh

Read only

0 Likes
7,908

Hi Sesh,

yes, you're right !

Like I said before, I didn't test the function yet. I only recognized this new ranges table type from Toms and Richs new book (and I haven't got the book in my customers office).

Uwe

Read only

uwe_schieferstein
Active Contributor
0 Likes
7,908

Hello Ferhat

There is a very elegant indirect way available to pass your select-options to class methods. Have a look at thread

Regards

Uwe