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

Passing a select-option like parameter

former_member1161170
Participant
0 Likes
1,450

Hi Experts.

I'm a newbie in Abap and I suppose I'm mistaking everything.

I've this code in a class:

PUBLIC SECTION.
    METHODS: constructor IMPORTING nometabella TYPE zcolt_rf0000-classe
                                   Selezione TYPE table of RSDSSELOPT.
[...]
CLASS zcolt_rf IMPLEMENTATION.
    SELECT * FROM vbrk INTO TABLE <table>
       WHERE vbeln IN selezione.

I want to get the records in a class, not in the report. So I must pass the select-options values like a parameter.

When I active the class, it's perfect.

When I active the report I get this error: "Unable to interpret RSDSSELOPT. Possible causes of error: Incorrect spelling or comma error".

The code in the report is:

[...]
DATA:    padre TYPE REF TO zcolt_rf.
DATA: twa_sel TYPE TABLE OF rsdsselopt WITH HEADER LINE.

[...]
SELECT-OPTIONS s_vbeln FOR vbrk-vbeln.
[...]

 LOOP AT s_vbeln.
   MOVE-CORRESPONDING s_vbeln TO twa_sel.
   APPEND twa_sel.
 ENDLOOP.

CREATE OBJECT padre
       EXPORTING nometabella = t_class1
                 selezione   = twa_sel.

What's wrong?

Thanks for your help

Edited by: Matt on Oct 13, 2009 4:33 PM - added {code] tags

1 ACCEPTED SOLUTION
Read only

Pawan_Kesari
Active Contributor
0 Likes
1,107

you can pass select-option to method of class.. you have to use RANGE type for that.. below is snapshot which might help..

CLASS cl_XXXX DEFINITION DEFERRED .

TYPES : r_werks  TYPE RANGE OF t001w-werks         ,
             ty_werks TYPE LINE OF r_werks                     .

DATA : ob_data   TYPE REF TO cl_XXXX .

SELECT-OPTIONS : s_werks FOR t001w-werks         MEMORY ID wrk    OBLIGATORY.

CREATE OBJECT ob_data .
ob_data->set_plant( i_werks = s_werks[] ) .

CLASS cl_XXXX DEFINITION .
  PUBLIC SECTION .
    METHODS :
        set_plant    IMPORTING i_werks TYPE r_werks    .
ENDCLASS.

CLASS cl_inbound_loadboard IMPLEMENTATION .

  METHOD set_plant .

    DATA : ls_werks TYPE t001w-werks .

    me->i_werks = i_werks .

    SELECT werks
      INTO ls_werks
      FROM t001w
     WHERE werks IN me->i_werks .

    ENDSELECT .

  ENDMETHOD .                    "set_plant

ENDCLASS .                    "cl_XXXX

Hi Experts.

I'm a newbie in Abap and I suppose I'm mistaking everything.

I've this code in a class:

PUBLIC SECTION.
    METHODS: constructor IMPORTING nometabella TYPE zcolt_rf0000-classe
                                   Selezione TYPE table of RSDSSELOPT.
[...]
CLASS zcolt_rf IMPLEMENTATION.
    SELECT * FROM vbrk INTO TABLE <table>
       WHERE vbeln IN selezione.

I want to get the records in a class, not in the report. So I must pass the select-options values like a parameter.

When I active the class, it's perfect.

When I active the report I get this error: "Unable to interpret RSDSSELOPT. Possible causes of error: Incorrect spelling or comma error".

The code in the report is:

[...]
DATA:    padre TYPE REF TO zcolt_rf.
DATA: twa_sel TYPE TABLE OF rsdsselopt WITH HEADER LINE.

[...]
SELECT-OPTIONS s_vbeln FOR vbrk-vbeln.
[...]

 LOOP AT s_vbeln.
   MOVE-CORRESPONDING s_vbeln TO twa_sel.
   APPEND twa_sel.
 ENDLOOP.

CREATE OBJECT padre
       EXPORTING nometabella = t_class1
                 selezione   = twa_sel.

What's wrong?

Thanks for your help

Edited by: Matt on Oct 13, 2009 4:33 PM - added {code] tags

4 REPLIES 4
Read only

Pawan_Kesari
Active Contributor
0 Likes
1,108

you can pass select-option to method of class.. you have to use RANGE type for that.. below is snapshot which might help..

CLASS cl_XXXX DEFINITION DEFERRED .

TYPES : r_werks  TYPE RANGE OF t001w-werks         ,
             ty_werks TYPE LINE OF r_werks                     .

DATA : ob_data   TYPE REF TO cl_XXXX .

SELECT-OPTIONS : s_werks FOR t001w-werks         MEMORY ID wrk    OBLIGATORY.

CREATE OBJECT ob_data .
ob_data->set_plant( i_werks = s_werks[] ) .

CLASS cl_XXXX DEFINITION .
  PUBLIC SECTION .
    METHODS :
        set_plant    IMPORTING i_werks TYPE r_werks    .
ENDCLASS.

CLASS cl_inbound_loadboard IMPLEMENTATION .

  METHOD set_plant .

    DATA : ls_werks TYPE t001w-werks .

    me->i_werks = i_werks .

    SELECT werks
      INTO ls_werks
      FROM t001w
     WHERE werks IN me->i_werks .

    ENDSELECT .

  ENDMETHOD .                    "set_plant

ENDCLASS .                    "cl_XXXX

Read only

0 Likes
1,107

Fantastic!!!

Thank you very much.

I have solved by your help.

Read only

0 Likes
1,107

I needed this solution as well, but my class is a global class.

I need to send the select option s_bukrs to my method in the global class. Unfortunately, the global class can't see my definintion of

type r_bukrs TYPE RANGE OF t001-bukrs.

as it is defined in the report, not the class. So I can't successfully check/activate the class.

Is there a similar solution to this for global classes? I really want to keep this as a globabl class as I want to reuse this in other reports.

Thanks,

Scott

Read only

0 Likes
1,107

Scott,

This thread is marked as answered. Please create a new thread and ask your question there.

Cheers,

Neil.