Call different RFC Functions depending on variable

Hi,
I have to implement following requirement:
My program generates a report for the user and the user can choose which data he wants to have.
Depending on the user decissions, I have to use different RFC - Functions to get the data.
I have the name of the RFC Function und I want to call the RFC Function with this name dynamically.
For example:
rfcName = "Z_FUNC_1";
rfc = get the object for Z_FUNC_1 somehow. This is my problem
rfc.execute();
Is there any way how to solve this?  I know that I can solve this like this, but this is not the flexible way that i want:
if (whichRFC == 1) {
  Z_Func_1_input rfc = new Z_Func_input();
rfc.execute();
Any ideas?
Best regards,
Peter

Dear Peter,
There are how many RFC models are you going to make? In my opinion it would be  too tedious and redundant as you have to create diifferent models fo each RFC.
Instead of this you may create a single RFC and in that you can call your required RFC depending on the user selection.
It will simplify your application as well as your task.
Hope it helps!!
Warm Regards
Upendra Agrawal

Similar Messages

  • Where should i call the rfc function module? in xi or in r/3

    where should i call the rfc function module?
    for the synch scenario: file < -- >  xi <---> rfc
    i know the type of rfc is tcp/ip; but i'm not sure with the followings,
    and with some trials i can not even see any message via rwb even all the setting
    can be activated without errors.
    where should i create the rfc destination? in r/3 or xi
    where should i call the rfc via abap program? in r/3 or xi
    i guess the calling program should belong to the different server with the rfc itself....
    so confused....
    Thanks for your reply!!
    Jun

    if i create the destination in xi point to r/3, then i call the rfc use the destination in r/3 right ?
    The call doesnt use the destination in R3. XI has the RFC destination which is just used to connect to the R3 system
    but where i need to create the fm via se37? in xi or r/3 ?
    In R3
    Regards,
    Prateek

  • Problem while calling an RFC Function Module in Background

    Hello,
    I have created a RFC function module for reading data from an external DB system. The FM calls an external RFC program (coded in C++ using RFC SDK), which delivers the required data. This external program is maintainged as an TCP RFC Connection in SM59.
    Further I have created a report, that calls the RFC function module to get the data from the external RFC programm.
    My problem is, when I call the report in foreground, everything works OK, the RFC connection works and data can be read from the external program.
    However, when I schedule the report to run in background as a job, the report is stating in the protocoll that there was a problem calling the defined RFC connection (although the connection is working properly at that time).
    More funny is, this particular problem with running in background occurs only in the productive system, in test and development system the report works correctly also while running as a job in background.
    Can you suggest the solution to this problem? Could it be something with authorisations or server settings?
    I will be on holiday for the next 6 weeks, so take your time to answer .
    Regards,
    Dusan.
    Edited by: Julius Bussche on Jan 22, 2009 7:19 PM
    Please read the forum rules about u r g e n t ...

    This is an external RFC server program, not a remote enabled ABAP RFC function module as the others seem to be assuming, right?
    Is it possible that your DEV and QAS systems only have one application server, but the PROD has many and dedicated one(s) for processing low priority background jobs?
    It might be that the target server of your TCP connection is not this BTC instance, and your RFC server is returning the data "locally" - so, into nirvana...
    Just guessing, but might be worth checking.
    Cheers,
    Julius

  • Calling Synchronous RFC Function Module in Background

    Hi all,
    Currently we are working on some requirement where in we have to retrieve data from one system(CRM) and update the same into another system(ECC). We have developed a RFC Function in CRM system and it is being called from ECC system as in synchronous mode via a batch program.
    Now since all sychronous call to a RFC function will be dialog there is a constraint on the runtime which is being set by maximum run time for each dialog work process. So my question is there an option to call an RFC function synchronously in background (background task) so there is no runtime performance.
    The standard TRFC, QRFC calls in background runs asynchronously and so I am trying to check with the SDN world as whether has anyone tried  SRFC(Synchronous) call in background?
    Thanks in advance,
    Jagath

    So my question is there an option to call an RFC function synchronously in background (background task) so there is no runtime performance.
    One solution would be to increase the value of the "time out" parameter defined the CRM system. This i feel is not a fool-proof solution as the run-times cannot be predicted. Check this thread: Re: RFC timeout profile parameter
    For me a better solution would be to implement tRFC call instead of a synchronous call. Any reasons why you don't want to implement a tRFC ?
    BR,
    Suhas
    Edited by: Suhas Saha on Jun 26, 2010 8:52 AM

  • Calling a RFC Function Module

    Hello Guys,
    I have a question regarding calling a RFC function module.
    In BW - BI 7.0 I call a RFC function module:
    (The ABAP program in BW-BI 7.0 is below)
      CALL FUNCTION ''ZTESTFUNCTIONMODULE'  " Function module in ECC
         DESTINATION 'DECCLNT110'  " ECC system
        TABLES
          it_gl_item   = it_gl
          it_errlog_gl = it_errlog_gl.
    The 'ZTESTFUNCTIONMODULE'   is RFC enabled in the ECC system.
    The purpose is we retarct the data from BW to ECC.
    When I run the function module it always asks for the user id and password.
    The SAP logon screen appears and it asks for the user id and password.
    The destination is maintained in the SM59 transaction and also the user is maintained there. I think it should login automatically into remote system and return the tables. is it correct. How to skip the logon screen.
    Do I have to pass the user id and password in the function module. I think it should take the user id from the SM59 destination. Is it correct.
    Please advise. As always thanks for your help guys.

    Hi Senthil,
    I think you answered your query in your question itself
    The user ID and password need to be maintained in RFC destination in SM59.
    Go to SM59 and then click on test connection..if it does not ask for ID and passwoed that means correct ID and password is maintained in SM59 otherwise maintain it.
    Regards,
    Atish

  • How to call a RFC function from ABAP to external C/C++ system

    Hi
    Can some one describe me what are the steps that needs to be done to call a RFC function in external C++ system and to handle errors.
    Any previous experience,please share

    Hi,
    i think this is the wrong Forum.
    Better use the SAP NetWeaver .NET Technologies Forum on this site.
    Henning

  • Calling a RFC function in non-SAP application

    Hi,
    I can call a RFC function in a .NET application. Here there is no problem.
    But if an ABAP program submitted in this RFC then I can not call this RFC?
    Can I call an RFC ( it submits another abap program) non-SAP application.
    Thanks.

    Hi Astron,
    Could you please close the thread as answered.
    Regards,
    Anand Mandalika.

  • Best practice usage of system users for different RFC functions execution

    Hello experts,
    Could you guys share your thoughts on RFC type 3 - system userid usage:
    Would it be recommended to use ONE RFC destination (type 3) for execution of various functions?
    Is it recommended using the different RFC destinations (type 3) (with different system user ids) depending on the functions execution?
    Thanks in advance for your thoughts.
    Thanks
    Himadama

    Thanks Julius for your information.
    Option 1: System user id / password:
    Password is sent over the network. But SNC control would take care of this.
    1 destination = 1 system userid
    If the useru2019s password is compromised the risk would be limited to that destination function group (RFC_NAME in S_RFC auth object)
    System users only need RFC authorizations (S_RFC).
    Only monitoring System users would be enough.
    Better password management if required.
    Option 2: u201CCurrent Useru201D option:
    One user may need access for more than one function groups access ( RFC_NAME).
    Compromising user's password would result more damage than the system user. Since this user has broad access to execute multiple function groups.
    Monitoring these users would be overloaded job in this case becoz of increased users numbers. 
    The management of authorizations (roles) to these users may require strict approval process.
    Option 3: Trusted system option:
    u2022          RFC_SYSID :                                                             
    u2022          RFC_CLIENT:                                                          
    u2022          RFC_USER  : ' '                                                                      
    u2022          RFC_EQUSER: Y (for Yes)                                                              
    u2022          RFC_TCODE : *                                                              
    u2022          RFC_INFO  :                                                          
    u2022          ACTVT     : 16                                                             
    Seems user requires both the auth objects S_RFCACL and S_RFC in this case.
    Compromising user's password would result more damage than the system user. Since this user has broad access to execute multiple function groups.
    Monitoring these users would be overloaded job in this case becoz of increased users numbers. 
    The management of authorizations (roles) to these users may require strict approval process.
    Would you say considering the system userid/password is better option than other methods with SNC control in place? Please share your thoughts.
    Thanks
    Himadama

  • Unknown error calling a RFC Function Module in BODI

    Hi all,
    I am having an issue identifying the error that my batch job in BODI is giving with regards to a RFC function module call in my query. The value returned by the standard parameter 'AL_RFC_RETCODE' are square characters (              ).
    At the completion of the job, the error message 'RFC CallReceive error <Function ZCT_INDSLS_SLS_TRN_INSERT: Invalid request.. Invalid request.>.' is being output.
    Correct me if I'm wrong but the parameter 'AL_RFC_RETCODE' should return standard values as per the techical manual provided to undertand any errors that might occur during a RFC FM call.
    Can anyone help me on this?
    Best regards,
    Andrew Wong

    Hi Senthil,
    I think you answered your query in your question itself
    The user ID and password need to be maintained in RFC destination in SM59.
    Go to SM59 and then click on test connection..if it does not ask for ID and passwoed that means correct ID and password is maintained in SM59 otherwise maintain it.
    Regards,
    Atish

  • Call a RFC function in VB but without SAPGui install in the system.

    Hi,
    Do you have example of code, to be able to call a RFC with the VB or C/C++ without needed to have the SAPGui install in the client.
    The RFC will be call by a server, so I don't want to install a SAPGui release on this server.
    Regards
    Frédéric

    Hi,
    You can access the RFC using VB by the SAP DCOM connector, or for a more basic solution you can access the wdtfuncs.ocx(ActiveX control).
    I think it has a Login control in it, you can have documentation while installing RFC SDK from SAPGui CD and it will give you some basic samples of how to use these controls.
    Or you can search in help.sap.com and search for "Example Application with the Function Control" and it should return the results to give your VB example.
    aRs

  • Calling BAPI(RFC function module) in java? Part 2

    Hi
    Can any body tell me or give me source code for calling give BAPI...i need to give the inputs to that parameters..
    data l_order_header_in    like bapisdhd1.
    data t_return             like bapiret2  occurs 0 with header line.
    data t_order_items_in     like bapisditm occurs 0 with header line.
    data t_order_schedules_in like bapischdl occurs 0 with header line.
    data t_order_partners     like bapiparnr occurs 0 with header line.
    *data t_order_condition_ex like bapicond   occurs 0 with header line.
    *clear   t_order_condition_ex.
    *refresh t_order_condition_ex.
    clear l_order_header_in.
    l_order_header_in-doc_type      =  'TA'.
    l_order_header_in-sales_org     =  'ZZ02'.
    l_order_header_in-distr_chan    =  'Z2'.
    l_order_header_in-division      =  'Z2'.
    *l_order_header_in-purch_no      =  '12'.
    clear   t_order_items_in.
    refresh t_order_items_in.
    t_order_items_in-itm_number     =  '000001'.
    t_order_items_in-material       =  'HAMAM'.                 " 'LBYA1'.
    t_order_items_in-target_qty     =  '0000000000001'.
    t_order_items_in-comp_quant     =  '0000000000001'.
    append t_order_items_in.
    clear   t_order_partners.
    refresh t_order_partners.
    t_order_partners-partn_role     =  'AG'.
    t_order_partners-partn_numb     =  '0000000006'.
    append t_order_partners.
    clear   t_order_schedules_in.
    refresh t_order_schedules_in.
    t_order_schedules_in-itm_number =  '000001'.
    t_order_schedules_in-sched_line =  '0001'.
    t_order_schedules_in-req_qty    =  1.
    append t_order_schedules_in.
    clear   t_order_partners.
    t_order_partners-partn_role     =  'WE'.
    t_order_partners-partn_numb     =  '0000000006'.
    append t_order_partners.
    break kumars.
    call function 'BAPI_SALESORDER_CREATEFROMDAT2'
      exporting
      SALESDOCUMENTIN               =
        order_header_in               = l_order_header_in
      ORDER_HEADER_INX              =
      SENDER                        =
      BINARY_RELATIONSHIPTYPE       =
      INT_NUMBER_ASSIGNMENT         =
      BEHAVE_WHEN_ERROR             =
      LOGIC_SWITCH                  =
      TESTRUN                       =
      CONVERT                       = ' '
    IMPORTING
      SALESDOCUMENT                 =
      tables
        return                        = t_return
        order_items_in                = t_order_items_in
      ORDER_ITEMS_INX               =
        order_partners                = t_order_partners
        order_schedules_in            = t_order_schedules_in
      ORDER_SCHEDULES_INX           =
      ORDER_CONDITIONS_IN           =
      ORDER_CONDITIONS_INX          =
      ORDER_CFGS_REF                =
      ORDER_CFGS_INST               =
      ORDER_CFGS_PART_OF            =
      ORDER_CFGS_VALUE              =
      ORDER_CFGS_BLOB               =
      ORDER_CFGS_VK                 =
      ORDER_CFGS_REFINST            =
      ORDER_CCARD                   =
      ORDER_TEXT                    =
      ORDER_KEYS                    =
      EXTENSIONIN                   =
      PARTNERADDRESSES              =
    break venkat.
    call function 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT          =
    IMPORTING
      RETURN        =
    Awaiting for ur responses..
    Thx
    PRadeep

    To call an RFC, you need to import that first. For that right click on the project into which you need to add the rfc.
    Import >>import RFC modules from r/3>>Give the package name and a port name for the rfc.
    set the server options as your r/3 server properties.
    Then you can search the Function name >> it will be displayed in the result area>> select it and press finish.
    The RFC will be imported to your project.
    Then you need to create JCO for calling that rfc.
    Here is a sample code which calls an RFC and setting jco..
    import com.sap.mw.jco.JCO;
    import com.sapportals.portal.prt.component.*;
    public class rfc extends AbstractPortalComponent
         private JCO.Client jcoClient;
         Insert_pgm_PortType insFunc=new Insert_pgm_PortType();
         Zinsert_Pgm_Input ip=new Zinsert_Pgm_Input();
         Zinsert_Pgm_Output op=new Zinsert_Pgm_Output();
        public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
        this.connect();
         insFunc.messageSpecifier.setJcoClient(jcoClient);
    //setting input params
         ip.setAssociate_Id1("44");
         ip.setCourse_Objt1(2);
         ip.setQlty_Content1(5);
         ip.setSeq_Content1(2);
         ip.setTraining_Id1("22");
    //calling RFC
         try{
         op=insFunc.zinsert_Pgm(ip);
         }catch(Exception e){}
              response.write(op.getMessage());
              this.disconnect();
    //creating JCO connection
         private void connect() {
                   try {
                        jcoClient =
                             JCO.createClient("Client","userid","password","Language","servername","Systemid");
                             jcoClient.connect();
                   } catch (Exception e) {
                        System.out.println("Error connecting to SAP ::" + e.getMessage());
                        e.printStackTrace();
         private void disconnect() {
                   try {
                        jcoClient.disconnect();
                   } catch (Exception e) {
                        System.out.println(
                             "Error dis-connecting to SAP ::" + e.getMessage());
                        e.printStackTrace();
    Hope this Helps
    gEorgE

  • Regarding: calling a rfc function module for web dynpro for JAVA

    Hello all,
    I want to call an rfc enabled function module from webdynrpo application.
    *and there is one condition that function module should be called not threw bapi.*
    Thanks
    Edited by: Punit Pawar on Jul 21, 2008 10:38 AM

    Hi 
    You can call RFC(remote enabled) from R/3 through Models in Webdynpro Java.You need to have JCO destinations.You connection properties of backend System
    http://help.sap.com/saphelp_nw04s/helpdata/en/6a/11f1f29526944e8580c5e59333d96d/frameset.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/11c3b051-0401-0010-fe9a-9eabd9c216de
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b0310cf8-8cdb-2910-4a82-df1f11619f4e
    Thanks,
    Tulasi Palnati

  • Getting Return values from RFC function call with visual basic

    Hi,
    I am creating a sample app to connect to a SAP system which call its RFC functions created with ABAP. It was known that the function will return more than 1 return values.
       SAP Function name ==> "ZFMTP_RFC_GET_RESULT"
            Export parameters (to SAP):
                    - Student Name [char 10]         ==> "STUNAME"
                    - Student ID         [char 20]        ==> "STUID"
           Return values (From SAP):
                    - Results [char 10]        ==> "RESULT"
                    - Remarks [char 200]        ==> "REMARKS"
    i have managed to get sample codes for connecting and call a RFC function with vb but they only get a return value. How do i retrieve multiple return values like the above function "RESULT" and "REMARKS"?
    Here's my vb code to accessing the function
            Dim R3 As Object
            Dim FBFunc As Object
            Dim returnFunc As Boolean
            Dim connected As Boolean
            R3 = CreateObject("SAP.Functions")
            R3.Connection.Client = "000"
            R3.Connection.User = "BCUSER"
            R3.Connection.Password = "minisap"
            R3.Connection.Language = "DE"
            R3.Connection.System = "dtsystem"
            R3.Connection.Applicationserver = "xxx.xxx.xxx.xxx" 
            connected = R3.Connection.Logon(0, True)
            If connected <> True Then
                MsgBox("Unable to connect to SAP")
            End If
            FBFunc = R3.add("ZFMTP_RFC_GET_RESULT")
            FBFunc.exports("STUNAME") = "Jonny"
            FBFunc.exports("STUID") = "12345"
            returnFunc = FBFunc.Call() <<== How do i get the return value? or RESULT and REMARKS of the RFC Function?
    thanks alot.
    Edited by: Eugene Tan on Mar 4, 2008 7:17 AM

    Hi Gregor,
    Thanks for the link....i am having some doubts with the codes, hope you can clarify them for me if you know the codes..
    Below is the code snippet.
    Set impReturn = CHPASS_FN.Imports("RETURN")  <<=== is RETURN the standard keyword to get a                                                                                return object?
      expPassword.Value = currpass
      expNewPass.Value = newpass
      expFillRet.Value = "1"
    ''' Call change password function
      If CHPASS_FN.Call = True Then
        outFile.Write (", Called Function")
        Message = impReturn("MESSAGE") <<==== So if i have 3 return values..i just replace with the return                                                               value variable names?
        outFile.WriteLine " : " & Message
      Else
        outFile.Write (", Call to function failed")
      End If
    thanks alot...all your help is very appreciated.

  • RFC function call from VB Script

    I have an RFC enabled function that I need to call from VBScript.  I was working through this issue as a BAPI call but after research and RFC not initialized error messages over and over I am coming to think that the issue is not how I was doing it but what I was trying to do with different objects. 
    I think the issue is that I was trying to call a RFC function with BAPI methods, I didnt understand that there was I difference but now I do.  I don't know how to initialize the RFC on the host system and unsure if I even have all of the components on the host system to make these function calls.
    The goal here is to call a function that passes 3 paramters and modifies a user object in SAP.

    Hello John,
       are you using DCOM Connector? I have a VBScript working correctly, using DCOM Connector, and consuming a Z function module defined as RFC.
    What's the error message you're getting?
    Regards
    Michael

  • Calling RFC function

    I am trying to call an RFC function in my bsp page. The RFC is to start a process chain. It gives me an error and I am not sure why. It tells me E_LOGID is not expected. Here is code:
    if event->id = 'Update1' and event->event_type = 'click'.
          Call Function 'RSPC_API_CHAIN_START'
          DESTINATION 'NONE'
          importing
          I_CHAIN = 'NCNADMFULL'
          I_SYNCHRONOUS = ''
          I_SIMULATE = ''
          EXPORTING
          E_LOGID = 0.
          endif.

    Hi Uday,
    well it seems that the function module RSPC_API_CHAIN_START does not expect and exporting parameter called E_LOGID.
    Why dont you just use the templating options to insert sample code to call the RFC?
    When I did this I got this code generated.
    CALL FUNCTION 'RSPC_API_CHAIN_START'
      EXPORTING
        i_chain             =
    *   I_T_VARIABLES       =
    *   I_SYNCHRONOUS       =
    *   I_SIMULATE          =
    *   I_NOPLAN            =
    * IMPORTING
    *   E_LOGID             =
    * EXCEPTIONS
    *   FAILED              = 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.
    So it seems you got your IMPORTING and EXPORTING options around the wrong way.
    Cheers
    Graham

Maybe you are looking for

  • Weird Outlook prob

    I have a Nomad Jukebox Zen Xtra. When I use the Creative Sync Manager, Outlook goes nuts. Its icon blinks on the taskbar and the only way to make it stop is to reboot the computer. I have looked all over and cannot find a setting that will stop this

  • Event timer for Leopard or Tiger?

    Hey all, I want to create an Automator script that will execute at a certain time. Is there a Unix command for this? Thanks, -Dan Uff

  • A temp table in a stored procedure , set a value to varchar(MAX)

    Hi ,, In stored procedure there is  a temp table and set a value to varchar(MAX) . What exactly is the different between setting it to varchar (MAX) instead of  varchar(n) Thank You Jeevan Vinay

  • Ibook g4 can't recognize wifi card but recognize bluetooth

    Hi,there: G4 can't recognize wifi card , but can recognize the bluetooth, last night I take apart of machine, and found that the 2 are into 1 chip, but now I forget which model is it?maybe 1127. When I take the card out and put back again, start mach

  • Is tech support kept in the dark?

    I have had occasion to contact tech support several times in the last few months because my broadband connection kept dropping out. Invariably there is a line test and I am told there is no fault and it must be something in my wiring or setup. On one