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: 

Passing select-options value in method

Former Member
0 Kudos

How to pass select-options value in method ?

Example:

Select-options: carrid for spfli-carrid.

class cl_myclass implementation.

select carrid connid from

spfli where carrid in carrid.

endclass.

Thanks

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

Hello Anee

The easiest (and probably most elegant) way is to use function module RS_REFRESH_FROM_SELECTOPTIONS.

In the CONSTRUCTOR method of your class you add an EXPORTING parameter IM_CALLING_PROGRAM.

Within the CONSTRUCTOR method you call the function module with the value of the calling program (which is your selection report). The function module returns you all current selection criteria of the report.

Have a look at class CL_DBSEL_CATS for a SAP standard example.

Regards

Uwe

4 REPLIES 4

uwe_schieferstein
Active Contributor
0 Kudos

Hello Anee

The easiest (and probably most elegant) way is to use function module RS_REFRESH_FROM_SELECTOPTIONS.

In the CONSTRUCTOR method of your class you add an EXPORTING parameter IM_CALLING_PROGRAM.

Within the CONSTRUCTOR method you call the function module with the value of the calling program (which is your selection report). The function module returns you all current selection criteria of the report.

Have a look at class CL_DBSEL_CATS for a SAP standard example.

Regards

Uwe

0 Kudos

THANKS A BUNCH

0 Kudos

Hi Uwe,

I am not getting that sample standard class.

Please give me an example where you are population data in method from Select-options.

Thanks

Anee

0 Kudos

Hello Anee

The coding of this functionality is quite simple:


REPORT zmy_report.


DATA:  go_myclass   TYPE REF TO zcl_myclass,
           gd_repid         TYPE syst-repid.



PARAMETERS:
  p_bukrs   ...

SELECT-OPTIONS:
  o_kunnr  ...


START-OF-SELECTION.

  gd_repid = syst-repid.

  CREATE OBJECT go_myclass
    EXPORTING
      id_calling_program = gd_repid.
...

And that's how your CONSTRUCTOR method should look like:


METHOD constructor.  " IMPORTING parameter id_calling_program

CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
  EXPORTING
    CURR_REPORT = id_calling_report
  TABLES
    SELECTION_TABLE = me->mt_selopts.

" NOTE: define mt_selopts as instance attribute of table type RSPARAMS_TT
  

ENDMETHOD.

Finally you have to extract the parameter and select-options from MT_SELOPTS.

Regards

Uwe