Passing select options to a subroutine

hi experts
can somebody tell me how to pass a select options to
a subroutine. tell  me how to pass using pass by reference and
value.
thanks.

Hi AJAY,
yes, as  Sumit Agarwal  already said, the select-options are internal tables. They are implicitly declared as range tables with header line.
SELECT-OPTIONS:
  s_matnr for mara-matnr.
decalares a table and will generate the input fields on the selection screen.
data:
  s_matnr TYPE RANGE OF mara-matnr WITH HEADER LINE.
declares the same table.
You may pass this to a subroutine using the TABLES parameter. But as this is obsolete, it is better to find or declare an appropriate type for this.
TYPES:
  ty_sel_mat TYPE RANGE OF mara-matnr .
PERFORM select_material USING s_matnr[]. "[] means table body only
FORM select_material USING pt_selmat type ty_sel_mat.
SELECT ... INTO ... FROM mara WHERE matnr IN pt_selmat.
ENFORM
is the appropriate syntax.
Note: SAP has dictonary types for many fields frequently used in select-option ranges. They are defined as table types and may be found by searching for names like range.
Regards,
Clemens

Similar Messages

  • Passing select options through subroutines

    Hi
    how do you pass select option values through subroutines?

    Hello,
    Is this what you are looking for:
    TYPES: ty_r_bukrs TYPE RANGE OF bukrs.
    DATA:
          v_date TYPE datum,
          v_bukrs TYPE bukrs.
    SELECT-OPTIONS:
    s_bukrs FOR v_bukrs OBLIGATORY,
    s_date FOR v_date.
    AT SELECTION-SCREEN.
      PERFORM f_check_cocd
      USING s_bukrs[].
    *&      Form  f_check_cocd
    *       Check Comp. Code
    FORM f_check_cocd
      USING fp_s_bukrs TYPE ty_r_bukrs.
      DATA: l_v_bukrs TYPE bukrs.
      SELECT bukrs UP TO 1 ROWS
      FROM t001
      INTO l_v_bukrs
      WHERE bukrs IN s_bukrs.
      ENDSELECT.
      IF sy-subrc <> 0.
    *   Throw Error Message
      ENDIF.
    ENDFORM.                    " f_check_cocd
    BR,
    Suhas

  • Passing Select option to the sub routine

    Hi All ,
    how can we pass  select option values to a subroutine ,
    Thanks in Advance
    Vinay

    Hi Vinay Kolla,
    Check out this.
    TYPES: TYP_DATUM TYPE RANGE OF SY-DATUM.
    DATA: WA_DATUM   TYPE LINE OF TYP_DATUM.
    SELECT-OPTIONS : S_DATUM FOR SY-DATUM.
    START-OF-SELECTION.
      PERFORM WRITE_DATUM TABLES S_DATUM[].
    *&      Form  write_datum
    *       text
    *      -->P_S_DATUM  text
    FORM WRITE_DATUM TABLES P_S_DATUM TYPE TYP_DATUM.
      LOOP AT P_S_DATUM INTO WA_DATUM.
        WRITE : /10 WA_DATUM-SIGN,
                    WA_DATUM-OPTION,
                    WA_DATUM-LOW,
                    WA_DATUM-HIGH.
      ENDLOOP.
    ENDFORM.            
    Regards,
    R.Nagarajan.
    We can -

  • Problem in passing select-options to class meathods , type any table

    <h1>how to pass type any table to class meathod</h1>
    <h3>hi all
           i'm trying to build class to validate the selection screen , like select-options and parameters
           while writing meathod to validate the select-options
           its throwing parameter mismath error</h3>
    <h4>i tried like made import parameter in class meathod as 'TYPE ANY TABLE' and tried to pass select-options from my program it is saying type mismatch , how to overcome this problem </h4>
    <h4>and i want to pass any select option , either of type lfa1-lifnr or mara-matnr or any other</h4>
    Moderator message : Don't shout, use proper font size for explaining the question. This has been discussed in ABAP forums before. Search for available information. Thread locked.
    Edited by: Vinod Kumar on Sep 14, 2011 11:20 AM

    hI
    Triggering and Handling events
    At the moment of implementation, a class defines its:
             Instance events (using the EVENTS statement)
            Static events (using the CLASS-EVENTS statement)
    Classes or their instances that receive a message when an event is triggered at runtime and want to react to this event define event handler methods. Statement: METHODS
    CLASS IC1_VEICHLE DEFINATION.
    PUBLIC SECTION.
    METHOD CONSTRUCTOR IMPORTING
    EVENTS VEICHEL_CREATION.
    ENDCLASS
    CLASS LC1_VEICHLE IMPLIMENTATION.
    METHOD CONSTRUCTOR
    RAISE EVENT VEICHLE_CREATION.
    REWARD IF USEFULL

  • Passing Select-options as parameter to function module

    I need to pass a select-option as a parameter to a function module. Is this possible?
    There is an option of passing all the values of the select-option to an internal table, passing that internal table as parameter to the function module, and then adding it manually again to a select-option in the function module.
    But is there any direct way to do this?

    Hi,
    I have a similar problem: I have RFC function module to which I want to pass select options. Therefore I defined table parameters as follows:
    IT_RUNID     TYPE     EFG_TAB_RANGES
    IT_PERNR      TYPE     EFG_TAB_RANGES
    IT_REINR     TYPE     EFG_TAB_RANGES
    I can successfully pass my values to the module, but if I try to check these parameters
    using
    CHECK IT_TRIPS-RUNID IN IT_RUNID.
        CHECK IT_TRIPS-PERNR IN IT_PERNR.
        CHECK IT_TRIPS-REINR IN IT_REINR.
    the check always fails, I guess because there are leading zeros in the ranges. Is there a way to solve this problem?
    Thanks and regards,
    Martin

  • How to pass select-option filed to Function Module Exporting Parameter

    Hi,
        How to pass select-option filed to Function Module Exporting Parameter.
    Thanks

    Hi,
    DATA: BEGIN OF ITAB5_WRK OCCURS 0,
            KUNNR     TYPE KNKK-KUNNR,  "CUSTOMER #
            SBGRP     TYPE KNKK-SBGRP,  "CREDIT REP
            KLIMK     TYPE KNKK-KLIMK,  "CREDIT LIMIT
            NAME1     TYPE KNA1-NAME1,  "CUSTOMER NAME
            SKFOR     TYPE KNKK-SKFOR,  "TOTAL A/R
            AMT1      TYPE KNKK-SKFOR,  "CURRENT
            AMT2      TYPE KNKK-SKFOR,                          "01-30
            AMT3      TYPE KNKK-SKFOR,                          "31-60
            AMT4      TYPE KNKK-SKFOR,                          "61-90
            AMT5      TYPE KNKK-SKFOR,                          "91-120
            AMT6      TYPE KNKK-SKFOR,                          "OVR 120
            BZIRK     TYPE KNVV-BZIRK,
          END OF ITAB5_WRK.
    SELECT-OPTIONS P_COMP     FOR  T001-BUKRS
      SELECT KUNNR SBGRP  FROM KNKK
             INTO TABLE ITAB5_WRK
             WHERE SBGRP IN P_REP
               AND KUNNR GE '0001000000'
               AND SKFOR NE 0.
      LOOP AT ITAB5_WRK.
        DELETE ADJACENT DUPLICATES FROM ITAB5_WRK COMPARING KUNNR.
      ENDLOOP.
      PERFORM GET_CREDIT_LIMITS.
    *=======================================================================
      IF P_DIST NE SPACE.
        LOOP AT ITAB5_WRK.
          SELECT SINGLE * FROM KNVV WHERE KUNNR EQ ITAB5_WRK-KUNNR
                                      AND VKORG EQ P_COMP
                                      AND VTWEG EQ '20'
                                      AND SPART EQ '10'
                                      AND BZIRK IN P_DIST.
          IF SY-SUBRC EQ 0.
            MOVE KNVV-BZIRK TO ITAB5_WRK-BZIRK.
            MODIFY ITAB5_WRK.
          ELSE.
            DELETE ITAB5_WRK.
          ENDIF.
        ENDLOOP.
      ENDIF.
    *==============================================================
      LOOP AT ITAB5_WRK.
        MOVE: 'F/S'            TO WRK-KKBER,
               ITAB5_WRK-KUNNR TO WRK-KUNNR.
        PERFORM AGING.
        ADD: W_SNFAE  TO ITAB5_WRK-AMT1,
             W_SFAE1  TO ITAB5_WRK-AMT2,
             W_SFAE2  TO ITAB5_WRK-AMT3,
             W_SFAE3  TO ITAB5_WRK-AMT4,
             W_SFAE4  TO ITAB5_WRK-AMT5,
             W_SFAE5  TO ITAB5_WRK-AMT6,
             W_SFAEL  TO ITAB5_WRK-SKFOR,
             W_SNFAE  TO ITAB5_WRK-SKFOR.
        MOVE: 'SPEC'            TO WRK-KKBER,
               ITAB5_WRK-KUNNR TO WRK-KUNNR.
        *PERFORM AGING.*
        ADD: W_SNFAE  TO ITAB5_WRK-AMT1,
             W_SFAE1  TO ITAB5_WRK-AMT2,
             W_SFAE2  TO ITAB5_WRK-AMT3,
             W_SFAE3  TO ITAB5_WRK-AMT4,
             W_SFAE4  TO ITAB5_WRK-AMT5,
             W_SFAE5  TO ITAB5_WRK-AMT6,
             W_SFAEL  TO ITAB5_WRK-SKFOR,
             W_SNFAE  TO ITAB5_WRK-SKFOR.
        MODIFY ITAB5_WRK.
      ENDLOOP.
    FORM AGING.
      *CALL FUNCTION 'CUSTOMER_DUE_DATE_ANALYSIS'* 
      EXPORTING
          BUKRS             = P_COMP           
          KKBER             = WRK-KKBER
          KUNNR             = WRK-KUNNR
          RASID             = 'FEND'
          KLIMP             = 'X'
        IMPORTING
          SFAE1             = W_SFAE1
          SFAE2             = W_SFAE2
          SFAE3             = W_SFAE3
          SFAE4             = W_SFAE4
          SFAE5             = W_SFAE5
          SFAE6             = W_SFAE6
          SFAEL             = W_SFAEL
          SNFA1             = W_SNFA1
          SNFA2             = W_SNFA2
          SNFA3             = W_SNFA3
          SNFA4             = W_SNFA4
          SNFA5             = W_SNFA5
          SNFA6             = W_SNFA6
          SNFAE             = W_SNFAE
        EXCEPTIONS
          NO-AGING_SCHEDULE = 1
          NO_TABLE_INPUT    = 2.
      CASE SY-SUBRC.
        WHEN 1.
          MESSAGE E999 WITH 'PLEASE ENTER AGING SCHEDULE'.
        WHEN 2.
          MESSAGE E999 WITH 'DO NOTHING ??'.
      ENDCASE.
    ENDFORM.                    "AGING
    Thanks

  • HOW TO PASS SELECT-OPTIONS AS IMPORT PARAMETER TO A CLASS

    Hi experts,how to pass select options value as a export parameters to a zclass.
    can  give me some idea.
    Thanks
    sai

    As Sachin already said, selection options are stored in an internal table. You can reconstruct the table type without the corresponding input fields using the type addition RANGE OF.
    So - assuming you have the following in your program:
    DATA: wa TYPE sflight.
            SELECT-OPTIONS so_car FOR sflight-carrid.
    you can create a publically-visible type in your class using direct type entry and the code
    TYPES: my_selectoption TYPE RANGE OF sflight-carrid.
    and use this to define the importing parameter of the method.
    The only other thing you have to remember is that select-options generates an internal table with header line. Thereore, to pass the table to the method, you would use (in the above example) so_car[], and not just the name of the select-option.
    Hope this helps.
    Regards
    Jon.

  • Passing SELECT-OPTIONS value to Function Module

    Hi,
    I need to pass select-options value to a function module.
    Code is like the following:
    SELECT-OPTIONS seltab FOR object-type.
    CALL FUNCTION 'Z_MY_FM'
          EXPORTING
            sel_tab         = seltab
         IMPORTING
            result_tab     = it_result
    I have found a similar problem in the SDN forum: How to pass select-options parameter to FM?
    However, that could not help me much in solving my problem.
    So far I have tried to created a structure in DDIC with the following components for the select-options:
    SIGN - BAPISIGN
    OPTION - BAPIOPTION
    LOW - ZBWOBJECTTYPE (my type)
    HIGH - ZBWOBJECTTYPE (my type)
    and subsequently a table type for this structure which is specified in the "Import" tab of my function module.
    Unfortunately, when I ran the program a runtime exception occured (CALL_FUNCTION_CONFLICT_TYPE).
    Could anyone please help me on this issue?
    Thanks in advance.
    Regards,
    Joon Meng

    Hello Joon,
    CALL FUNCTION 'Z_MY_FM'
          EXPORTING
            sel_tab         = seltab
         IMPORTING
            result_tab     = it_result
    You have defined SELTAB as a SELECT-OPTION.
    So when you pass only SELTAB, the header line is transferred to the FM. When you pass SELTAB[] the whole table(range) is passed.
    It is similar to the concept of an internal table with header line.
    Hope i am clear.
    Anyways how have you defined result_tab and sel_tab ?
    BR,
    Suhas

  • Passing SELECT-OPTIONS to smart forms

    hi ,
       how can we pass select options from a program to a smart form.
    Regards
    Arun

    Hi,
    Just try to append the valid values in select options  to internal table from report.
    Then pass that internal table(ofcourse, you need to create user-defined struture if needed in SE11) from report to smart forms.
    Rgds,
    J.Jayanthi

  • Passing select-options to method of class

    Hai friends,
             Could u please tell me how to pass select-options as parameters to method of a class.

    Hi
    You have to declare the select
    options like
    <b>DATA: l_kunnr TYPE STANDARD TABLE OF wselkunnr,</b>
    see this example
    *& Report  ZCL_TEST_ANJI
    REPORT  zcl_test_anji.
    TABLES kna1.
    DATA: l_kunnr TYPE STANDARD TABLE OF wselkunnr,
          l_kna1  TYPE STANDARD TABLE OF kna1,
          l_sales TYPE STANDARD TABLE OF vbak,
          l_cust  TYPE kna1,
          l_vbak  TYPE vbak.
    DATA: obj_cust TYPE REF TO zcl_test_anji.
    SELECT-OPTIONS: s_kunnr FOR kna1-kunnr.
    Start of Selection
    START-OF-SELECTION.
      CREATE OBJECT obj_cust.
      SET HANDLER obj_cust->event_handler_1 FOR obj_cust.
      SET HANDLER obj_cust->event_handler_2 FOR obj_cust.
      l_kunnr[] = s_kunnr[].
      CALL METHOD obj_cust->zcust
        EXPORTING
          s_cust  = l_kunnr
        RECEIVING
          it_kna1 = l_kna1.
      IF NOT l_kna1[] IS INITIAL.
        LOOP AT l_kna1 INTO l_cust.
          WRITE: / l_cust-kunnr, 12 l_cust-name1,
                48 l_cust-ort01, 85 l_cust-land1,
                95 l_cust-pstlz.
          HIDE l_cust-kunnr.
        ENDLOOP.
      ENDIF.
    At line Selection
    AT LINE-SELECTION.
      CASE sy-lsind.
        WHEN 1.
          CALL METHOD obj_cust->zso
            EXPORTING
              im_kunnr = l_cust-kunnr
            RECEIVING
              it_so    = l_sales.
          IF NOT l_sales[] IS INITIAL.
            LOOP AT l_sales INTO l_vbak.
              WRITE: / l_vbak-kunnr, 12 l_vbak-vbeln,
                    24 l_vbak-vkorg, 30 l_vbak-audat,
                    43 l_vbak-netwr.
            ENDLOOP.
          ENDIF.
    ENDCASE.
    <b>Reward points if useful</b>
    Regards
    Anji

  • 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

    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

  • Showing error in passing select option to smartforms

    Dear Friends,
      I have done program of passing select option to smartforms. But it was showing errorin Types of Global defination  that the flat structure is not allowed. So pls guide me.
    Thanks in advance,
    Pradipkumar

    Hi Pradip,
    <li>When you want pass select-option from program to Smartform. You need create one structure in SE11 (data dictionary) and Use that under Form interface ->Tables tab
    <li>The structure should have the following fields.
    low
    high
    sign
    option
    <li>The structures should be same in the program and smartform when that is used as interface.
    Thanks
    Venkat.O

  • How to Pass Select-options Single values as Parameter value to Method ?

    Hi Friends,
    I need to pass select-options values(single values) for s_arbpl to the method "process_percent_planned". Now all single values are in internal table s_arbpl-low field. I need to pass this internal table(s_arbpl-low) values to the method where i will run query based on these single values.In my below code i am passing value through variable w_arbpl. I have defined this parameter in the method.But here only one value is passed to method. I want multiple single values (in s_arbpl-low) should be passed. Please let me know how to correct code.
    Tables: crhd.
    Data: ktext type auftext,
    w_arbpl type arbpl.
    select-options: s_arbpl for crhd-arbpl.
    ktext = 'Test'
    create object obj_plan.
    call method obj_plan->process_percent_planned
    exporting
    ktext = ktext
    w_arbpl = s_arbpl-low.
    Thanks

    hi ,
    when you want to pass  S_ARBPL AS PARAMETER IN SELEC OPTION
    ARBPL SUCH AS  
       WIN002
      WIN003
      WIN004
      WIN005
      WIN006
      WIN007
    IN MULTIPLE SELECTION  S_ARBPL
    THEN
    USE  
    Tables: crhd.
    Data: ktext type auftext,
    w_arbpl type arbpl.
    select-options: s_arbpl for crhd-arbpl.
    ktext = 'Test'
    LOOP AT S_ARBPL .
    create object obj_plan.
    call method obj_plan->process_percent_planned
    exporting
    ktext = ktext
    w_arbpl = s_arbpl-low.
    ENDLOOP.
    REGARDS
    dEEPAK .
       THEN SELECT THAT
    call method obj_plan->process_percent_planned
    exporting
    ktext = ktext
    w_arbpl = s_arbpl-low.

  • Passing SELECT-OPTIONS and Internal Tables to SUBROUTINES

    Hi Guys
    In the code below my colleague has created her own table types in order to pass a select option and internal tables to her subroutine. Is there an easier way of making them known to the subroutine.
    data : v_vbeln type vbeln_vf,
          it_bdoc type table of vbrp,
          it_t006 type table of t006a,
          wa_bdoc type vbrp,
          wa_t006 type t006a,
          it_bdoc2 type table of zsswathi_st_vbeln,
          wa_bdoc2 type zsswathi_st_vbeln
    select-options s_vbeln for v_vbeln matchcode object zswathi_vbeln obligatory.
    start-of-selection.
    perform bdoc using s_vbeln[]
                 changing it_bdoc
                          it_bdoc2
                          it_t006.
      loop at it_bdoc2 into wa_bdoc2.
    form bdoc using f_s_vbeln type ZSWATHI_ST_SELECT_OPTION_TA_TY       " all these are table types. for select options, a structure is created and then a table type for it is created.
            changing f_it_bdoc type zswathi_vbrp_ty_ta
                     f_it_bdoc2 type zswathi_vbeln_ty_ta
                      f_it_t006 type ZSWATHI_T006_TA_TY.
    select * from vbrp into table f_it_bdoc where vbeln in f_s_vbeln.
          if f_it_bdoc is not initial.
          select  vbeln sum( netwr ) prsdt from vbrp into table f_it_bdoc2 where vbeln in f_s_vbeln group by vbeln prsdt.
          sort f_it_bdoc2 by vbeln.
          "select * from t006a into table it_t006 for all entries in it_bdoc where msehi = it_bdoc-vrkme.
          select * from t006a into table f_it_t006 for all entries in f_it_bdoc where msehi = f_it_bdoc-vrkme.
       endif.
        endform.

    Hi Brett,
    1. you can use a select-options-range in a FORM subroutine also without passing it as a parameter because parameters and select-option range tables are global fields in their program.
    2. If you need a parameter, declare it as type table or type standard table or type any table. You do not need any special table type.
    Regards
    Clemens

  • Passing select-options to class methods

    Hi,
    I want to pass a select-option filled in the selection screen by the user to a method of my class. Since select-options are hold as an internal table with fields sign option low high, and passing internal tables to methods require typing, what should I write as the name of this internal table type?
    For example;
    select-options: so_carid for spfli-carrid.
    I want to pass the contents of so_carid to my method defined in a class

    hI
    Triggering and Handling events
    At the moment of implementation, a class defines its:
             Instance events (using the EVENTS statement)
            Static events (using the CLASS-EVENTS statement)
    Classes or their instances that receive a message when an event is triggered at runtime and want to react to this event define event handler methods. Statement: METHODS
    CLASS IC1_VEICHLE DEFINATION.
    PUBLIC SECTION.
    METHOD CONSTRUCTOR IMPORTING
    EVENTS VEICHEL_CREATION.
    ENDCLASS
    CLASS LC1_VEICHLE IMPLIMENTATION.
    METHOD CONSTRUCTOR
    RAISE EVENT VEICHLE_CREATION.
    REWARD IF USEFULL

Maybe you are looking for

  • Error message when syncing iPhone 4 to iTunes after updating software on both OXE800001

    Help Just updated software for both iPhone & MacBook iTunes and since receive error message oxe8 etc. have tried all recommended steps but do not work. Has synced wirelessly ok & iPad seems ok as well

  • Problem Managing Custom Paper Size Using Epson

    Since updating my Mac to the latest version Yosemite, when I now try to Manage Custom Paper Size in the Epson print box via my Photoshop Elements 11, Photoshop crashes. Has anyone experienced this problem? If so have you found a solution?

  • What does DUMMY=1 mean in the URL string

    Hello, I am executing WAD template that contains a query for my planning layout. When I look at the URL link of the WAD in the browser, it has the following in it: http://xxx.xxx.com:50000/irj/servlet/prt/portal/prtroot/pcd!3aportal_content!2fcom.sap

  • Error when i share to youtube

    fcp7 - share - youtube - publish to youtube. it converts, then when it tries to publish, it gives me an error that says unable to publish to youtube. i know i have the right username and password put in. it has never worked. any ideas? I'm on 10.6.2

  • Java Library for SFTP Access

    Hi, Currently I am uploading files via SFTP Software on a specific server. I have to automate this step. How can I do this step with Java. -Aykut