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

Passing select-options value in method

How to pass select-options value in method ?

Example:

Select-options: carrid for spfli-carrid.

class cl_myclass implementation.

select carrid connid from

spfli where carrid in carrid.

endclass.

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Jan 26, 2008 at 12:54 PM

    Hello Anee

    The easiest (and probably most elegant) way is to use function module RS_REFRESH_FROM_SELECTOPTIONS.

    In the CONSTRUCTOR method of your class you add an EXPORTING parameter IM_CALLING_PROGRAM.

    Within the CONSTRUCTOR method you call the function module with the value of the calling program (which is your selection report). The function module returns you all current selection criteria of the report.

    Have a look at class CL_DBSEL_CATS for a SAP standard example.

    Regards

    Uwe

    Add a comment
    10|10000 characters needed characters exceeded

    • Hello Anee

      The coding of this functionality is quite simple:

      REPORT zmy_report.
      
      
      DATA:  go_myclass   TYPE REF TO zcl_myclass,
                 gd_repid         TYPE syst-repid.
      
      
      
      PARAMETERS:
        p_bukrs   ...
      
      SELECT-OPTIONS:
        o_kunnr  ...
      
      
      START-OF-SELECTION.
      
        gd_repid = syst-repid.
      
        CREATE OBJECT go_myclass
          EXPORTING
            id_calling_program = gd_repid.
      ...
      
      

      And that's how your CONSTRUCTOR method should look like:

      METHOD constructor.  " IMPORTING parameter id_calling_program
      
      CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
        EXPORTING
          CURR_REPORT = id_calling_report
        TABLES
          SELECTION_TABLE = me->mt_selopts.
      
      " NOTE: define mt_selopts as instance attribute of table type RSPARAMS_TT
        
      
      ENDMETHOD.
      

      Finally you have to extract the parameter and select-options from MT_SELOPTS.

      Regards

      Uwe

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.