01-26-2008 6:12 AM
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
01-26-2008 12:54 PM
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
01-26-2008 12:54 PM
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
01-27-2008 2:13 AM
01-30-2008 6:30 PM
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
01-30-2008 10:59 PM
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