Application Development and Automation 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: 
Read only

select options in a method as parameter

rainer_hbenthal
Active Contributor
0 Likes
9,991

Hi,

how do i specify a table defined in a select option as a range table as input parameter for a method? I can use any table, but thats something i dont want to do in this case.,

1 ACCEPTED SOLUTION
Read only

Kiran_Valluru
Active Contributor
0 Likes
5,815

Hi.,

In your Method parameters declare only parameter of that type instead of range parameters ., and in method source code you append it to range.

ex:

date type ISH_ANFDT.

and in source code:

data:

RT_RANGES_FDT TYPE RANGE OF ISH_ANFDT,

RS_RANGES_FDT LIKE LINE OF RT_RANGES_FDT.

if date is not initial.

RS_RANGES_FDT-OPTION = 'EQ'.

RS_RANGES_FDT-LOW = date.

RS_RANGES_FDT-SIGN = 'I'.

APPEND RS_RANGES_FDT TO RT_RANGES_FDT.

ENDIF.

hope this helps u.,

Thanks & Regards,

Kiran

11 REPLIES 11
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
5,815

Hi,

I am little confused with the question

Does the select option content hold the table name ? Possibilities of multiple entries in select option ?

Please make it clear:)

Read only

0 Likes
5,815
select-options selcrit for....

this creates an internal table selcrit with header line as a global range table . I would lioke to handle that table selcrit in a method, but i dont know how to specify it as an input parameter. Which type do i have to enter?

Read only

5,815

Hello Rainer,

First-of-all i'm lil' bit surprised that y.o.u are asking this qn

Anyway back to your qn:

select-options s_bukrs for t001-bukrs

So in your class define a pvt. type:

TYPES grt_burks TYPE RANGE OF bukrs

and use define your i/p param as

IP_BUKRS TYPE grt_bukrs

In your method call you can pass the select-option as

IP_BUKRS = S_BUKRS[] "Remeber the square brackets

Hope this helps.

BR,

Suhas

Read only

0 Likes
5,815

I implemented following solution when I used Local class within an ABAP program.

Call the function module RS_REFRESH_FROM_SELECTOPTIONS in the constructor method of the class. Whenever the instance of class is created the above function module will return the selection screen components (including the values in select-options).

See the wiki post [ABAP Objects - Accessing selection screen components in Local Class|http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=235963596] for reference.

Regards, Vinod

Read only

0 Likes
5,815

Hi Vinod,

Good idea

Suhas I thought that OP wanted to pass multiple select options ( dynamically ) with one parameter in the method. You solution will work for only one. Vinod's idea sounds good . Not sure !! Is it not possible by passing the reference and dereferencing it ?

Didn't look at the editor for last 2 months ...

Read only

0 Likes
5,815

Hello Keshav,

Suhas I thought that OP wanted to pass multiple select-option ( dynamically ) with one parameter in the method

In that case create a data reference parameter & pass the select-option reference to the param:

ip_selcrit TYPE REF TO data

In the calling program get the reference of select-option:

DATA: gd_selcrit TYPE REF TO data.
GET REFERENCE OF selcrit INTO gd_selcrit

& in the method call pass the data ref. gd_selcrit.

BR,

Suhas

Read only

0 Likes
5,815

Yes !! This is what i meant

Keshav

Read only

0 Likes
5,815

Thks guys.

I tried now with type standard table and got a type mismatch error. I forgot that select-options tables do have a header line and selcrit only passes the header line which is of course incompatible with tables.

After a while i recognized that i had to use selcrit[]. Grmpf. I hate tables with header lines.

In the method i'm now checking if it is a table, has 4 columns, every column has the correct values and if the test passes with ok, i have a correct range table.

Did i mention already that i really hate header lines?

After that i'm creating a dynamic field structure, assigning that to a field_symbol (did i mention that i hate header lines) and looping thru the table.

Well, thanks everybody for giving me hints on how to solve that. It wasnt just that easy as in my first thoughts (comparing to a simple perform its a lot more coding). I hate performs as well as header lines. Guess i mentioned that already.

Was a nice practise dealing with dynamic data structures.

Read only

Kiran_Valluru
Active Contributor
0 Likes
5,816

Hi.,

In your Method parameters declare only parameter of that type instead of range parameters ., and in method source code you append it to range.

ex:

date type ISH_ANFDT.

and in source code:

data:

RT_RANGES_FDT TYPE RANGE OF ISH_ANFDT,

RS_RANGES_FDT LIKE LINE OF RT_RANGES_FDT.

if date is not initial.

RS_RANGES_FDT-OPTION = 'EQ'.

RS_RANGES_FDT-LOW = date.

RS_RANGES_FDT-SIGN = 'I'.

APPEND RS_RANGES_FDT TO RT_RANGES_FDT.

ENDIF.

hope this helps u.,

Thanks & Regards,

Kiran

Read only

0 Likes
5,815

I would like to hand ove the complete selcrit table.

Read only

0 Likes
5,815

Hi Rainer,

Below is an example of what you are trying to achieve, update the post if you have any specific question after going through the below.


*----------------------------------------------------------------------*
*       CLASS lcl_some_class DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*

CLASS lcl_some_class DEFINITION.
  PUBLIC SECTION.
    METHODS some_method IMPORTING lt_tab TYPE STANDARD TABLE.
ENDCLASS. "lcl_some_class DEFINITION

*----------------------------------------------------------------------*
*       CLASS lcl_some_class IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_some_class IMPLEMENTATION.

  METHOD some_method.

    IF sy-subrc EQ 0.

    ENDIF.
  ENDMETHOD. "some_method

ENDCLASS. "lcl_some_class IMPLEMENTATION


data: l_data TYPE TABNAME30,
      lt_tab1 TYPE STANDARD TABLE OF selopttab.

SELECT-OPTIONS l_tab FOR l_data.

START-OF-SELECTION.

  DATA: lcl_class TYPE REF TO lcl_some_class.

  CREATE OBJECT lcl_class.

  LOOP AT l_tab.
    APPEND l_tab to lt_tab1.
  ENDLOOP.

  CALL METHOD lcl_class->some_method EXPORTING lt_tab = lt_tab1.

Regards,

Chen