How to call a function module dynamically?

Hi
I am doing a smartform development and here my scenario.
<b>Scenario:</b>
There will be a simple report which will trigger a smartform output. The report has a selection screen and and in one of the field the user will enter the layout name or the layout name will be stored in the variant so that the user need not remember the layout name.
Based on the layout selected i need to show the output.
<b>What i have coded:</b>
In my program after selecting the data i am calling the FM SSF_FUNCTION_MODULE_NAME which will return the function module name to be called.
<b>Question:</b>
How do i call the function module dynamically. I cannot do a single call to the function module using the FM name derived from the above function call. I want to make the interface calling dynamic. We dont want to hardcode the function calls coz we may have many layouts to be called so how is it possible in SAP to call the FM interface dynamically.
~Suresh

Actually you can call the FM dynamically in by taking it into one variable and than use the CALL FUNCTION V_FM_NAME.
But the problem here is, you need to take care about the importing, exporting and tables parameters. They needs to be same for all FMs which you are planning to call. Otherwise system will give you a run time error.
   CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
         EXPORTING  FORMNAME           = LF_FORMNAME
*                 variant            = ' '
*                 direct_call        = ' '
         IMPORTING  FM_NAME            = LF_FM_NAME
         EXCEPTIONS NO_FORM            = 1
                    NO_FUNCTION_MODULE = 2
                    OTHERS             = 3.
      CALL FUNCTION LF_FM_NAME
           EXPORTING
                      ARCHIVE_INDEX        = TOA_DARA
                      ARCHIVE_PARAMETERS   = ARC_PARAMS
                      CONTROL_PARAMETERS   = LS_CONTROL_PARAM
*                 mail_appl_obj        =
*                     mail_recipient       = ls_recipient
                      MAIL_SENDER          = LS_SENDER
Regards,
Naimesh Patel

Similar Messages

  • How can call a function module(RFC)in one server to another sever in my rep

    How can call a function module(RFC)in one server to another sever in my report program.
    What i am know whenever rfc enabled immediately radio button checks then only it will come.
    please justify.

    Syntax
    CALL FUNCTION func DESTINATION dest [EXPORTING p1 = a1 p2 = a2 ...]
    [IMPORTING p1 = a1 p2 = a2 ...]
    [CHANGING p1 = a1 p2 = a2 ...]
    [TABLES t1 = itab1 t2 = itab2 ...]
    [EXCEPTIONS [exc1 = n1 exc2 = n2 ...]
    [system_failure = ns [MESSAGE smess]]
    [communication_failure = nc [MESSAGE cmess]]
    [OTHERS = n_others]].
    http://help.sap.com/saphelp_47x200/helpdata/en/22/042537488911d189490000e829fbbd/frameset.htm

  • How to call a function module from the Web Template?

    Hi all,
    how can I call a function module from a BI 7.x web template and then show the result of the FM on the web template?
    Many thanks for your hints.
    Regards, Nils

    Hi!
    I am too working on a similar issue.
    Probably this helps:
    Re: Calling a function module from a Web Template
    Regards,
    Sri

  • How to call a function module from a transformation

    Hi,
    Could somebody please let me know how I can call an abap function module from a transformation (abap xslt program). I know how to call the class methods from transformation, but how do i call a function module..?
    Thanks,
    Shashi.
    Edited by: Shashi Kanth Kasam on Apr 8, 2010 12:45 PM

    Ya. I can do that. But I don't want to use a class and a method to call that function module. Want to directly call function module from transformation. Is that possible..?
    Thanks,
    Shashi

  • How to call a function module in VC

    Hi,
    I want to call a function module for an addition formula which shall calculate and infer the value.
    eg. quantities of 5 different characteristics (of numeric data) is to be summed up and inferred against the 6th characteristic.
    I want to know the detailed process to create a Variant Function and use it in a dependency.
    Request to please advise the steps, type of dependency and its code.
    Regards,
    Rajesh Mohapatra

    Dear Rajesh,
    I also wanted to learn how to do that, your post motivated me to use a bit of freetime and investigate on the subject. I finally made my function work, so here are the tips.
    The example is very simple, just a variant function with two inputs and which multiplies inside the input values and transfer that result to the output ( 3 x 4 => 12 ).
    Deducting how to add five values or any other logic would be easier starting from there.
    STEP 1: Create Variant Class for the product. I imagine you already have that. In my case its name is ZVC_CLASS, you have already a material assigned to the class, a configuration profile, etc....
    STEP 2: Create Three Characteristics Z_NUM_CH_1,Z_NUM_CH_2,Z_NUM_CH_3 the three of numeric type
    STEP 3: Assign characteristics from step 2 into class ZVC_CLASS
    STEP 4: Create the function module with the code given below. I put the name ZVC_FUN_TEST
    FUNCTION ZVC_FUN_TEST.
    ""Interfase local
    *"  IMPORTING
    *"     REFERENCE(GLOBALS) TYPE  CUOV_00
    *"  TABLES
    *"      QUERY STRUCTURE  CUOV_01
    *"      MATCH STRUCTURE  CUOV_01
    *"  EXCEPTIONS
    *"      FAIL
    *"      INTERNAL_ERROR
    *- Inicializar los valores.
      DATA:
      GV_VALOR_FINAL        TYPE CUOV_01-ATFLV,
      GV_VALOR_NUM1         TYPE CUOV_01-ATFLV,
      GV_VALOR_NUM2         TYPE CUOV_01-ATFLV.
      CLEAR:
        gv_valor_final,
        gv_valor_num1,
        gv_valor_num2.
    CALL FUNCTION 'CUOV_GET_FUNCTION_ARGUMENT'
        EXPORTING
          ARGUMENT            =  'Z_NUM_CH_1'
        IMPORTING
         VTYPE               =  P_VTYPE1
         SYM_VAL             =  P_VALOR_SYM1
          NUM_VAL             =  gv_valor_num1
      IO_FLAG             =
        TABLES
          QUERY               =  QUERY
        EXCEPTIONS
          ARG_NOT_FOUND       = 01.
      IF SY-SUBRC <> 0.
        RAISE INTERNAL_ERROR.
      ENDIF.
    CALL FUNCTION 'CUOV_GET_FUNCTION_ARGUMENT'
        EXPORTING
          ARGUMENT            =  'Z_NUM_CH_2'
        IMPORTING
         VTYPE               =  P_VTYPE1
         SYM_VAL             =  P_VALOR_SYM1
          NUM_VAL             =  gv_valor_num2
      IO_FLAG             =
        TABLES
          QUERY               =  QUERY
        EXCEPTIONS
          ARG_NOT_FOUND       = 01.
      IF SY-SUBRC <> 0.
        RAISE INTERNAL_ERROR.
      ENDIF.
    *- Calculate final value
      gv_valor_final = gv_valor_num1 * gv_valor_num2.          "Especifico de c/u.
    DATA: VTYPE TYPE CUOV_01-ATFOR.
    VTYPE = 'NUM'.
    CALL FUNCTION 'CUOV_SET_FUNCTION_ARGUMENT'
        EXPORTING
          ARGUMENT                = 'Z_NUM_CH_3'
          VTYPE                   = VTYPE
          NUM_VAL                 =  gv_valor_final
        TABLES
          MATCH                   = MATCH
        EXCEPTIONS
          EXISTING_VALUE_REPLACED = 01.
      IF SY-SUBRC <> 0.
        RAISE INTERNAL_ERROR.
      ENDIF.
    ENDFUNCTION.
    STEP 5: Activate the function module for Variant Configuration in transaction CU65, put there your function module, release int and in button characteristics write  Z_NUM_CH_1,Z_NUM_CH_2,Z_NUM_CH_3. Flag the first two lines as they are inputs.
    STEP 6: Create a Dependency ZVC_PROC_TEST of type Procedure to call the function with this code:
    000010 Function ZVC_FUN_TEST           
    000020 (Z_NUM_CH_1 = $root.Z_NUM_CH_1, 
    000030 Z_NUM_CH_2 = $root.Z_NUM_CH_2,  
    000040 Z_NUM_CH_3 = $self.Z_NUM_CH_3)  
    STEP 7: Lets say I want to calculate the multiplication only upon the selection of another characteristic "Calculate" YES/NO. For this I create a characteristic in CT04 Z_CALCULATE type CHAR 1 with possible values Y or N. For the value Y y add the procedure ZVC_PROC_TEST so that formula only activates on Y.
    STEP 8: Add characteristic Z_CALCULATE to class  ZVC_CLASS
    STEP 9: VA01, it should work

  • How to call a function module from a workflow ? ?

    hi all,
    i have to call a function module from an workflow, i got a hint from someone that i have to enhance an object and then write and methode, in this methode i can call that function module. I dont know even how to go for it.
    Can anyone suggest that how to go for it ?
    thanks.
    raman khurana.

    Hi Raman Khurana,
    Please  go through the links it might be helpful , notsure
    http://help.sap.com/saphelp_nw2004s/helpdata/en/c5/e4af8b453d11d189430000e829fbbd/content.htm
    http://www.abapcode.info/2007/07/standard-function-module-text.html
    http://it.toolbox.com/wiki/index.php/SAP_Workflow
    Regards,
    Sreekar.Kadiri.

  • How to call a function module from debugger?

    Hi all,
           i just wanted to know whether we can call a function module from a debugger ,
           if yes how ?

    Hi Laxmikanth,
    How ur going to call a function module which is not present in program???
    In debugging mode u can change the values of variables,put break points and watch points,but i thnk its not possible to call a function module(not present in program) while debugging .
    Please share with us if u have any solution...
    Regards,
    lakshman.

  • How to call Z-Function module from BAPI_IDOC_INPUT1.

    Hi All,
    Process code is :BAPI and standard function module is  BAPI_IDOC_INPUT1.
    I am coding all the logic for the INBOUND IDOC in the Z-Function module ZIDOC_INPUT_ZGOODSMOVEMENTOIL.
    My requirement is:
    Process code fires the inbound function module BAPI_IDOC_INPUT1, this in turn call the function module ZIDOC_INPUT_ZGOODSMOVEMENTOIL.
    How can i call ZIDOC_INPUT_ZGOODSMOVEMENTOIL from BAPI_IDOC_INPUT1 to process the idoc.
    Thanks in Advance.
    Regards,
    Umesh

    Hi Krush,
    Thanks for your reply,
    Now i can trigger the idoc.
    I have one more problem that if i want to add another z-segment to the attached idoc type its not allowing me its saying that it is already generated and cannot be changed.
    if i am generating the BDBG transaction its not asking for specific segment and it automatically takes the segment and generates the function module.
    How  i can add an additinal z-segment to the idoc type and it generate through BDBG transaction to include in inbound function module?
    Thanks in Advance.
    Regards,
    Umesh

  • How to create RFC function module and how to call this function module

    Hi,
    i want to know step for creating RFC function module and then How to  use this function module from some other sap system.
    Thnaks,
    jigar

    Jigar,
    To implement a remote function module in ABAP, perform the following steps:
    Register the module as remotely callable in the RFC server system.
    In the function module Administration screen (transaction code SE37), set the field Can be called via REMOTE CALL. Registering a module as remote causes an RFC stub to be generated for it.
    Write the code for the function module.
    Create the destinations.....................
    Displaying, Maintaining and Testing Destinations
    To display, create or modify destinations, choose Tools ® Administration ® Administration ® Network ® RFC destinations or enter transaction code SM59.
    Remote Destinations are stored in table RFCDES. The RFCDES table describes logical destinations for remote function calls.
    It is not possible to maintain the RFCDES table directly.
    You can also access logical destinations via the Implementation Guide (IMG) by choosing Tools ® AcceleratedSAP ® Customizing ® Execute Project ® SAP Reference IMG.
    In the Implementation Guide, expand the following hierarchy structure:
    Basis
    Application Link Enabling (ALE)
    Sending and Receiving Systems
    Systems in Network
    Define Target Systems for RFC Calls
    Displaying Destinations
    The initial screen for this transaction displays a tree:
    Different connection types (i.e. partner systems or programs) are possible. For further information, see Types of Destinations.
    To display all information for a given destination, double-click it, or place the cursor on it and press F2 .
    To search for a destination, press the Find button and specify your selection. You get a list of all entries matching your selection. Place the cursor on the one you want, and press F2 or simply double-click the destination. All information for the given entry appears.
    Creating Destinations
    On the destinations overview screen (transaction code SM59), the connection types and all existing destinations are displayed in a tree structure.
    All available connection types are explained in Types of Destinations.
    To create a new RFC destination, press the Create button. A new screen is displayed with empty fields for you to fill in.
    If you want to create a new destination
    As you create a remote destination, you can specify a particular application server or a group of servers for a balanced distribution of system load.
    For details of the destination parameters, see Entering Destination Parameters.
    Changing Existing Destinations
    On the destinations overview screen (transaction code SM59), the connection types and all existing destinations are displayed in a tree structure.
    You can display all information for a given destination by double-clicking it or pressing F2 on it.
    To change an existing destination, double-click it, or place the cursor on it and press the Change button.
    For details of the destination parameters, see Entering Destination Parameters.
    Testing Destinations
    To test a destination, choose the appropriate function from the Test menu.
    Connection (also available via the Test connection pushbutton)
    Authorization (checks logon data)
    Local network (provides a list of application servers)
    You can use the CALL FUNCTION statement to call remote functions, just as you would call local function modules. However, you must include an additional DESTINATION clause to define where the function should run:
    CALL FUNCTION RemoteFunction
    DESTINATION Dest
    EXPORTING
    f1 =...
    f2 =...
    IMPORTING
    f3 =...
    TABLES
    t1 =...
    EXCEPTIONS......
    The field Dest can be either a literal or a variable: its value is a logical destination (for example, "hw1071_53") known to the local SAP System. Logical destinations are defined in the RFCDES table (or the TRFCD table in R/2 Systems) via transaction sm59 or the following menu path: Tools ® Administration, Administration ® Network ® RFC destinations. You can also access logical destinations via the Implementation Guide (IMG) by choosing Tools ® Customizing ® Enterprise IMG. In the Implementation Guide, you can then choose Cross-application components ® ALE ® Communication ® Define RFC destination.
    The remote function call concept, for example, allows you to access a function module in an R/2 System from an ABAP program in an R/3 System. If you want to read a customer record from your R/2 System’s database, create a remotely callable function module in the R/2 environment which retrieves customer records. Call this function from your R/3 System using a remote function call and listing the destination for the target R/2 System:
    Pls. reward if useful

  • How to call a Function Module in a BSP Page?

    Hi there,
    i have no deep knowledge about BSP Programming.
    So what i wanna do is to call a Function Module in a BSP Site..
    I go to SE80... create a new empty BSP Application under that a Page with FlowLogic:
    I see the new empty BSP Page with this Test Button and Hello world in it.
    So my Funtion Module is called Z_Subscribe
    What i have to do that the FM is called when i open the BSP?
    Thanks
    Bjoern
    Edited by: bjoern bayerschmidt on Mar 3, 2009 1:01 PM

    Hi Bjoem,
    Search the forum for tutorials and blogs...
    Regards,
    Anubhav

  • How to call javascript function with dynamic data in display tag

    Hi,
    Iam new to pagination concept. Iam using display tag to display rows in jsp by strtus.
    I have a problem when calling the javascript function using ahref in attribute in display tag.
    <bean:define name="form1" property="EditDetails.List" id="ListDisplay"/>
    <display:table name="pageScope.ListDisplay" cellpadding="0" cellspacing="1" pagesize="10" partialList="false" size="listSize" requestURI="">
    <display:column property="poNo" href='javascript:searchEditDetails("./submitOrder.do? actionID=getMISLoadEdit&poNumberSel=<%=((com.po.bean.EditDetails)poListDisplay).getNo()%>&statusIdSelected=<%=((com.po.bean.EditDetails)ListDisplay).getStatusId()%>")'
    title="Number"/>                         
    <display:column property="strDate"title="Date" />
    <display:column property="orderValue"title="Order Value(INR)"/>
    <display:column property="stringRequestedDeliveryDate"title="Suggested Delivery Date"/>
    <display:column property="statusDescription" title="Status" />
    </display:table>
    The above code display the data in row format is working fine when I click the No It thow javascript error and its not redirecting to the other page.
    When I try this with ordinary struts its working fine the code is:
    <logic:iterate id="polist" name="Form1" property="EditDetails.List" indexId="i" type="com.bean.EditDetails">
    <tr>
    <td ><a href="javascript:searchEditDetails("./submitOrder.do?actionID=getMISLoadEdit&NumberSel=<%=((com.bean.EditDetails)polist).getNo()%>&statusIdSelected=<%=((com.bean.EditDetails)polist).getStatusId()%>")"><html:hidden name="polist" property="No" write="true" /></a>     </td>
    <td><html:hidden name="polist" property="strDate" write="true" /></td>
    <td><html:hidden name="polist" property="orderValue" write="true" /></td>
    <td><html:hidden name="polist" property="stringRequestedDeliveryDate" write="true" />     </td>
    <td><html:hidden name="polist" property="statusDescription" write="true" /></td>
    </tr>
    </logic:iterate>
    Please help me how to call javascript with dynamic data.
    Thanks in advance

    The ADF Mobile Container Utilities API may be used from JavaScript or Java.
    Application Container APIs - 11g Release 2 (11.1.2.4.0)

  • How to call ABAP function module/ class method through web service?

    Hi Colleagues,
    I need to write an iphone version of current ABAP program. I want to call ABAP method and function module through my iphone so that I can re-use the ABAP APIs.So I choose web service. Can you give me any details information about how to do that?
    Thank you very much

    Hi,
    you need to create webservice out of FM. goto SE80 and follow the webservice creation wizard. Finally use webservice url for calling FM (remote enabled) from your iPhone.
    Regards,
    Gourav

  • Calling Function Modules Dynamically

    Hi All,
           Is it possible to call a function module dynamically i.e. to pass the module name and the import and export parameters dynamically at runtime. Please provide a way of achieving this.
    Regards,
                 Milan Thaker

    Hello,
    Read this SAP documentation on calling function modules dynamically: [http://help.sap.com/abapdocu_70/en/ABAPCALL_FUNCTION_DYNAMIC.htm|http://help.sap.com/abapdocu_70/en/ABAPCALL_FUNCTION_DYNAMIC.htm] Here you have an example explaining the technique.
    Also check this link on [ABAP FAQs|http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/840ad679-0601-0010-cd8e-9989fd650822#q-29].
    Cheers,
    Suhas
    Edited by: Suhas Saha on Mar 9, 2010 3:33 PM

  • Can we call a function module in ADHOC query

    Hi
    Can we call a function module in ADHOC query if yes how.
    Also we ned to know how to call a function module in SAP query.
    An early responce is appreciated.
    Thanks and best regards
    Rajeev

    Okay as far as I understand your aim is:
    To fill a field in the output list with a value that is based on the current line information and calculated by a function module
    So go to SQ02 and create an additional field in the InfoSet.
    You can refer in the coding to the technical names you can see in the left tree window like P0000-PERNR.
    More information is avaiable in the Help part look for additional field in SQ02.
    Regards,
    Michael

  • How to delete Thr created functional module dynamically

    Hi All,
    How to delete Thr created functional module dynamically
    Regards,
    Lisa
    Message was edited by:
            Lisa Roy

    Hi,
    You can use the function module RS_FUNCTION_DELETE to do that.
    Make sure you are not deleting any standard FM's.
    Example
          call function 'RS_FUNCTION_DELETE'
               exporting
                    funcname          = 'ZFM_NAME" " Function modue name
                    suppress_popups   = 'X' " TO suppress any pop-ups that come when you delete
               exceptions
                    error_message     = 1
                    cancelled         = 2
                    function_released = 3
                    others            = 4.
    Regards,
    Sesh

Maybe you are looking for

  • Searching file from directory located at http path.

    Hi All, I have made the program to search for a file in a directory and its subdirectories. This is working fine when my directory is located on local machine. But if the same directory is placed in HTTP path, the code fails to search a directory. Do

  • Is it possible to play civilization V with the macbook air

    Is it possible to play civilization V with the macbook air

  • Will Radeon x800xt support  30" ACD plus a 23"ACD

    I have a dual 2ghz G5 tower with an ATI Radeon x800xt graphics card. Will the system support two Apple Cinema Displays simultaneously: a 30" plus a 23""?

  • Serial Key

    I would like my app to be available for download as a Trial version, which can be validated using a serial key. Can anyone please give me an idea of how the serial key validation works or how I can implement it??.. thanks for the help.

  • New requirement in BOM - supply area

    Dear friends My client requirement as below He want a new field in BOM item details, where in he will input the physical location where this item is assembled in shop floor. ex ( s1,s2.....s99) After entering this in all applicable BOM, he wants to m