Dynamic parameters in function module

Hi. I need to write a program that can call various different function modules based on what the user inputs.
For example, if the user chooses "BAPI_USER_GET_DETAIL" I need to then call that function module. There is a list of about 30 functions they can choose from.
I can read in the function interface using FUNCTION_IMPORT_INTERFACE and have got the import, changing and tables parameters being entered in an editable ALV.
Now I just need to work out how to call the function module.
I could spend ages hard coding all the various combinations, but what I would like to do is call the function totally dynamically.
I know this wouldn't work, but this sort of thing:
CALL FUNCTION p_funct
   EXPORTING
          <imp_1> = <val_1>
          <imp_2> = <val_2>.
Has anyone got any ideas?
Thanks a lot,
Dave.

Hi. I think you've solved it, thanks a lot.
Just checking it all now, will be back shortly.
Can't believe it was that simple, spent ages looking through SDN and google. I was searching for dynamic function, not bapi, so I missed that posting too.
Regards,
Dave.

Similar Messages

  • How to log input parameters for Function Modules?

    Hi,
    I need to create a Logging system to trace input parameters for function modules.
    The log functionality could be done by developing a class method or a function module (For example 'write_log'), and calling it within each function module that I want to log. The 'write_log' code should be independent from the interface of the Function Module that I want to log.
    For example, I'd like to write a function/class method that can log both these functions modules:
    Function DummyA
       Input parameters: A1 type char10, A2 type char10.
    Function DummyB
       Input parameters: B1 type char20, B2 type char20, B3 type char20, B4 type Z_MYSTRUCTURE
    Now the questions...
    - Is there a "standard SAP" function that provide this functionality?
    - If not, is there a system variable in which I can access runtime all parameters name, type and value for a particular function module?
    - If not, how can I loop at Input parameters in a way that is independent from the function module interface?
    Thank you in advance for helping!

    check this sample code. here i am capturing only parameters (import) values. you can extend this to capture tables, changin, etc.
    FUNCTION y_test_fm.
    *"*"Local Interface:
    *"  IMPORTING
    *"     REFERENCE(PARAM1) TYPE  CHAR10
    *"     REFERENCE(PARAM2) TYPE  CHAR10
    *"     REFERENCE(PARAM3) TYPE  CHAR10
      DATA: ep TYPE STANDARD TABLE OF rsexp ,
            ip TYPE STANDARD TABLE OF rsimp ,
            tp TYPE STANDARD TABLE OF rstbl ,
            el TYPE STANDARD TABLE OF rsexc ,
            vals TYPE tihttpnvp ,
            wa_vals TYPE ihttpnvp ,
            wa_ip TYPE rsimp .
      FIELD-SYMBOLS: <temp> TYPE ANY .
      CALL FUNCTION 'FUNCTION_IMPORT_INTERFACE'
        EXPORTING
          funcname                 = 'Y_TEST_FM'
    *   INACTIVE_VERSION         = ' '
    *   WITH_ENHANCEMENTS        = 'X'
    *   IGNORE_SWITCHES          = ' '
    * IMPORTING
    *   GLOBAL_FLAG              =
    *   REMOTE_CALL              =
    *   UPDATE_TASK              =
    *   EXCEPTION_CLASSES        =
        TABLES
          exception_list           = el
          export_parameter         = ep
          import_parameter         = ip
    *   CHANGING_PARAMETER       =
          tables_parameter         = tp
    *   P_DOCU                   =
    *   ENHA_EXP_PARAMETER       =
    *   ENHA_IMP_PARAMETER       =
    *   ENHA_CHA_PARAMETER       =
    *   ENHA_TBL_PARAMETER       =
    *   ENHA_DOCU                =
       EXCEPTIONS
         error_message            = 1
         function_not_found       = 2
         invalid_name             = 3
         OTHERS                   = 4
      IF sy-subrc = 0.
        LOOP AT ip INTO wa_ip .
          MOVE: wa_ip-parameter TO wa_vals-name .
          ASSIGN (wa_vals-name) TO <temp> .
          IF <temp> IS ASSIGNED .
            wa_vals-value = <temp> .
          ENDIF .
          APPEND wa_vals TO vals .
        ENDLOOP .
      ENDIF.
    ENDFUNCTION.

  • What are  the input parameters for Function Module

    Dear Experts,
    I want to generate a Sales Tax returns report,those fields are not available in my existing Datasources.
    For that i want to write a Generic Datasource with Function Module.
    audat
    bukrs
    vkorg
    vtweg
    spart
    aurat
    auart
    netwr
    mwsbp
    kschl zedp(consition type)
    kschl zvat(condition type)
    ksch   zcst(condition type)
    matkl     material group
    Here what are the Input parameters for Function Module.
    Thanks in Advance.
    Srinivasan.

    Srinivasan-
    For creating a Generic extractor based on a FM, you first of all need to know what is going to be your structure.. i.e. what all fields you need to pull from what all tables. A functional consultant may help you identify the exact DB tables.
    Once you know them, hand over the requirement and the pdf mentioned by Krishna to the ABAP guy, he would be able to take this up further.
    Also decide 1st whether you would be using a full load or delta. There is a slight difference in the way they are built.
    Let me know how it goes.
    -Bhushan.

  • 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

  • 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

  • Probelem with passing parameters to function module

    hey i am facing a problem to pass the parameters to function module.let me explain.. we cant pass the parameters which we are using in the select option statements directly to a function module called...i just wanna know if there is any way so that i can pass those values to a fnc module while passing it from select options

    Hi,
    You have to create a table type in SE11..
    Check this sample table type PDSMAINT_MATNR_RNG_T...
    Then use that table type in the importing parameter of FM..
    PT_MATNR TYPE PDSMAINT_MATNR_RNG_T..
    For which field you have created select-options..I will check if there is any existing table type in se11..
    Thanks,
    Naren

  • What are the parameters of Function Module

    Hi,
    What are the parameters of Function Module?

    Function Modules are special external subroutine stored in a central library. The R/3 system provides numerous predefined function modules that you can call from the ABAP/4 programs.
    All the function Modules are created under the Function Groups. Function Groups are nothing but the related group of function modules.
    The function modules can be maintained through T.CodeSE37 and T.Code SE80.
    In general the function module has the following components.
    Documentation:
    This is the place where you can find the discription/purpose of the function module.
    Import & Export Parameters.
    Import parameters correspond to the formal input parameters of subroutines. They pass data from the calling program to the function module.
    Export parameters correspond to the formal input parameters of subroutines. They pass data from the function module back to the calling program.
    Table Parameters.
    Table parameters are internal tables. Internal tables are treated like changing parameters and are always passed by reference.
    Exceptions.
    Exceptions are used to handle error scenarios which can occur in the function modules. The function modules checks for any type of error and raise exception and returns SY-SUBRC value to the calling program.
    Source Code:
    the programming logic of the function module is written in this source code.
    Rewards if useful.

  • Dynamic Actions with Function Module

    Hai all,
    I got a problem while doing Dynamic Actions. I want to delete a record from 0105 infotype and it is through dynamic actions using function module. All things going correct but in the database table the entry was not deleted. While debugging it was giving as deleted but actually it is not deleting in database table. I hope u help me out.
    Thanks,
    Tara.

    Hai Srimantra,
    Thanks for ur response and here iam sending the code where i used the function module. and i called the subroutine from sm30.
    I should not use any sql statements or commands to delete the records from database tabels. hope u will help me out.
    Thank u,
    Tara.
    TABLES p0105.
    *data: lw_0105 type p0105.
    TABLES: pspar.
    *&      Form  HR_INFOTYPE_OPERATION
          text
    FORM hr_infotype_operation.
      DATA: l_it_pa0105 TYPE STANDARD TABLE OF pa0105.
      DATA: l_it_p0105 TYPE STANDARD TABLE OF p0105.
      DATA: l_p0105 TYPE p0105.
      DATA: wa_pa0105 TYPE pa0105.
      DATA: l_return TYPE bapireturn1.
      break developer.
      SELECT SINGLE * FROM pa0105 INTO CORRESPONDING FIELDS OF l_p0105
      WHERE pernr EQ p0105-pernr AND
            subty EQ p0105-subty AND
            begda EQ p0105-begda AND
            endda EQ p0105-endda AND
            seqnr EQ p0105-seqnr AND
            objps EQ p0105-objps AND
            sprps EQ p0105-sprps.
      CHECK sy-subrc EQ 0.
      CALL FUNCTION 'HR_INFOTYPE_OPERATION'
         EXPORTING
           infty                  = '0105'
           number                 = l_p0105-pernr
           subtype                = l_p0105-subty
           objectid               = l_p0105-objps
           lockindicator          = l_p0105-sprps
           validityend            = l_p0105-endda
           validitybegin          = l_p0105-begda
           recordnumber           = l_p0105-seqnr
           record                 = l_p0105
           operation              = 'DEL'
          TCLAS                  = 'A'
          NOCOMMIT               =
          VIEW_IDENTIFIER        =
          SECONDARY_RECORD       =
        IMPORTING
          return                 = l_return.
          KEY                    =
      MESSAGE l_return-message TYPE 'S'.
    ENDFORM.                    "HR_INFOTYPE_OPERATION

  • Dynamic Table Selection function module

    Dear Friends,
      We have got critical requirement on Custom BAPI function module :
         we have to pass one field name of table and table name : Eg (Matnr and MARC).
         we have to get table contents w.r.t field name of table and table : Has to display MARC based on Matnr.
    (It is something like we display table contents in SE11 and SE16, Our requirement is to get the data by giving  random field name of table and table name ).
    My View : Imports Tab of F.M of is static
                   Tables Tab of F.M could be dynamic....if so how to achieve or any other approach?
    Note :  Eg1 : Matnr and MARA  (Input to F.M) -
    > Get MARA contents (Table from F.M)
               Eg2 : Matnr and MARC (Input to F.M) -
    > Get MARC contents (Table from F.M)
               Eg3 : Lifnr and LFA1 (Input to F.M)  -
    > Get LFA1 contents (Table from F.M)       
               Eg1 : Ebeln and EKKO (Input to F.M)  -
    > Get EKKO contents (Table from F.M)
    Awaiting for positive and quick views.
    Regards
    Sekhar

    Dear Sarcevic,
       I have created zfunction module with imports and tables.
      I'm able to manage import parameters as dynamical, but tables declaration gives fuzzy.
      How do we make tables tab declaration in function module as dynamic? any other views?
    Regards
    Sekhar

  • Passing dynamic table to function module

    Hi all,
    actully i have to pass dynamic internal table from function module.
    for that i use syntax
    move <dyn_table> to data_tab.
    but now my question is that in fm parameters what is the  type spec & associated type for data_tab in fm parameters.
    regards,
    anuj

    Hi
    Good
    Here is a simple example of passing an internal table "itab" to a function module "REUSE_ALV_LIST_DISPALY".
    It displays the internal table data into a list format.
    data : itab like ztest213 occurs 0 with header line.
    tables : ztest213 .
    select * from ztest213 into table itab.
    loop at itab.
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = ' '
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
    i_structure_name = 'ztest213'
    IS_LAYOUT =
    IT_FIELDCAT =
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    IT_EVENTS =
    IT_EVENT_EXIT =
    IS_PRINT =
    IS_REPREP_ID =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IR_SALV_LIST_ADAPTER =
    IT_EXCEPT_QINFO =
    I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    tables
    t_outtab = itab
    exceptions
    program_error = 1
    others = 2
    if sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endloop.
    Thanks
    mrutyun^

  • What are minimum passing parameters for function module CS_BOM_EXPL_MAT_V2

    Hi
    Im going to use FM: CS_BOM_EXPL_MAT_V2 and I want to only pass WERKS, but when I execute FM is gives exception as CALL_INVALID.
    I saw all the Import parameters are Optional, but I think I need to pass more inputs to FM.
    Please let me know what are MINIMUM input parameters required to run this FM
    Thanks

    Hi
    In my requirement, there are range of WERKS and MATNR which has to be given from selection screen, where as In CS_BOM_EXPL_MAT_V2 function module I can only give single value for WERKS and MATNR.
    Can any one guide me how can I implement this?

  • Structure of Dynamic Table in Function Module

    Hi,
    I'm trying to find a way to get as OUTPUT a dynamic Table from a Function Module.
    I declared a table called T_DATA without a type.
    And this table should have a dynamic table back.
    The problem that I get the data back but, I only found a data without any field-elements.
    The data is there but there's no structure, no table.
    Is there any way that I can send the Data in a proper structure?

    Hi
       Try using the following code
    type-pools:slis.
    data:it_fcat type lvc_t_fcat,
         wa_fcat type lvc_s_fcat,
         itab type ref to data.
    data:it_fcat1 type slis_t_fieldcat_alv,
         wa_fcat1 like line of it_fcat1.
    data:cl_tab type ref to cl_alv_table_create,
         wa_ref type ref to data.
    field-symbols:<itab> type table,
                  <wa> type any,
                  <comp>.
    create object cl_tab.
    refresh:it_fcat.
    wa_fcat-fieldname = 'NAME'.
    wa_fcat-inttype  = 'C'.
    wa_fcat-intlen = '10'.
    wa_fcat1-fieldname = 'NAME'.
    wa_fcat1-inttype  = 'C'.
    wa_fcat1-intlen = '10'.
    append wa_fcat to it_fcat.
    append wa_fcat1 to it_fcat1.
    wa_fcat-fieldname = 'NAME2'.
    wa_fcat-datatype  = 'CHAR10'.
    wa_fcat1-fieldname = 'NAME2'.
    wa_fcat1-datatype  = 'CHAR10'.
    append wa_fcat to it_fcat.
    append wa_fcat1 to it_fcat1.
    cl_alv_table_create=>create_dynamic_table(
      exporting
       I_STYLE_TABLE             = I_STYLE_TABLE
        it_fieldcatalog           = it_fcat
       I_LENGTH_IN_BYTE          = I_LENGTH_IN_BYTE
      importing
        ep_table                  = itab
       E_STYLE_FNAME             = E_STYLE_FNAME
    EXCEPTIONS
       GENERATE_SUBPOOL_DIR_FULL = 1
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    assign itab->* to <itab>.
    create data wa_ref like line of <itab>.
    assign wa_ref->* to <wa>.
    do.
      assign component 'NAME' of structure <wa> to <comp>.
      <comp> = 'AA'.
      unassign <comp>.
      assign component 'NAME2' of structure <wa> to <comp>.
      <comp> = 'AB'.
      insert <wa> into table <itab>.
      exit.
    enddo.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = sy-repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  = I_STRUCTURE_NAME
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      = I_GRID_TITLE
      I_GRID_SETTINGS                   = I_GRID_SETTINGS
      IS_LAYOUT                         = IS_LAYOUT
       it_fieldcat                       = it_fcat1
      IT_EXCLUDING                      = IT_EXCLUDING
      IT_SPECIAL_GROUPS                 = IT_SPECIAL_GROUPS
      IT_SORT                           = IT_SORT
      IT_FILTER                         = IT_FILTER
      IS_SEL_HIDE                       = IS_SEL_HIDE
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        = IS_VARIANT
      IT_EVENTS                         = IT_EVENTS
      IT_EVENT_EXIT                     = IT_EVENT_EXIT
      IS_PRINT                          = IS_PRINT
      IS_REPREP_ID                      = IS_REPREP_ID
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   = IT_ALV_GRAPHICS
      IT_HYPERLINK                      = IT_HYPERLINK
      IT_ADD_FIELDCAT                   = IT_ADD_FIELDCAT
      IT_EXCEPT_QINFO                   = IT_EXCEPT_QINFO
      IR_SALV_FULLSCREEN_ADAPTER        = IR_SALV_FULLSCREEN_ADAPTER
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           = E_EXIT_CAUSED_BY_CALLER
      ES_EXIT_CAUSED_BY_USER            = ES_EXIT_CAUSED_BY_USER
      tables
        t_outtab                          = <itab>
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
    Regards

  • Use of Interface parameters in Function module in ECC 6.0

    Hello all,
    In ECC 6.0 Version we do not use Changing/Tables interface parameters. Instead we declare a table type and use Exporting Parameters.
    Can any one send me the link to sap help where this is mentioned.
    Thanks,
    Salil

    Should be straight forward. Here's a sample...
    Exporting...
    VBSK_E     LIKE     VBSK
    ET_SPLITPROT     TYPE     VLIKP_T_SPLITPROT
    If not enough, do application help from function module....
    http://help.sap.com/saphelp_nw04/helpdata/en/d1/801e9a454211d189710000e8322d00/frameset.htm

  • How to pass parameters to function module

    Hello,
    Can someone suggest how to pass parameter values to BAPI function module from a .NET client? I am using the BAPI_PO_GETDETAILS module and want to pass required parameters to get the item details. Also, please let me know which table should I refer to when retrieving the result. I am using sap .net connector 3.0.
    Thanks in advance

    Hi unosino,
    at http://www.se80.co.uk/sapfms/b/bapi/bapi_po_getdetail.htm you can see, that you have to pass po_header and po_address to the function.
    You can do that with the nco3 like this:
    IRfcFunction rfcFunction = destination.Repository.CreateFunction("BAPI_PO_GETDETAILS");
    rfcFunction.SetValue("po_header", /* your value */);
    rfcFunction.SetValue("po_address", /* your value */);
    rfcFunction.Invoke(destination);
    kind regards
    christian
    Edited by: chrislind on Nov 11, 2011 2:47 PM

  • Importing parameters in Function Module SD_VBFA_ARRAY_READ_VBELV

    Hi All,
    Please let me know the use of importing parameters in the Function Module SD_VBFA_ARRAY_READ_VBELV.
    The importing parameters are,
    I_BYPASSING_BUFFER
    I_REFRESH_BUFFER
    I'm having problem of memory overflow in the function module so I thought these importing parameters may help me.
    Kindly explainn me the use of these importing parameters and tell me whether they help m out to avoid memory overflow problem.
    Thanks a lot in advance,
    Rama Krishna

    Hello Rama
    If you bypass the buffer the fm will always read directly from the DB.
    And if you refresh the buffer the buffer is cleared and will be filled again with every call of the fm.
    Regards
      Uwe

Maybe you are looking for