Call Function using DESTINATION

Hi there!
Abapers, I'm needing some help here with RFCs.
My destinations (SM59):
ERP_100
ERP_120
ERP_130
PI_200
PI_300
I have to call a function in PI from ERP. I'm doing in this way:
CALL FUNCTION 'pi_function_module' DESTINATION 'PI_200' ...
It's working. But the destination can not be hard coded. With the program in ERP_100 (DEV) and ERP_120 (QAS) the destination is PI_200 (PI DEV) and with the program in ERP_130 (PRD) the destination is PI_300 (PI PRD).
How can I handle this?
Thanks in advance!
Best regards,
Charles

Hi Charles,
Refer [this|Re: Deciding RFC destination dynamically; thread.
I quote the last post by Micky Oestreich - "This solely depends on the naming conventions you are using. Since the name of the RFC destination is arbitrary, there is 'no' way of determining the name of the destination."
So, your design approach could either be by building a customizing table where you maintain the destination values or use a 'CASE' statement in your code before calling the remote function module....something like:
DATA:
  lv_own_system  TYPE logsys,
  lv_rfcdest     TYPE rfcdest.
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
  IMPORTING
    own_logical_system             = lv_own_system
  EXCEPTIONS
    own_logical_system_not_defined = 1
    OTHERS                         = 2.
IF sy-subrc NE 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CASE lv_own_system.
  WHEN 'ERP_100' or 'ERP_120'.
     lv_rfcdest = 'PI_200'.
  WHEN 'ERP_130'.
    lv_rfcdest = 'PI_300'.
  WHEN OTHERS.
ENDCASE.
"Now call the remote function
CALL FUNCTION 'pi_function_module' DESTINATION lv_rfcdest ...
Hope this helps,
Cheers,
Sougata.

Similar Messages

  • Call function..Destination

    Hi Experts,
    My requirement is to call a RFC Java function in SAP. The Java function is an encryption function which has 4 parameters (Password, Message, Strength128, Strength256). I need to pass the data for the parameters from SAP to JAVA. With the help of SDN, I tried to call this function in ABAP. A destination named 'INTEGRATION' is created in SM59, with the registered Program ID 'ASEncryptionHelper'. ASEncryptionHelper is the Java function name and the program ID is registered with this name only. The following is the code I wrote in my report
    DATA: XPASS TYPE STRING.
    XPASS = 'PASS'.
    CALL FUNCTION 'ASENCRYPTIONHELPER' DESTINATION 'INTEGRATION'
      EXPORTING
        PASSWORD          = XPASS
        MESSAGE             = XML_RESULT
        STRENGTH128       = ' '
        STRENGTH256       = 'X'
    I have created a RFC function module in my SAP system with the name ASENCRYPTIONHELPER
    FUNCTION ASENCRYPTIONHELPER.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(PASSWORD) TYPE  STRING
    *"     VALUE(MESSAGE) TYPE  STRING
    *"     VALUE(STRENGTH128) TYPE  BOOLEAN
    *"     VALUE(STRENGTH256) TYPE  BOOLEAN
    ENDFUNCTION.
    When I execute the program I get a runtime error "Bean ASENCRYPTIONHELPER not found on host HOSTNAME".
    I am not able tofigure out the exact problem.
    Also I wanted to know whether the way I am coding is right. Do I need to create a RFC function module in SAP also as I did above?
    Does the Uppercase of the function 'ASENCRYPTIONHELPER' matter? In SM59 the program id is mentioned as 'ASEncryptionHelper'.
    I tried to change the function name with 'ASEncryptionHelper' in the CALL FUNCTION, but then I get another error, "JCO.Server could not find server function 'ASEncryptionHelper' '. What is wrong? I am confused.
    Please guide.
    Thanks
    Anu.

    Hi,
    I didn't get your requirement wxatly but you can do as below,
    What I am assuming is you have a java batch file at your desktop and you want to encrypt the file through this batch file execution from SAP.
    Now to execute the batch file at runtime and to pass data at runtime you can use below function module
    W_RFCENCRY = 'C:\Encrypt\enc.exc C:\Encrypt\test.txt'.
    W_RFCDEST = 'ZRFC'.
    CALL FUNCTION 'RFC_REMOTE_PIPE'
          DESTINATION W_RFCDEST
          EXPORTING
            COMMAND               = W_RFCENCRY
          EXCEPTIONS
            COMMUNICATION_FAILURE = 1
            SYSTEM_FAILURE        = 2
            OTHERS                = 4.
    Here ZRFC is the RFC created in SM59 as below
    1) select TCP/IP and create ZRFC
    in program option type as below C:\RfcSdk\bin\rfcexec.exe
    Note: RFCDSK folder is required to execute the batch file at your workstation at path specified as above
    2) In activation type select start on front end work station radio button.
    Now save the RFC and check the connection, same will be there if RFC SDK folder is available as specified in the program option
    In W_RFCENCRY give the inputs that you want to pass with the batch file.
    here I have mentioned as 'C:\Encrypt\enc.exc C:\Encrypt\test.txt'. in the program where C:\Encrypt\enc.exc is the path for batch file and C:\Encrypt\test.txt is the path of the file on the work station which is to be encrypted.
    Hope this will help you, I think at your end batch file can be different and inputs to be passed in the batch file can also be different.

  • Remote call function and destination

    Hi all @SAPforums,
    I used to call remotely a custom function, in a report, from many backends:
    CALL FUNCTION ZFOO destination mydest
    where mydest is a string containing the name of an RFC destination.
    My question is: is there a way, on the destination machine, to get the name/id of the "caller" ?
    The question arises from this task: I have to use the caller ID in a WHERE clause of a SELECT statement I have to write in ZFOO. I can - of course - pass the caller ID by adding a new parameter to the function, but this would make necessary a change on the CALL FUNCTION in every backend (quite expensive task, in terms of time). So if it's possible, from the callee, to get the name of the caller, I could just modify the function leaving the calls in every backend as they are.
    Thanks in advance

    >
    Matteo Montalto wrote:
    > Hello Wolfgang,
    > sorry for the stupid question... what does "destination" stands for?
    > Thanks for the help
    Hi ,
    they are two types of RFC calling is ther..
    1......
    CALL FUNCTION "function0module-name' DESTINATION "DEST" 
    --that means you are picking data from another r/3 sytem using detination from 'DEST'..
    2....
    CALL FUNCTION "function0module-name' IN BACKGROUND TASK DESTINATION "DEST" 
    --that means you are sending data to another r/3 sytem or any other sytem XI or and EDI
    using detination from 'DEST'..
    for 1 and 2..
    --go to t-code SM59 and see the DEST what type of connection is and what system it is connected..
    Regards,
    Prabhudas

  • Calling function using setOnClick()

    Hi All,
    I am trying to open the link to the application in a new window without anymenubars,navigation bar,toll bar etc.I am using the following code.I am trying to call function onLinkAction() using setOnClick(),but getting an error cannot find onLinkAction().Please help me in this regard how to call the onLinkAction() method.

    Hi,
    How are you trying to call the function,could you please share your code.
    You neeed not prefix the menthod with "on" while calling using setOnClick()..
    Also make sure your function onLinkAction() has the mehtod signature as follows
    onLinkAction(Event event)
    Hope it helps..If not please elaborate your problem
    Regards,
    Santhosh

  • Calling function using ADO

    Hi.
    I am trying to execute a function using ADODB.Command object. I am using ODBC driver Oracle73 Ver 2.5.
    When I am executing the command object with CommandText Property set to "pk_test.GET"
    It returns error saying:
    [ORA-06550]
    PLS-00221: 'GET' is not a procedure.
    Statement Ignored.
    Thank you

    Is there actually a procedure 'get' inside a package 'pk_test'?
    Justin

  • Plain call function versus destination 'none'

    we have an RFC enabled function module which is being used as an rfc by external calls but is also used within the same sap system as a conventional function mdoule.
    Currently the call in the same sap system uses a DESTINATION 'NONE' clause and I have noticed that in the SE30 Runtime analysis there is sometimes an expensive 'WAIT for RFC' against this function module call.
    Can I simply remove the DESTINATION 'NONE'  clause or is there a good reason for it being there?
    Will a call without the clause always be more efficient than one with it or is there no difference?

    Currently the call in the same sap system uses a DESTINATION 'NONE' clause and I have noticed that in the SE30 Runtime analysis there is sometimes an expensive 'WAIT for RFC' against this function module call.
    I wish I had a running SAP system to quickly test this. Did you enable also profiling of RFC calls in SE30? Couldn't the trivial reason just be that the function module takes some time and since it's a synchronous calls the calling program has to wait for it to return?
    Can I simply remove the DESTINATION 'NONE' clause or is there a good reason for it being there?
    Well, I'd be really careful and first make sure that I understand why somebody put it there. Note that an RFC call is executed in it's own context (e.g. see comments in ABAP online documentation on [RFC destination|http://help.sap.com/abapdocu_70/en/ABENRFC_DESTINATION.htm]), so if that was the reason why the destination 'NONE' was introduced you probably shouldn't change it.
    Also, a [synchronous RFC call|http://help.sap.com/abapdocu_70/en/ABAPCALL_FUNCTION_DESTINATION.htm] triggers an implicit database commit. In theory a program shouldn't rely on that, but I've seen my fair share of programs where developers were not aware of some side effects (and actually relied on them).
    Or how about a funky setup where your RFC module actually has coding to call the original system back (i.e. usage of RFC destination 'BACK'); so removing the 'NONE' should cause trouble in this case as well...
    There's probably lots of other possible traps once you start thinking about it. Most likely they are not relevant, but it definitely helps a lot if you can judge the skill set of the programmer who introduced this possibly unnecessary  RFC call...
    As far as performance is concerned I doubt that you'd gain much if it's a synchronous RFC (and the function module runs for some time and is not executed tons of times). Note though that RFC calls are limit to some stricter resource management (e.g. they can be controlled via quite a few profile parameters), so your RFC might timeout due to lack of resources, where your direct function call wouldn't do that. But if your RFC does some substantial work I doubt that the overhead for the RFC calls will be measurable.
    Cheers, harald

  • Calling function using user-defined type from query

    I am in a bit over my head on this, at least at 2:30 in the morning after several hours of intense development. I am working on a function to return financial aging figures by aging date range. I created a user type Aging with a Currency type member for
    each of these.
     Public Type Aging
      Aging0 As Currency
      Aging30 As Currency
      Aging60 As Currency
      Aging90 As Currency
      Aging120 As Currency
     End Type
    I then created a function that accepts the account ID & the as-of date. I have all the rest of the code written to actually calculate all of it, but I am having a fundamental problem figuring out how to call the function. To eliminate any of the complex
    mathematical elements for testing, I have reducted the function to a set of simple explicitly-set values below:
    Public Function GetAging(AccountID As Integer, AsOfDate As Date) As Aging
        GetAging.Aging0 = 0
        GetAging.Aging30 = 0
        GetAging.Aging60 = 0
        GetAging.Aging90 = 0
        GetAging.Aging120 = 0
    End Function
    This all works fine from the immediate window, where I can type this:
    ?GetAging(115,#2015-04-05#).Aging0
    and get the expected response of 0 (I have tested with other values for each member, so I know this part is working correctly).
    But can I and/or how do I call this from a query? I should be able, as a test, to pass in each account # and the current date, just to get the Aging0 element out of my function--something like this:
     SELECT
      AccountID,
      CustomerName,
      GetAging([AccountID],Date()).Aging0
     FROM
      Customer
     ORDER BY
      CustomerName
    I get "The expression you entered has an invalid .(dot) or ! operator or invalid parentheses. But if I remove the ".Aging0", I get this error: Undefined function 'GetAging' in expression. 
    What am I missing here?

    To expand on the answer of Hans, you could use a AgePoint parameter in the function like this:
    Public Function GetAging(AccountID As Integer, AsOfDate As Date, AgePoint As Integer) As Currency
    ' do calculation
    Select Case AgePoint
    Case 0: GetAging = Aging.Aging0
    Case 30: GetAging = Aging.Aging30
    Case 60: GetAging = Aging.Aging60
    Case 90: GetAging = Aging.Aging90
    Case 120: GetAging = Aging.Aging120End Select
    End Function
    then use it in the query like this:
    SELECT
    AccountID,
    CustomerName,
    GetAging([AccountID],Date(), 0),
    GetAging([AccountID],Date(), 30),
    GetAging([AccountID],Date(), 60),
    GetAging([AccountID],Date(), 90),
    GetAging([AccountID],Date(), 120)
    FROM
    Customer
    ORDER BY
    CustomerName
    However, this has the big drawback that the function will be called 5 times for each and every AccountID, so you will probably have bad performance.
    Since you pass the AccountID to the function, you could consider to calculate the results for all AccountIDs in the code and store the results into a table, then join this table into the query.
    Matthias Kläy, Kläy Computing AG

  • Calling function using grovey script

    hi how can i write a grovey script to call a function,for below if statement
    if :agr.contract_no is null
    and :agr.agr_start_dt is not null then
         :agr.contract_no := sms_fapp.get_contract_no(:fac.par_id_fac,:agr.agr_start_dt);
    end if;     
    am in jdeveloper 11g release 2

    i may understood you requirement.
    why because am also forms background.
    but peoples who gathered here may/may not know Oracle forms better be explict with your requirement in detail
    if(Religionid!=null)
    adf.object.applicationModule.FuncFindReligionDesc(x,Religionid)
    }

  • Warning when calling function using page text

    Hi *,
    I have a function in package which generates some parameters for a link I want to put on bottom of the View Form.
    The HTML I put in the bottom of View Form user text field looks like this:
    Create default visit for this group
    The problem is that Desinger throws a warning when I try to generate and the auto-install option gets ignored due to this error...
    Can I set Designer to ignore this "parse error", so that the auto-install works again?
    Here is the exact error message:
    Message
    CDG-03707: Module Component GROUPS.GROUPS: Invalid syntax in User Help Text or Page Text for Bottom of View Form: 'guides_package.visit_create...'
    Thanks in advance,
    Goeran Zaengerlein

    Is there actually a procedure 'get' inside a package 'pk_test'?
    Justin

  • Call Function Destination in a background job

    I am having a problem using:
      CALL FUNCTION 'TABLE_ENTRIES_GET_VIA_RFC'
             DESTINATION p_dest
    in a background job.
    I am working on a program that would compare the same table in 2 different systems and write the differences.  It works when I run it in the foreground.  However, I want to run this in a nightly background job.  However, it is failing and I beleive that it is the result of the program needing a user to interactively logon to the remote system.
    How can I bypass the logon screen or enter information into the logon screen using a background job?
    Thanks.
    Jon

    Hi Jonathan,
    Would you like to reward some points to the poster to thank them as a part of SDN Contributor Recognition Program?
    You can click on the yellow star on the right of each post header to reward points.
    For more information:
    https://www.sdn.sap.com/sdn/index.sdn?page=crp_help.htm
    John.

  • Call function destination XI exception

    Hello,
    in R3 i call to function in XI, it's follow:
    call function 'XXX'
    --destination 'XI'
    --exporting
    AA = aa
    --importing
    BB = bb
    --exceptions
    system_failure = 1
    communication_failure = 2
    other = 3
    when this call produce a exception, why sometimes I can not see anything in XI - SXMB_MONI / runtime workbench -?
    thank you very much

    HI,
    If in case the message failed at entry point i.e. RFC sender communication channel, then it would not be available in SXMB_MONI.
    You may trace it from Communciation Channel Monitoring from RWB..
    Thanks
    Swarup

  • Computer name in R3 when call function RFC from CRM to R3

    Hi all,
    i nead the computer name in R3 when I  come to R3 from  CRM .
    In R3  i call function 'TERMINAL_ID_GET'  in R3   but I don't retrieve the computer name.
    i tried also to  call function 'TERMINAL_ID_GET'  in destination 'CRM'   but I don't retrieve the computer name.
    The code in R3:
    CALL FUNCTION 'TERMINAL_ID_GET' DESTINATION 'R3GETCRM'
          EXPORTING
            username             = sy-uname
          IMPORTING
            terminal             = l_terminal_usr41
          EXCEPTIONS
            multiple_terminal_id = 1
            no_terminal_found    = 2
            OTHERS               = 3.
    This function works ok when i call her direct from R3 or direct from CRM,
    but not give me in R3 the computer name when i came to R3 From CRM. 
    Thanks for your cooperation.
    dany

    thats because 'TERMINAL_ID_GET'  is not a RFC (check the attributes tab of the FM from SE37)
    if you dont find a RFC to do t his you can wrap this FM with a custom RFC and use it.
    if you want all the logged on users info (computer name and other info) then you can use THUSRINFO FM which a RFC
    Raja

  • CALL FUNCTION 'RFC_REMOTE_PIPE' throwing exception as 1

    Hi Sapients,
    I am using CALL FUNCTION 'RFC_REMOTE_PIPE' to rename a file at the UNIX level..Though this runs well... sometimes this is giving an exception as ''1'' (System Failure).. if we execute the same after 3  or 4 hours this RFC is again successfully executed...Can anyone throw some light on why this is happening and how we can avoid the same.
        CALL FUNCTION 'RFC_REMOTE_PIPE'
        DESTINATION 'SERVER_EXEC'
        EXPORTING
          COMMAND = l_command
          READ    = c_yes
        EXCEPTIONS
          system_failure        = 1
          communication_failure = 2
          OTHERS                = 3.
    where the l_command is mv old_file_name New_file_name
    and C_yes is X

    Hi,
    Maybe my answer comes too late.
    Could be helpful for others anyway.
    We got the same trouble and it was due to the RFCEXEC.SEC file.
    Installing the SDK7.20 the RFCEXEC files were missing and old RFCEXEC.SEC was not in the same format...
    Please look also to OSS notes #1592501 and #1581595
    Thanks
    //Philippe.

  • CALL FUNCTION 'RFC_REMOTE_PIPE' throwin exception ''1''

    Hi Sapients,
    I am using CALL FUNCTION 'RFC_REMOTE_PIPE' to rename a file at the UNIX level..Though this runs well... sometimes this is giving an exception as ''1'' (System Failure).. if we execute the same after 3  or 4 hours this RFC is again successfully executed...Can anyone throw some light on why this is happening and how we can avoid the same.
        CALL FUNCTION 'RFC_REMOTE_PIPE'
        DESTINATION 'SERVER_EXEC'
        EXPORTING
          COMMAND = l_command
          READ    = c_yes
        EXCEPTIONS
          system_failure        = 1
          communication_failure = 2
          OTHERS                = 3.
    where the l_command is mv old_file_name New_file_name
    and C_yes is X
    <promise removed by moderator>
    Edited by: Thomas Zloch on Mar 16, 2011 1:00 PM

    Hi,
    Maybe my answer comes too late.
    Could be helpful for others anyway.
    We got the same trouble and it was due to the RFCEXEC.SEC file.
    Installing the SDK7.20 the RFCEXEC files were missing and old RFCEXEC.SEC was not in the same format...
    Please look also to OSS notes #1592501 and #1581595
    Thanks
    //Philippe.

  • CALL FUNCTION  WITH STARTING NEW TASK

    Hi All,
    i'm call a function module through
    CALL FUNCTION 'Y_WIN'  DESTINATION 'rfc_destination' then it's give right result but when i want to call with starting new task then
    CALL FUNCTION 'Y_WIN'  STARTING NEW TASK 'INFO' DESTINATION 'rfc_destination'
    it does nt provide me any data. i have check in debugger call fm is wkging fine so pls clear me why i'm nt geeting result.
    pls give ur suggestions,
    Anuj

    Did you use the PERFORMING <form> ON END OF TASK to get the results back; like in the following sample
              CALL FUNCTION 'SAPWL_STATREC_READ_FILE'
                   STARTING NEW TASK taskname
                   DESTINATION list-name
                   PERFORMING read_outtab ON END OF TASK
                   EXPORTING
                        read_start_date   = s_date
                        read_start_time   = '000000'
                        read_end_date     = s_date
                        read_end_time     = '235959'
                   EXCEPTIONS " failure when calling RFC
                        communication_failure = 1 MESSAGE msg_text
                        system_failure        = 2 MESSAGE msg_text
                        RESOURCE_FAILURE      = 3.
    and
    FORM read_outtab USING taskname.
    * Receive results back
      RECEIVE RESULTS FROM FUNCTION 'SAPWL_STATREC_READ_FILE'
        TABLES
          v2_normal_records = outtab
        EXCEPTIONS " from the called FM
          nodata    = 1.
    Regards

Maybe you are looking for