05-21-2007 11:06 AM
Hai friends,
Could u please tell me how to pass select-options as parameters to method of a class.
05-21-2007 11:26 AM
Hello Chitra
The easiest (and probably most elegant) way is to use function module <b>RS_REFRESH_FROM_SELECTOPTIONS</b>.
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 <b>CL_DBSEL_CATS</b> for a SAP standard example.
Regards
Uwe
05-21-2007 11:09 AM
05-21-2007 11:09 AM
Hi
You have to declare the select
options like
<b>DATA: l_kunnr TYPE STANDARD TABLE OF wselkunnr,</b>
see this example
&----
*& Report ZCL_TEST_ANJI
&----
REPORT zcl_test_anji.
TABLES kna1.
DATA: l_kunnr TYPE STANDARD TABLE OF wselkunnr,
l_kna1 TYPE STANDARD TABLE OF kna1,
l_sales TYPE STANDARD TABLE OF vbak,
l_cust TYPE kna1,
l_vbak TYPE vbak.
DATA: obj_cust TYPE REF TO zcl_test_anji.
SELECT-OPTIONS: s_kunnr FOR kna1-kunnr.
Start of Selection
START-OF-SELECTION.
CREATE OBJECT obj_cust.
SET HANDLER obj_cust->event_handler_1 FOR obj_cust.
SET HANDLER obj_cust->event_handler_2 FOR obj_cust.
l_kunnr[] = s_kunnr[].
CALL METHOD obj_cust->zcust
EXPORTING
s_cust = l_kunnr
RECEIVING
it_kna1 = l_kna1.
IF NOT l_kna1[] IS INITIAL.
LOOP AT l_kna1 INTO l_cust.
WRITE: / l_cust-kunnr, 12 l_cust-name1,
48 l_cust-ort01, 85 l_cust-land1,
95 l_cust-pstlz.
HIDE l_cust-kunnr.
ENDLOOP.
ENDIF.
At line Selection
AT LINE-SELECTION.
CASE sy-lsind.
WHEN 1.
CALL METHOD obj_cust->zso
EXPORTING
im_kunnr = l_cust-kunnr
RECEIVING
it_so = l_sales.
IF NOT l_sales[] IS INITIAL.
LOOP AT l_sales INTO l_vbak.
WRITE: / l_vbak-kunnr, 12 l_vbak-vbeln,
24 l_vbak-vkorg, 30 l_vbak-audat,
43 l_vbak-netwr.
ENDLOOP.
ENDIF.
ENDCASE.
<b>Reward points if useful</b>
Regards
Anji
05-21-2007 11:10 AM
You should be able to pass it as an itab, just declare a table type with the same fields as a select-option, and pass it to the method as a parameter.
Hope this helps.
Sudha
05-21-2007 11:14 AM
Hi chitra,
1. in the class methods, parameter,
it should be of table type parameter.
2. The fields should match our field,
and it should be in the format of
structure eg. RSOBUKRS
regards,
amit m.
05-21-2007 11:19 AM
05-21-2007 11:26 AM
Hello Chitra
The easiest (and probably most elegant) way is to use function module <b>RS_REFRESH_FROM_SELECTOPTIONS</b>.
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 <b>CL_DBSEL_CATS</b> for a SAP standard example.
Regards
Uwe
05-21-2007 11:28 AM