Export RANGES to function module

Can anyone tell, how to pass RANGES to function module.
i have report program in ,
DATA : BEGIN OF ITAB OCCURS 0,
           MATNR LIKE MARA-MATNR,
          END OF ITAB.
SELECT-OPTIONS  : S_MATNR FOR MARA-MATNR.
I want all the values in S_MATNR in ITAB.
Note that S_MATNR has any value( Include, Exclude,Between, Equal etc.)

Hi,
Define a type in the global data declaration of the function module as follows :
TYPES : BEGIN OF t_range_matnr,
        sign(1) TYPE c,
        option(2) TYPE c,
        low TYPE mara-matnr,
        high TYPE mara-matnr,
END OF t_range_werk.
" Define a table type
types matnr_tab type t_range_matnr occurs 0.
Once done, define the importing parameter of t_matnr in the function modules signature, lets call it matnr
In your program where you would call the function, lets say you have the select option as follows
SELECT-OPTIONS matnr FOR ekpo-matnr.
" In the call function simply pass matnr[]
call function 'select_mara'
exporting
   matnr = matnr[].
Done.
P.S. Do not forget the square brackets.
regards,
Advait
Edited by: Advait Gode on Apr 16, 2009 10:05 AM

Similar Messages

  • Fetch data from table(ET_) which is exporting parameter of function module

    Hi,
    I m new to ABAP programming.
    I have to develop a smartform that has to be filled in with fields from few tables.
    These tables have the naming convention ET_<XXX> (i.e. exporting parameter of function module).
    I m not able to directly view its contents in se11 or use select query for it.
    I have a report program which i can execute to view these parameter names.
    Now, how do i fetch data from these parameters/tables and pass it from my driver program to smartform??
    Someone pls guide me...
    Thank You.

    Hi,
    I have done that using Field-Symbols.
    Thanks,
    Preetha

  • Ranges in function module

    HI All,
      how can we use ranges in function module.
    please send sample code for this.
    regards,
    amit.

    Hi,
    If you have range, you can convert the contents of ranges into internal table.
    And then Pass the internal table to FM.
    Thanks,
    Sriram Ponna.

  • Ranges as export parameter in function modules

    hi guys
    i have to design a function module in such a way that i have to pass a ranges table.
    watt structure or type should i use?
    thanks
    sameer

    Define your range in the datadictionary and then use this type for the changing or exporting parameters.
    In SE11 define a structure of table type.  From the edit menu choose define as ranges table.  After this you may input the field for the high\low data element.  input the name and create the structure:
    Example range table for VKBUR.
    create ZRT_VKBUR as structure (table)
    Input  VKBUR as data element for high/low and input zrl_vkbur in structure row type.  Save and then click on the create button for ZRL_VKBUR which will create a standard range table line definition.

  • How to import a range in Function module?

    I am using a Function module in which material is getting imported.
    In the import tab we have
    Parameter Name    Typing     Associated Type       optional          pass value
    IM_MATERIAL       TYPE       MATNR                 <checked>         <checked>
    So when the Function module is execute we can enter only one value into the IM_MATERIAL.
    But now it has to be enhanced for entering multiple values. How to import the material as a range?
    Please throw light.
    Thanks.

    Hi
    If you are using a select-options you can use this approach.
    TABLES: MARA.
    DATA: RANGE TYPE WRF_MATNR_RANG_TTY.
    SELECT-OPTIONS: SO_MATNR FOR MARA-MATNR.
    START-OF-SELECTION.
      RANGE[] = SO_MATNR[].
    CALL FUNCTION 'ZTEST'
    EXPORTING
       I_RANGE       = RANGE.
    Where I_RANGE is defined using this table type WRF_MATNR_RANG_TTY
    Parameter Name    Typing     Associated Type     optional          pass value
    I_RANGE       TYPE       WRF_MATNR_RANG_TTY      <checked>     <checked>

  • Any example to import and export itab to function module

    hi all,
    as the table parameter in function module is obsolete, please advise an example on how to pass in an internal table
    and return back the result in an internal table as well.
    for example, i have itab1 and itab2. By using table parameters i got the following code. Please advise alternative way by using import and export.
    ""Local Interface:
    *"  TABLES
    *"      itab1 STRUCTURE  Zitab1
    *"      itab2 STRUCTURE  Zitab2
    loop at itab1 into wa_itab.
    **do some logic here to assign value to itab2 and return.
      wa_itab2-a = xxx .
      wa_itab2-b = xxx.
    append wa_itab2 to itab2.
    endloop.
    thank you.

    hi,
    suppose you have two structure name struc1 and struc2.
    create table type zitab1 & 2 for both.
    please do the following:
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(itab1) TYPE  Zitab1
    *"  EXPORTING
    *"     VALUE(itab2) TYPE  Zitab2
    you can avoid to use the obsolete table parameters as well as LIKE in function module creation.
    cheers

  • Difference between Import and Export parameters in Function Module

    Hi All,
    I am unclear about the import and export parameters, when i create a function module. Can anyone explain abt this. However when i call the function module in any program the import parameters in Function module are displayed as exporting in program amd the export parameters as importing.
    Any help on this would be appericiated.
    Shejal.

    HI,
    Import parameter in FM is the value u provide to FM for processing.
    export is the value u get from FM after processing.
    when u call a FM in a progam the import parameter will appear as Export bcos u r giving value to the FM.
    and u r getting value from FM in import parameter(bcos u r importing).
    rgds,
    latheesh
    Message was edited by: Latheesh Kaduthara

  • Date range in function module

    Hi guys,
                 i have a selection screen where i need to give range of date.
    say from 01.01.1998 to 01.02.2007.
    i need to pass this date range to 'Z' funtion module how can i do it.
    do i need to define it in tables declaration. if yes what will be the reference type of this field.
    I want this range of dates in function module.
    Please explain.

    Hi ahmed
           Let us assume s_date is the select option for the date range defined like  
           DATA: s_date for p0001-begda.
           Now while calling the FM pass the s_date-low and s_date-high as 2 parameters for the FM.In the FM create 2 parameters begda and endda of type begda. Use the low value and high value in the FM to populate the range table and u can use this range table for further processing of the dates in the FM.The range table can be forwarded as follows:
    r_date-low = begda.
    r_date-high = endda.
    also provide the sign and options for the ranges table.

  • Pass internal tables in Export  Parameters of  Function Module

    Hi
    How to pass internal tables through export parametes of the calling function module. i
    think i can pass it by reference ....
    if so can anyone suggest how to do it?

    Hi,
    You can Export values of an Internal table in two ways, by :
    1) specifying in Tables tab
    (Not recommended since it's an obsolete in ECC 6.0)
    If used, will reduce the performance of the FM
    Tables are always passed by reference
    2) specifying in Exports tab.
    The parameter should be a Table type (created in se11)
    having a Line type that refers to the structure of the data.
    Pass by Value is not used for Normal Function modules.
    Used usually for RFC enabled FMs.
    Cheers,
    Remi

  • Dynamic Export table of a function Module

    Hi Friends,
    I have a requirement where fields of  Export table of my function Module is dynamic. It is like the Fields to be expoerted by the Function Module would be stored in a seperate Z table
    The Z table would contain the records as follows .
    Table Name              FieldName
    =========     
    MARA                      MATNR
    MARC                      WERKS
    and So on..
    . How can I define my Export table in Function module dynamically so that the structure of my Export Function Module would be same as that of the Fieldnames in Z table..
    Thanks

    Just declare the associate type as "ANY TABLE" in the exporting parameter.
    FUNCTION ZTEST.
    *"*"Local Interface:
    *"  EXPORTING
    *"     REFERENCE(IT_TAB) TYPE  ANY TABLE

  • Help in ABAP function module coding.

    Hi,
    i am having trouble coding the program where i have to select a number from the table and add one to it to create a new record back to the table.  example, i've select 1 from the table, i need the program to be able to return 2 and create a new record back into the table and the next time i generate the program, i will select 2 and create a 3 into the table. It needed to be a custom function module as i need to call it in another function module which would concatenate the generated number with some words..
    i'm very new to abap programing...so could anyone please provide a detailed on how i could code it...
    THANKS alot in advance!!!!

    Hi Lessy,
    i have done the same requirement where my sequence number will automatically get incremented by 1 as new record cames for update.as already discussed you have to cretae the numebr range and call the number range by function module 'Number_get_next'.
    PFB the code which will definitely help you.
    CALL FUNCTION 'NUMBER_GET_NEXT'
            EXPORTING
              NR_RANGE_NR                   = '01'  " specify this number this is
    *the same when you cretae numberrange  have specified.
              OBJECT                        = 'ZSEQNUM'    " This the number range
    *i have created
           IMPORTING
             NUMBER                         = wa_msg-seqnr
           EXCEPTIONS
             INTERVAL_NOT_FOUND            = 1
             NUMBER_RANGE_NOT_INTERN       = 2
             OBJECT_NOT_FOUND              = 3
             QUANTITY_IS_0                 = 4
             QUANTITY_IS_NOT_1             = 5
             INTERVAL_OVERFLOW             = 6
             BUFFER_OVERFLOW               = 7
             OTHERS                        = 8.
          modify lt_message FROM wa_msg TRANSPORTING seqnr.
    to cretete number range.
    goto transaction SNRO
    enter the name,short text, give the number length domain (char10 or what ever is your domain)
    click on number range and cretae interval.
    give the number , from number and to number.
    this number you have to give in FM also (i have given '01').
    hope this will help you.for any problem revert back
    thanks
    Tanmaya
    Code Formatted by: Alvaro Tejada Galindo on Jan 13, 2010 4:16 PM
    Edited by: Rob Burbank on Jan 13, 2010 5:20 PM

  • Select options passed to function module

    Hey
    I would like to know how r the select-options of a program passed to the function module that is called internally in that program? I want to use this select-options in the function module to fetch frm the database tables?
    Shakr

    Hi,
    Use ranges in function modules. You can declare in import/export/ changing or tables parameters
    Example of ranges:
    ERDAT_RAN
    ERDAT_RAN
    SHP_R_ERZET
    RVBELN
    ERNAM_RAN
    Please see them in se11.
    Pass the select options in the report to these ranges or use below coding:
    DATA: wa_cmfre     LIKE     erdat_ran,
          wa_erdat     LIKE     erdat_ran,
          wa_erzet     LIKE     shp_r_erzet,
          wa_vbeln     LIKE     rvbeln,
          wa_ernam     LIKE     ernam_ran.
    SELECT-OPTIONS: s_erdat FOR vbak-erdat,                  s_erzet FOR vbak-erzet NO-EXTENSION,  
    s_cmfre FOR vbak-cmfre OBLIGATORY ,
    s_vbeln FOR vbak-vbeln NO-EXTENSION,         
    s_auart FOR vbak-auart OBLIGATORY,                           s_bsark FOR vbak-bsark.
      wa_cmfre-sign    = s_cmfre-sign.
      wa_cmfre-option  = s_cmfre-option.
      wa_cmfre-low     = s_cmfre-low.
      wa_cmfre-high    = s_cmfre-high.
      IF NOT s_erdat[] IS INITIAL.
        wa_erdat-sign   =  s_erdat-sign.
        wa_erdat-option =  s_erdat-option.
        wa_erdat-low    =  s_erdat-low.
        wa_erdat-high   =  s_erdat-high.
      ENDIF.
      IF NOT s_erzet[] IS INITIAL.
        wa_erzet-sign   =  s_erzet-sign.
        wa_erzet-option =  s_erzet-option.
        wa_erzet-low    =  s_erzet-low.
        wa_erzet-high   =  s_erzet-high.
      ENDIF.
      IF NOT s_vbeln[] IS INITIAL.
        wa_vbeln-sign   =  s_vbeln-sign.
        wa_vbeln-option =  s_vbeln-option.
        wa_vbeln-low    =  s_vbeln-low.
        wa_vbeln-high   =  s_vbeln-high.
      ENDIF.
      IF NOT s_ernam[] IS INITIAL.
        wa_ernam-sign   =  s_ernam-sign.
        wa_ernam-option =  s_ernam-option.
        wa_ernam-low    =  s_ernam-low.
        wa_ernam-high   =  s_ernam-high.
      ENDIF.
    you can pass these work areas to function module.
    Thanks,
    Shravan G.

  • Use of FOREIGN_FACTOR and LOCAL_FACTOR in Function module CONVERT_TO_LOCAL_

    Hi all ,
               could anyone tell me what is the use of  following two Export parameters in function module    CONVERT_TO_LOCAL_CURRENCY and why they are used for ,
    1.   FOREIGN_FACTOR (Factor for the foreign currency units)      and
    2.  LOCAL_FACTOR ( Factor for the local currency units ) .

    Hi Ramya ,
                        Thanks for your reply . But i would like to know what is the use of those two parameters and in what calculation it    is used. 
    The value which is to be converted is passed through  'foreign_amount ' parameter and it is returned after convertion by
    'local_amount ' parameter in the function module 'CONVERT_TO_LOCAL_CURRENCY' . Other than this  if we want to change the currency of another variable which is not passed to this function module  how can i do it ? Is it enough if i multiply that variable with the FIXED_RATE parameter which is returned by this function module as its value is same as exchange rate or do i need to
    use FOREIGN_FACTOR  and LOCAL_FACTOR  also for this calculation?
    Edited by: archana_nayak on Apr 25, 2010 9:52 AM

  • Need of Changing Parameters in Function Module

    Hi All,
    Why we need sepearte Import and Export parameters in Function Module if the Changing Parameters
    acts as both import and export parameters.
    What is the use of using Changing Parametrs in Function Module.
    Thanks in advance.
    Sundaresan

    Hi,
    EXPORT PARAMETERS: When u r passing some value to the function, and the parameter will not be changed in the function, we use export parameter. Example: u pass parameter (a : 10) to a function, even after the function has been executed, value of a will be 10 only.
    IMPORT PARAMETER: When u require some value back from the function. u do not provide any initial value to the function. Example : u pass a parameter (b: <blank>) to the function, function returns the same import parameter as (b : 20).
    CHANGING PARAMETER: When u pass some value to the function and that function may change that value inside function, then changing parameters are used. Example: u pass parameter ( c: 30) to the function as changing parameter and function modifies this variable and return ( c: 50).
    Reward points if helpful.
    Thanks & Regards
    - Rishika Bawa

  • Function module releated

    Dear All ,
    I have doubt regarding whether ,by default the import and export parameters in function modules are passed by value or by reference . And what is the use of check box which is given to check pass by value .

    Hi
      If i am not mistaking that you might have somewhat confusion in pass by value and pass by reference.
    There are three ways of passing parameters to a subroutine:
    Pass by reference
    Pass by value
    Pass By Value Example->
    report ztx1806.
    2  data: f1 value 'A'.
    3
    4  perform s1 using f1.
    5  write / f1.
    6
    7  form s1 using value(p1).
    8      p1 = 'X'.
    9      write / p1.
    10     endform.
    Pass By Reference=>
    With internal subroutines, there is little difference between passing parameters by reference and accessing global variables from within the subroutine. Both allow you to change the value of a global variable directly.
    Example->
    1  report ztx1804.
    2  data f1 value 'A'.
    3
    4  perform s1 using f1.
    5  write / f1.
    6
    7  form s1 using p1.
    8      p1 = 'X'.
    9      endform.
    So when you r using the import or export paramteters there it is pass by value bcz there you r using the internal table values not the reference of the internal table reference but some cases import and export parameter also pass the value in reference.
    As per your doubt in check box the check box value is passed by value not the reference.There is no specific reason why the check box is pass by value or reference.ITs all done as per the requirements.
    Thanks
    Mrutyunjaya Tripathy

Maybe you are looking for