How to close RFC connection in one script coding

In one script, I am using the REF command to call another 2 scripts and these called scripts shd be run on same C36 ( test system). I shd close RFC connection between these 2 scripts.
That is , once the 1s script over the RFC shd be closed and the user has to give usename and pwd  then  2nd script shd run.
I have tried with the following code…. But it says RFC is not open……
REF ( Y04S_FC_RM_CJ88_112 , Y04S_FC_RM_CJ88_1 , C36_999 ).   (when execute this script RFC to C36 will be created and after execution that RFC shd be closed so I included following ABAP code)
ABAP.
  data : dest type RFCDEST.
  move 'S4_SAPC36999' to dest.                                       
  move dest to v_dest.
*--Close the connection before opening it incase it is opened
          call function 'RFC_CONNECTION_CLOSE'
               exporting
                    destination          = dest
               exceptions
                    destination_not_open = 1
                    others               = 2.
          if sy-subrc <> 0.
          endif.
          move sy-subrc to v_subrc.
ENDABAP.
REF ( Y04S_FC_RM_CJ44_112 , Y04S_FC_RM_CJ44_1 , C36_999 ). (here agagin the RFC will be created and this script will be exectued.)

In one script, I am using the REF command to call another 2 scripts and these called scripts shd be run on same C36 ( test system). I shd close RFC connection between these 2 scripts.
That is , once the 1s script over the RFC shd be closed and the user has to give usename and pwd  then  2nd script shd run.
I have tried with the following code…. But it says RFC is not open……
REF ( Y04S_FC_RM_CJ88_112 , Y04S_FC_RM_CJ88_1 , C36_999 ).   (when execute this script RFC to C36 will be created and after execution that RFC shd be closed so I included following ABAP code)
ABAP.
  data : dest type RFCDEST.
  move 'S4_SAPC36999' to dest.                                       
  move dest to v_dest.
*--Close the connection before opening it incase it is opened
          call function 'RFC_CONNECTION_CLOSE'
               exporting
                    destination          = dest
               exceptions
                    destination_not_open = 1
                    others               = 2.
          if sy-subrc <> 0.
          endif.
          move sy-subrc to v_subrc.
ENDABAP.
REF ( Y04S_FC_RM_CJ44_112 , Y04S_FC_RM_CJ44_1 , C36_999 ). (here agagin the RFC will be created and this script will be exectued.)

Similar Messages

  • How to close RFC connections

    The RFC connections to the R/3 backend system are not closed when I close my iviews which are created in the Visual Composer. Each time the iview is reloaded, an additional RFC connection is opened...
    Has someone a solution for this problem?
    Kind regards
    Frank

    Hi Frank,
    The connector pool keep the connection alive to be reused by the model iViews datasource, those connections will be closed at the timeout or when CLEANUP runs.
    It's not a problem is the way how the connector framework works
    You can adapt the timeout according SAP Notes 913483 & 314530
    Best Regards, Luis

  • Open and close RFC connection with portals...

    Hi Experts,
    I created a RFC having a query which is taking a long time to execute. So i want to close RFC connection with portals which is via java connector(JCO)  before that query and open the connction again after that query.
    Please advice is it possible to achieve this. If yes, then how.
    Regards,
    Guddan

    Hi Guddan,
    I created a RFC having a query which is taking a long time to execute. So i want to close RFC connection with portals which is via java connector(JCO) before that query and open the connction again after that query.
    I guess i will need to understand your requirement a little more in detail, as i understand you have an RFC which has a query within to fetch some data and is taking a long time to do so. In the meantime you don't want to keep the connection open?
    My question would be, Is the role of this RFC to only execute the query and fetch the data or does it do something else?
    If it does other things and these are independent of the query execution, then you can span a parallel call within the RFC to execute the query and in the meantime the RFC does the other things (or vice versa) hence reducing the overall time taken.
    If the sole purpose of this RFC is to execute the query, then you will not be able(i mean to say there is no simple and direct way of doing this) to close the connection after the Query is started and re-establish the connection after its execution, for a simple reason that - how will you know if the query has completed it's execution, so that you can establish the connection back.
    Alternate solutions, make this a two way asynchronous call, 1) You invoke the RFC asynchronously and close the connection, the RFC in turn will execute the query and transfer the data to JCO via another RFC call.
    If this needs to be a synchronous call, then you will need to optimize the query to its best.
    Regards,
    Chen

  • When and How to close database connection in JSP?

    Hi there,
    I am using MySQL and JDBC 3.0, in my system, When and How to close database connection in JSP?
    Thanks in advance.
    Lonely Wolf
    <%@ page session="true" language="java" %>
    <jsp:include page="checkauthorization.jsp" />
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    <%--
    Execute query, with wildcard characters added to the
    parameter values used in the search criteria
    --%>
    <sql:query var="availablecomputerList" dataSource="jdbc/Bookingcomputer" scope="request">
    SELECT * FROM computer where status=0
    order by s_code
    </sql:query>
    <html>
    <head>
    <title>Search Result</title>
    </head>
    <body bgcolor="white">
    <center>
    <form action="checkin.jsp" method="post">
    <input type="submit" value="Back to Check-in Page">
    </form>
    <c:choose>
    <c:when test="${availablecomputerList.rowCount == 0}">
    Sorry, no available computer found.
    </c:when>
    <c:otherwise>
    The following available computers were found:
    <table border="1">
    <th>Computer</th>
    <th>Description</th>
    <th>Status</th>
    <c:forEach items="${availablecomputerList.rows}" var="row">
    <tr>
    <td><c:out value="${row.s_code}" /></td>
    <td><c:out value="${row.description}" /></td>
    <td><c:out value="${row.status}" /></td>
    </tr>
    </c:forEach>
    </table>
    </c:otherwise>
    </c:choose>
    </center>
    </body>
    </html>

    when should you close the connection? when you're done with it.
    how should you close the connection? like this: conn.close();
    that said, doing this in a JSP page is bad form and not recommended
    JSP's typically don't contain ANY business or data logic

  • Need to close RFC connection

    Hi all,
    Currently we developed a application in NWDS, the same is operational from portal.
    As per the requirment we have to run the RFC many times to extract the data from R/3. After running the RFC many times
    we are getting the following Error "Error connecting using JCO.client: null"
    But if we redeploy the application the problem is solved but after a while the same issue is persisting.
    Please suggest how the problem can be solved ??
    Thanks,
    vijay.

    Hi venkat,
    Thanks for the example suggested by you.
    The following is the RFC iam executing many times.
    Z_Hr_Aprsl_Init_Input input= new Z_Hr_Aprsl_Init_Input();
    input.setI_Usrid("UserId");
    wdContext.nodeZ_Hr_Aprsl_Init_Input_new().bind(input);
    wdContext.nodeZ_Hr_Aprsl_Init_Input().currentZ_Hr_Aprsl_Init_InputElement().modelObject().execute();
    the code iam using to close the connection is
    JCO.Client client = JCO.getClient(" "); // Please specify the parameter to be used to refer the above RFC
    client.disconnect();
    Please suggest the required the parameter to close the RFC connection
    Thanks
    vijay

  • How to Alert RFC connection failure via message mapping? Kindly Help!

    Hi Experts,
        I have a JMS - XI - RFC scenario.
    JMS receives the Rosattenet PIP contents and sends it to RFC function module in remote SAP R/3 system.
       I have a requirement where I have to monitor RFC connection failure because of the remote R/3 system being down. I have to send a email alert where the subject contains the PIP number to understand for which PIP the connection failed.
      The PIP number exists in the PIP content at the interface.
      If I use the Alert configuration in the runtime workbench for monitoring then I cannot dynamically pass the PIP number.
      Only way I think of triggering alert is in the message mapping via a Java UDF.
      But I am not sure how can I do this? How do I check in the UDF if RFC connection has failed? Is this the correct approach?
      How to acheive my requirement? Note that my email subject content is dynamic bacause if PIP number.
    Please help!
    Thanks
    Gopal
    Message was edited by:
            gopalkrishna baliga

    Hi Gopal,
    what version/sps of XI are u running?
    The easiest way to do what u want inside a UDF is to
    1. use JCo to try estabilish a connection to the remote SAP System
    2. if that fails, use JavaMail to send an email message
    Let your UDF work on the PIP number, accepting it as input, and (maybe) returning it as output if everything goes ok. Otherwise break the mapping execution as described by Michal in one of his last weblog (using Dynamic Configuration).
    Note that the above method doesn't guarantee that the message will be actually delivered, as some seconds could last between your check and the real RFC delivery operated by the Adapter Engine...
    I am evaluating a way to do the same with Alert Framework. I will let you know the result!
    Cheers,
    Alex

  • How to close timeout  connection in SQLDBC ?

    Hello,
    I use SQLDBC to access MAXDB 7.7.0.7.16 database, i have the following issue :
    When a connection reach timeout, I close the connection, and the release the connexion, and then I create a new connection
    To close connection I call my Disconnect function
                        The call close method return "Not connected", but It seems that the underlying Socket is not closed and the Database user task is not closed.
    So the number of task grow until it reach the maximun.
    Where is my error ?
    How can I be sure to close the database user task ?
    IDBError CMaxDBConnection::Disconnect()
         IDBError hr;
         if (m_pConnection)          
              EDPTRACE_DBG_INF(L"CMaxDBConnection::Disconnect %1", EDPMASK_TRC_CONNECTIONS) << (DWORD)m_pConnection;
              SQLDBC_Retcode rc = m_pConnection->close();
              if (SQLDBC_OK != rc)
                   hr = convertError(rc, m_pConnection->error(), L"CMaxDBConnection::Disconnect");               
              m_pParent->m_pEnvironment->releaseConnection(m_pConnection);
              m_pConnection = NULL;
         return hr;
    Regards
    Yann

    MAXDB 7.7.07.16 (WINDOWS 2008 R2 (64 bits) Client program in 32bits.
    Hello
    I have code a small program to illustrate my issue.
    When I create a connection with SQLDBC it create 2 user tasks in the MAXDB task Manager
    One uer task  APPPLICATION SERVER, SESSION TIMOUT, ... filled.
    T425  10 0x16AC User      2688* Command wait        823 0            76 20691065(s)
    and One User task with no session tiemout.
    T111   8 0x15B8 User       2688 Command wait       3009 0            76 24900501(s)
    T111                  USER             ( pid = 2688       ) -
    dispatcher_cnt: 2                                     command_cnt   : 2
    exclusive_cnt : 30                                    self_susp_cnt : 0
    state_vwait   : 0          state_vsleep  : 0          state_vsusp   : 0
    same_ukt_coll : 0        
    when I close the connection the task T111 is never remove !!
    Do you have any idea ?
    I try to delete environment but It does not work.
    Regards
    Yann.
    Here is the code  :
    // SQLDBC.cpp : Defines the entry point for the console application.
    #include "stdafx.h"
    #include "SQLDBC.h"
    using namespace SQLDBC;
    static void parseArgs(int argc, wchar_t **argv);
    static SQLDBC_Connection *connectDB();
    SQLDBC_Environment *g_env;
    typedef struct ConnectArgsT {
      bstrt username;
      bstrt password;
      bstrt dbname;  
      bstrt host;    
      bstrt request;    
    } ConnectArgsT;
    ConnectArgsT connectArgs;
    void exitOnError(SQLDBC_ErrorHndl &err);
    int _tmain(int argc, _TCHAR* argv[])
         SQLDBC_Retcode ret;
       parseArgs(argc, argv);
       for (int j = 0 ; j < 10 ; ++j)
            for (int i = 0 ; i < 100 ; ++ i)
                 SQLDBC_Connection *conn = connectDB();
                 ret = conn->close();
                 ret = conn->disconnect();
                 g_env->releaseConnection(conn);
            delete g_env;
            g_env = NULL;
       return 0;
    SQLDBC_Connection *connectDB()
      char errorText[200];
      SQLDBC_Retcode rc;
      if (g_env == NULL)
    Every application has to initialize the SQLDBC library by getting a
    reference to the ClientRuntime and calling the SQLDBC_Environment constructor.
           SQLDBC_IRuntime *runtime;      
           runtime = SQLDBC::GetClientRuntime(errorText, sizeof(errorText));
           if (!runtime) {
              fprintf(stderr, "Getting instance of the ClientRuntime failed %s\n", errorText);          
           g_env = new SQLDBC_Environment(runtime);      
    Create a new connection object and open a session to the database.
      SQLDBC_Connection *conn = g_env->createConnection();
      printf("Connecting to '%s' on '%s' as user '%s'\n",
             (char)connectArgs.dbname, (char)connectArgs.host, (char*)connectArgs.username);
      rc = conn->connect(connectArgs.host, connectArgs.dbname,
                         connectArgs.username, connectArgs.password);
      if(SQLDBC_OK != rc) {
        fprintf(stderr, "Can't connect to '%s'.\nERROR: %d:'%s'\n",
                connectArgs.dbname, conn->error().getErrorCode(), conn->error().getErrorText());
        exit(1);
         conn->setAutoCommit(SQLDBC_TRUE);
      return conn;
    static void parseArgs (int argc, wchar_t **argv)
      connectArgs.username = "ESKDBADM";
      connectArgs.password = "DELORME";
      connectArgs.dbname = "EDP350";
      connectArgs.host = "ly-delorme"; 
    void exitOnError(SQLDBC_ErrorHndl &err)
      if(err) {
        fprintf(stderr, "Execution stopped %d:'%s'", err.getErrorCode(), err.getErrorText());
        //exit(1);
    Yann.

  • How to close database connections in Crystal Reports

    I am using the following code to connect to database. I can either pass JNDIName or I can provide values for others by leaving JNDI name empty.
    If i use JNDI name, it will use a connection from the connection pool of App Server (in my case Weblogic), but it is not releasing the connection after use. Connection remains even if I logoff from the application. If i keep my max connections as 15 in weblogic, after clicking the page with crystal report 15 times all will remain active and users will not be able to login to the application.
    If i use connectionString and others without using JNDI Name, it directly connects to database. So it creates a connection in database server directly without using connection pool of weblogic. If i check weblogic, it shows no connection in use as expected, but if i check database, i can see the no. of connections increasing everytime a user clicks a crystal report page.
    When the connection touches the maximum allowed connection in server, every application using the same server goes down
    How can I close the connection which was created for the viewing the report?
    String reportName = "/reports/BankBalance.rpt";
    ReportClientDocument clientDoc = (ReportClientDocument) session.getAttribute(reportName);
    if (clientDoc == null)
             clientDoc = new ReportClientDocument();
             clientDoc.setReportAppServer(ReportClientDocument.inprocConnectionString);
            // Open report
            clientDoc.open(reportName, OpenReportOptions._openAsReadOnly);
           String connectString = ""; // jdbc:sybase:Tds:DBSERVERNAME:9812/DBNAME?ServiceName=DBNAME
           String driverName = "";    // com.sybase.jdbc3.jdbc.SybDriver
           String JNDIName = "DS_APP";
           String userName = "";
           String password = "";
           // Switch all tables on the main report and sub reports
           CRJavaHelper.changeDataSource(clientDoc, userName, password, connectString, driverName, JNDIName);
         // logon to database
          CRJavaHelper.logonDataSource(clientDoc, userName, password);
    // Store the report document in session
    session.setAttribute(reportName, clientDoc);
                   // Create the CrystalReportViewer object
                          CrystalReportViewer crystalReportPageViewer = new CrystalReportViewer();
         String reportSourceSessionKey = reportName+"ReportSource";
         Object reportSource = session.getAttribute(reportSourceSessionKey);
         if (reportSource == null)
              reportSource = clientDoc.getReportSource();
              session.setAttribute(reportSourceSessionKey, reportSource);
         //     set the reportsource property of the viewer
         crystalReportPageViewer.setReportSource(reportSource);
         crystalReportPageViewer.setHasRefreshButton(true);
         crystalReportPageViewer.setToolPanelViewType(CrToolPanelViewTypeEnum.none);
         // Process the report
         crystalReportPageViewer.processHttpRequest(request, response, application, null);

    the sample shows how to clear RAS and Enterprise resources after viewing report.
    1. If you use unmanaged RAS - as I can see you using setReportAppServer, then remove the enterprise related stuff : instantiating and cleaning code.
    The sample code is meant to give you an idea on how you can release the resources after done with viewing report. In your case all you need to do for cleaning is call close() on ReportDocumentObject. The sample will need to be modified for your requirements.

  • How we close Views without using Java Script

    Hi All,
    can you please suggest me how i close view with out using java script.
    if possible please reply with code.
    Thanks
    Siva

    Hi Siva,
    You can do this either by hiding your window or by closing the window. Following is the sample code to do that
    IWDWindowInfo windowInfo = null;
    IWDWindow window =null;
    windowInfo = (IWDWindowInfo)  wdComponentAPI.getComponentInfo).findInWindows("<<WindowName>>");
    if(windowInfo!=null)
    window = wdComponentAPI.getWindowManager().createWindow(windowInfo,true);
    window.hide();
    Try with this code, might be useful for your scenario.
    Thanks,
    Sandeep

  • Close RFC Connection

    Hi,
    I have some problems with the availibility of my WebDynpro-Application. It seems to be, that to much connections are opened at the same time. Is it necessary to close the connection in the code or should it closed by the system automatically?
    To use a model I use the following code(example):
    wdContext.nodeZ_Rfc_GetData_Input().bind(new Z_Rfc_GetData_Input());
    wdContext.currentZ_Rfc_GetData_InputElement().modelObject().execute();
    wdContext.nodeOutput().invalidate();
    I don't know if there is a option to close the connection.

    Hi,
    Use below code:
    wdContext.currentRFC_InputElement().modelObject().modelInstance().disconnectIfAlive();
    Please check below forum ,
    webdynpro JCO - RFC Connections are not closing  in back end ECC (SM51)
    Regards
    Deepak

  • How to debug RFC connection using RfcOpenEx?

    Hi,
    I use COOPC1 to test a RFC connection and this transaction uses RfcOpenEx which fails.
    How can I debug this connection?
    Best regards
    Marty

    Hi,
    in fact the conection from SAP to the destination works using SM59. but the system reply with a connection using RfcOpenEx but this function fails because there is a mixup with the parameters maybe a wrong type.
    I will try to debug from the tcode COOPC1 when I start a subscription.
    Thanks
    Marty

  • How to pass the result of one script to another?

    Hi
    Is there any possibility to pass info from one script to another? I run some scripts at night and they have to use the results I get during the day...
    Thank you in advance for any help
    Vera

    There's a couple of ways of doing this.
    It sounds like the second script isn't being called directly from the first one, so you can't pass the data directly, so that leaves you with a couple of options.
    One is to have the first script write the data to a file, then have the second script read that file.
    The other would be to store the data as a property in the first script - properties are saved between executions - then have the second script read the first script's property when it starts up.
    For the first option, just have the script write the data to a file:
    set myData to "here's the data to save"
    set myFile to (open for access file (path to home folder as text & "data.file") with write permission
    write myData to myFile starting at 0
    close access myFile
    Now the second script can read the file:
    set otherScriptsData to read file (path to home folder as text & "data.file")
    For the second option, just store the data as a property:
    property myData:""
    set myData to "here's the data to save"
    Now loading the data in the second script goes like:
    set otherScript to load script file "path:to:other.scpt"
    set otherScriptsData to otherScript's myData
    Here you can see the second script loading the script then reading its myData property.

  • How many AppleTVs can connect to one computer?

    I have a client that would like to set up a large number of 2nd Generation AppleTVs to be synced to one Mac's iTunes and iPhoto libraries.
    What's the maximum number of ATVs that can connect to one computer? My client would like to connect 13, but is there a maximum number?

    Bear in mind that unlike AppleTV1 you cannot AFAIK specify different photo content to different AppleTVs - you'd therefore need to get the 13 'different' slideshows on each maybe using events, then manually choose the differing slideshow to run if doing all of this remotely.
    If someone could walk around and just hook a laptop up to each AppleTv to transfer photos over ethernet you'd have more flexibility, but this would be a chore if AppleTV lost photos for any reason.
    I don't use photos much with ATV2 and am unsure if they survive a reboot or power outage in memory.  Also unsure if there's a limit to the number of photos that can be transferred.
    AC

  • How to setup RFC Connection for SAPOSS?

    Dear Experts,
    I tried to setup the RFC connection for SAPOSS based on the following settings, but when I test connection, it failed.
    Target system : OSS
    Msg. Server : ... ( this where I stuck which I'm not sure what to fill in)
    Group : EWA
    Client : 001
    User : OSS_RFC
    Password : CPIC
    Does anyone know the right settings?
    Regards,
    Abraham

    Hi all,
    Do I really need to setup our own SAProuter if our firewall doesn't block any outbound IP address?
    I've tried the following settings in OSS1 but still failed to connect.
    SAProuter at SAP :-
    Name : sapserv3 ( or sapserv7 or sapserv2)
    IP address : 147.204.2.5   (or 194.39.134.35 or 194.39.131.34)
    Instance no : 99
    SAPNet Message Server
    Name : oss001
    DB Name : 001
    Instance No : 01
    I left the SAProuter1 and SAProuter2 (at customer site) blank.
    Did I miss out anything?

  • How to solved RFC connection (EarlyWatch)

    Hi,
    I having problem in Solution Manager 4.0 (EarlyWatch Report)
    R/3 landscape (NDV,NQA,NPR)
    NDV and NPR does works fine and getting EWA everyweek which is schedule every week
    NQA does not work at all
    Screenshot here:
    http://www.flickr.com/photos/25222280@N03/2586790185/sizes/o/
    1. I check RFC connection in solution manager (sdccn)
    Selected NQA, and click RFC button
    Login NQA tr: sdccn --> taskLog --> from menu GOTO --> setting --> Processor task
    Checkhosts then double click (RFC destination) I got error: "no host fulfils the requirements of service data control center"
    Is there any problem please let me know
    Screenshot here:
    http://www.flickr.com/photos/25222280@N03/2586794197/sizes/o/
    2. Goto SM59 --> under R/3 connection --> check connection "SM_NSMCLIENT100_BACK" does works fine...
    screenshot here:
    http://www.flickr.com/photos/25222280@N03/2586794219/sizes/o/
    Question: please let me know where and what i am missing or wrong ?
    Thanks in Advanced

    Hi Issue,
    These can solved in two ways.
    1. You dont need an trusted RFC for EWA. You can get the reports w/o TRUSTED. if you really need this, then follow option 2.
    2. Add S_RFC & S_RFCACL autorization objects to your ID in both systems. Solman & Target system.
    This will solve your issue.
    Thanks,

Maybe you are looking for

  • Populating JList with a single database column

    Hi all, I have the following code and i'm trying to popluate the JList with a particular colum from my MySQL Database.. how do i go about doing it?? Can some one please help import java.awt.*; import java.awt.event.*; import java.sql.Connection; impo

  • Having itunes open when ipod is connected

    Nano 4th generation--iTunes always opened when iPod was connected to computer; now it doesn't and going to Devices and scrolling down Summary to "open when ipod is connected" is greyed out and will not allow me to check it.  Even going to the iTunes

  • Acrobat 8.1 and Outlook 2007, still can't save as pdf

    I have intalled Acrobat 8.1, and while all the PDF goodies seem installed in Word 2007, they are not installed in Outlook 2007. Still can't save as pdf in Outlook 2007. I querried at MS Forums, only to be referred to Adobe Forums. --GJ

  • Quality INspection of Storage Tank Material

    Dear experts, I have the following scenario in QM. We are a chemical industry. we have different storage tanks((TK101A)) for like caustic soda. we are making in process inspection and inspection at the time of GR and it creates inspection lot of 04.

  • Nearly no broadband

    Hi can anyone help for several weeks we have had nearly no broadband   despite   over an hour on live chat  and the line being reset,  it worked for a few days then went again,   4 times on the phone  for nearly an hour each time  and being promised