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: 

How to declare a param. of type RANGE OF in a method (or function module)?

Former Member
0 Kudos

Hello,

I've got a following problem.

I want to pass a value of type RANGE OF to a method declared in

an interface (the interface is built using Class Builder). I don't know

how to do that and I did not manage to find a solution using both

SAP help and google.

Did anybody have the same problem before?

--

Best regards

Pawel

1 ACCEPTED SOLUTION

Former Member

Hi,

see my posting .

You can specify such a table type in DDIC.

Regards Rudi

13 REPLIES 13

former_member202474
Contributor
0 Kudos

Hi,

Can u tell me the method name and class name to which u want to pass the range values.

Regards,

Ruby

0 Kudos

The method and parameter names are irrelevant, so

I don't understand your request.

Former Member
0 Kudos

HI I did it for the function module...i had passed the ranges for the function module

in the tables devlare the fields like this.

r_matnr like RANGE_WERKS

0 Kudos

Yes, it works for a function module but for a method TABLES

statement is not allowed. I would still like to know how to do

that using a method.

Former Member
0 Kudos

Ok, I find a workaround. Maybe it will be useful for somebody in the future.

Declare the parameter type as ANY TABLE and then cast it to the expected type

in the body of the method.

So for example.

Parameter Type Typing Method Associated Type

I_RNG_DATUM Importing Type ANY TABLE

In the body of the method.

TYPES:

erdat_range TYPE RANGE OF erdat.

FIELD-SYMBOLS:

<l_fs_rng_erdat> TYPE erdat_range.

DATA:

l_ref_to_range TYPE REF TO data.

GET REFERENCE OF i_rng_datum INTO l_ref_to_range.

ASSIGN l_ref_to_range->* TO <l_fs_rng_erdat> CASTING.

However, if somebody know how to pass type RANGE OF

explicitely, the right answer is still welcome.

Best regards

Pawel

0 Kudos

you could simply use the table type RSELOPTION

0 Kudos

When I try to pass SELECT-OPTIONS variable to a method with a parameter type declared

as TYPE RSELOPTION I got compile error "S_ERDAT" is not type-compatible with formal parameter "I_RNG_DATUM".

S_ERDAT definition:

DATA: g_erdat TYPE erdat.

SELECT-OPTIONS: s_erdat FOR g_erdat.

Parameter of my method looks like that right now:

I_RNG_DATUM Importing Type RSELOPTION.

Best regards

Pawel

Edited by: Pawel Jagus on Jun 18, 2008 2:03 PM

0 Kudos

what you are saying is that you declared a variable of type RSELOPTION as the importing parameter of a method.

and within the method how you are using that variable?

is it with a select stt? if yes can you post the select stt code here.

where is select-option coming here.

Regards

Raja

0 Kudos

No, you got me wrong. I am talking about method invocation.

I turns out that I cannot pass SELECT-OPTIONS directly to the method as

type RSELOPTION because they are not type compatible.

I have to first loop at SELECT-OPTIONS and move corresponding

fields to a RSELOPTION working area then append it to a RSELOPTION

table.

After that I am able to pass the parameter to the method.

I cannot pass SELECT-OPTIONS directly.

Best regards

Pawel

Edited by: Pawel Jagus on Jun 18, 2008 2:51 PM

Edited by: Pawel Jagus on Jun 18, 2008 2:51 PM

0 Kudos

Hi,

you have to pass the select-option with brackets [], because a select-option is a table type with header line. If you do not use the brackets then just the header line is passed to the method. And sure, this is not type compatible to RSELOPTION.

o_mail->add_receiver( it_sel = so_range[] ).

Regards Rudi

0 Kudos

Rudi, in my opinion your solution is the best.

I applied it and everything is now as I expected

it to be.

Thank you all very much for the support.

I am closing this topic as answered.

Best regards

Paweł

Former Member

Hi,

see my posting .

You can specify such a table type in DDIC.

Regards Rudi

Former Member
0 Kudos

Hi,

data:

w_matid TYPE matnr,

  • Range table for matid

rt_matid LIKE RANGE OF w_matid,

  • Workarea for matid

wa_matid LIKE LINE OF rt_matid.

Thanks,

Rajinikanth G