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 to method of class

Former Member
0 Kudos

Hai friends,

Could u please tell me how to pass select-options as parameters to method of a class.

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

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

7 REPLIES 7

Former Member
0 Kudos

Hi,

use set parameter-id and get parameter-id.

rgds,

bharat.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

athavanraja
Active Contributor
0 Kudos

set the import parameter of the class of type RSELOPTION

uwe_schieferstein
Active Contributor
0 Kudos

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

Former Member
0 Kudos

I got a answer,Thank u all