Skip to Content
author's profile photo Former Member
Former Member

Passing Select-options in OO ABAP

Hi,

How to use select-options in oo ABAP?

Regards,

Ravi S

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 22, 2008 at 11:07 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 22, 2008 at 11:05 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 22, 2008 at 11:14 AM

    Hello Ravi

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

    Regards

    Uwe

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 27, 2008 at 06:52 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 27, 2008 at 07:15 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 27, 2008 at 11:40 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 27, 2008 at 12:44 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on May 28, 2008 at 07:44 AM

    Hi,

    You can do it like this....

    Tables: MARA.

    select-options: i_matnr like MARA-matnr.

    Reward if helpful.

    Regards,

    Syed

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.