cancel
Showing results for 
Search instead for 
Did you mean: 

Pass internal table of selection-options through method!

Former Member
0 Kudos

I created a selection screen with multiple select-options. Now I want in a method of a class work with the internal tables of the select options.

But the internal tables are dynamic, depending on the lenght of the fieldtype.

If I want to pass the internal table through a method defining the type as RSELOPTION, then the LOW en HIGH have different length and I get a compatible problem.

How can I solve this?

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member183804
Active Contributor
0 Kudos

Hello Frank,

you can also declare an (non-Ddic) type and use this in the method signature. With release 640 or higher you might do this within the class itself. In lower releases this option is limited to private methods. So you can eigther make the signature untyped ( type data ) or due the type definition within a type-pool.

Kind Regards

Klaus


REPORT  KZI_TEST_01.
  tables: Trdir.
  select-options:
    p_Progs for Trdir-Name default sy-Repid.

   class lcl_Sample definition.
     public section.
***************************************************
       types:  ty_Prog_Range type range of Program.
***************************************************
       class-methods: list_Authors importing Programs type ty_Prog_Range.
   endclass.

   class lcl_Sample implementation.
     method list_Authors.
       data: author_Name type sy-Uname.
       select Cnam from Trdir into author_Name where Name in Programs.
         write: / author_Name.
       endselect.
     endmethod.
   endclass.

start-of-selection.
  lcl_Sample=>list_Authors( p_Progs[] ).

nablan_umar
Active Contributor
0 Kudos

In your method definition, try declaring the importing parameter with type ANY.

Former Member
0 Kudos

It almost works. But I get only a record (the first one_, and not the internal table! If I try ANY TABLE, then I get my type-compatible problem again.

former_member183804
Active Contributor
0 Kudos

Hello Frank,

Select-Options are internal tables with header line => more or less one name with two variables a structure and an internal table.

When doing a call only one of them can be passed. Do you use [] (the table) as actual parameter ?

Best Regards

Klaus

nablan_umar
Active Contributor
0 Kudos

Frank,

Did you try something like this:

In definition

METHODS methd1 IMPORTING itab TYPE ANY.

In your program

data: lt_range type rseloption,

ls_range type line of rseloption.

ls_range-sign = 'I'.

ls_range-option = 'EQ'.

ls_range-low = 'ABC'.

append ls_range to lt_range.

...

call method methd1( itab = lt_range ).

Former Member
0 Kudos

This works! Thank you very much!