cancel
Showing results for 
Search instead for 
Did you mean: 

Windows Form App using NCO3

Former Member
0 Kudos

I have a Windows Form App that makes an RFC call to SAP using NCO3.    However I noticed in SAP when I look at the gateway monitor, the connection stays alive until the app itself closes in Windows.

How do I "logoff" the connection in my Windows App without having to close the app itself?

Here's the code I have so far..

               RfcConfigParameters myConfig = new RfcConfigParameters();

                myConfig.Clear();

                myConfig.Add("USER", txtUserName.Text);

                myConfig.Add("PASSWD", txtPassword.Text);

                myConfig.Add("CLIENT", txtClient.Text);

                myConfig.Add("LANG", "EN");

                myConfig.Add("SYSNR", txtSystemNumber.Text);

                myConfig.Add("ASHOST", txtAppServerHost.Text);

                myConfig.Add("NAME", txtSystemName.Text);

                //Get destination instance

                RfcDestination destination = RfcDestinationManager.GetDestination(myConfig);

                IRfcFunction function = null;

                try

                {

                    function = destination.Repository.CreateFunction("STFC_CONNECTION"); 

                    function.SetValue("REQUTEXT", "Hello SAP");

                    function.Invoke(destination);

                                    }

                catch (RfcBaseException e3)

                {

                    MessageBox.Show(e3.Message);

                    return;

                }

                string msg4box = "SUCCESS";

                MessageBox.Show(msg4box);

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can use RfcDestinationManager.UnregisterDestinationConfiguration(ID);

where ID is your implementation of IDestinationConfiguration.

just remember to re-register this ID if you wish to continue activity with SAP ( otherwise you can get exception ).

Yarden

Answers (0)