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 in OO ABAP

Former Member
0 Kudos
2,662

Hi,

How to use select-options in oo ABAP?

Regards,

Ravi S

1 ACCEPTED SOLUTION

Former Member
0 Kudos
432

Hi Ravi,

If you want to pass the select-option values to the method (importing parameter), Convert select option values to range.after that you use the range in your method.

9 REPLIES 9

former_member480923
Active Contributor
0 Kudos
432

This is how you declare it..



DATA: gw_bukrs TYPE bukrs.

SELECT-OPTIONS: s_bukrs FOR gw_bukrs.

you can use s_bukrs as you do in normal ABAP.

Hope That Helps

Anirban M.

Former Member
0 Kudos
433

Hi Ravi,

If you want to pass the select-option values to the method (importing parameter), Convert select option values to range.after that you use the range in your method.

uwe_schieferstein
Active Contributor
0 Kudos
432

Hello Ravi

If you are interested in how to import select-options into class methods have a look at the following threads:

Regards

Uwe

Former Member
0 Kudos
432

hi,

you can use the formatt.

*"Table declarations...................................................

TABLES:

rbkp, " Document Header Invoice receipt

rseg, " Document Item: Incoming Invoice

eban, " Purchase Requisition

t001w. " Plants/Branches

*"Selection screen elements............................................

PARAMETERS:

p_gjahr LIKE rbkp-gjahr. " Fiscal Year

SELECT-OPTIONS:

s_belnr FOR rbkp-belnr, " Document number of an invoice

s_bldat FOR rbkp-bldat, " Document Date in Document

s_budat FOR rbkp-budat, " Posting Date in the Document

s_werks FOR rseg-werks. " Plant

reward if helpful.

regards,

srishti.

former_member569226
Participant
0 Kudos
432

Hi,

Please find the code below using select-options in ABAP-OO.

Report ztest.

tables:marc.

select-options: s_matnr for marc-matnr.

class c3 definition.

public section.

types: begin of ty_marc,

matnr type marc-matnr,

werks type marc-werks,

end of ty_marc.

data: wa_itab type ty_marc.

data: itab type table of ty_marc .

data: wa_matnr type r_matnr.

methods: add.

private section.

*methods: sub.

endclass.

class c3 implementation.

method add .

select matnr

werks

from marc into table itab where matnr IN s_matnr.

loop at itab into wa_itab.

write: wa_itab-matnr,

wa_itab-werks.

endloop.

endmethod .

endclass.

start-of-selection.

data b1 type ref to c3.

create object b1 .

call method b1->add.

Best Regards

Suresh

Former Member
0 Kudos
432

Hi Ravi,

U can go ahead with normal way of putting the select-options in ur report as the Select-options will remains constant put in before the event flow or definitions.

cheers

Mohinder Singh

Former Member
0 Kudos
432

Hi All,

Thanks for ur replies.

I Knew this way to write select-options normally.But my doubt is how to pass these select-options as parameters in methods.Anyway i resolved this.

Regards,

Ravi S

0 Kudos
432

Hi Ravi,

You have to define a type as below

TYPES:tr_matnr TYPE RANGE OF matnr.

DATA: gv_matnr TYPE mara-matnr.

SELECT-OPTIONS: so_matnr FOR gv_matnr.

----


  • CLASS lcl_example DEFINITION

----


CLASS lcl_example DEFINITION.

PUBLIC SECTION.

METHODS:

get_data

EXPORTING

so_matnr TYPE tr_matnr.

ENDCLASS.

----


  • CLASS lcl_example IMPLEMENTATION

----


CLASS lcl_example IMPLEMENTATION.

METHOD get_data.

SELECT COUNT(*)

FROM mara

WHERE matnr IN so_matnr[].

ENDMETHOD.

ENDCLASS.

If you have to pass it globally create a table type that has the same structure as select-opton ( that is low high sign option ).

PLEASE REWARD THE POINTS

Thanks & Regards,

Sujith

Former Member
0 Kudos
432

Hi,

You can do it like this....

Tables: MARA.

select-options: i_matnr like MARA-matnr.

Reward if helpful.

Regards,

Syed