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: 

Regarding usage of select options in methods of a class

Former Member
0 Kudos

Hi Every body,

I have an issue regarding the usage of values from select-options in the methods of class. i dont know how to pass the values from select options as a parameter to the class method. i tried with ranges but it is skipping the single values in the select options. Thanks in adavance

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor

You are on right track.

Crate a Range Table Type

You can create it as


TYPES: TY_R_MATNR TYPE RANGE OF MARA-MATNR.

Now, use this type to define your parameter of your method


methods:
  get_data
    importing
      it_r_matnr type ty_r_matnr.

To pass your select-option you need to pass the internal table. Since Select-options are the internal table with Header line, you need to use this type of syntax to pass this select-option table to the method


select-options: s_matnr for w_mantr.
....
call metho lo_data->get_data
  exporting
    it_r_matnr = S_MATNR[].   "pass select-option with []s

Regards,

Naimesh Patel

3 REPLIES 3

MarcinPciak
Active Contributor
0 Kudos

I think you have two possibilities:

1) type parameter as SELOPT

2) define such type in public section of class.


TYPES t_rangetab TYPE RANGE OF your_type_or_field_here.

Now type your parameter as T_RANGETAB

Regards

Marcin

naimesh_patel
Active Contributor

You are on right track.

Crate a Range Table Type

You can create it as


TYPES: TY_R_MATNR TYPE RANGE OF MARA-MATNR.

Now, use this type to define your parameter of your method


methods:
  get_data
    importing
      it_r_matnr type ty_r_matnr.

To pass your select-option you need to pass the internal table. Since Select-options are the internal table with Header line, you need to use this type of syntax to pass this select-option table to the method


select-options: s_matnr for w_mantr.
....
call metho lo_data->get_data
  exporting
    it_r_matnr = S_MATNR[].   "pass select-option with []s

Regards,

Naimesh Patel

Former Member
0 Kudos

Thanks for the answers.

I have used the same way as you guys specified before it self but problem is with the single values in the select options are not considering in the above solutions. i have not tried with SELOPT. Any way i solved the problem temporarily by writing the code for selection screen before the local calss definition and used the select options variable directly in the method. i know this is not the efficient method. Any way thanks for the quick response.