cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting to QA with Nco3.0 "Invalid Destination"

Former Member
0 Kudos

Hi all,

I am workign on a proof of concept for my management to prove that i can connect to our SAP QA system using nCo3.0 in a small VS2010 C# project. All i need to do at this stage is to get a connection to the backend system and display something from a backend function or create something.

I have the code below that I found with a google search. It complies ok, but i get the error "Cannot get a client connection: invalid destination (QAS_315 (DELETED). I have tripple checked the IP, the system number & the client. All match our QA SAP system fine. Should I have enabled something in SAP GUI to allow this connection?

Many thanks

CODE:

public partial class Form1 : Form

    {

        string MATNR = string.Empty;

        public Form1()

        {

            InitializeComponent();

        }

        public void nco()

        {

            IDestinationConfiguration ID = new MyBackendConfig();

            RfcDestinationManager.RegisterDestinationConfiguration(ID);

            RfcDestination prd = RfcDestinationManager.GetDestination("QAS_315");

            RfcDestinationManager.UnregisterDestinationConfiguration(ID);

            nco(prd);

        }

        public void nco(RfcDestination prd)

        {

            RfcRepository repo = prd.Repository;

            IRfcFunction companyBapi = repo.CreateFunction("ZRFC_MARA_INFO");   //RFC FUNCTION NAME

            companyBapi.SetValue("MATNR", MATNR);   //SET Import PARAMETER

            companyBapi.Invoke(prd);   //  EXECUTE FUNCTION

            IRfcTable table = companyBapi.GetTable("IT_MARA");  //GET MAPPING INTERAL TABLE

            string MAKTX = companyBapi.GetValue("MAKTX").ToString();  //GET MM NAME

            DataTable dt = new DataTable();  //CREATE A NEW TABLE

            dt.Columns.Add("u54C1u53F7");  //ADD A COLUMN

            for (int i = 0; i < table.RowCount; i++)

            {

                table.CurrentIndex = i; 

                DataRow dr = dt.NewRow();

                dr[0] = table.GetString("MATNR"); 

                dt.Rows.Add(dr); 

            }

            if (MATNR == "")

            {

                for (int i = 0; i < dt.Rows.Count; i++)

                {

                  //  this.comboBox1.Items.Add(dt.Rows<i>[0].ToString());   //u586Bu5145u4E0Bu62C9u6846

                }

            }

            this.label1.Text = MAKTX;

            prd = null;

            repo = null;

        }

        public class MyBackendConfig : IDestinationConfiguration

        {

            public RfcConfigParameters GetParameters(String destinationName)

            {

                if ("QAS_315".Equals(destinationName))

                {

                RfcConfigParameters parms = new RfcConfigParameters();

  parms.Add(RfcConfigParameters.AppServerHost, "152.37.876.433");                            parms.Add(RfcConfigParameters.SystemNumber, "00"); 

  1. parms.Add(RfcConfigParameters.User, "user");                  parms.Add(RfcConfigParameters.Password, "pswrd"); 

                parms.Add(RfcConfigParameters.Client, "315"); 

                parms.Add(RfcConfigParameters.Language, "EN"); 

                return parms;

                }

                else return null;

            }

            public bool ChangeEventsSupported()

            {

                return false;

            }

            public event RfcDestinationManager.ConfigurationChangeHandler ConfigurationChanged;

        }

        private void Form1_Load(object sender, EventArgs e)

        {

            comboBox1.Items.Clear();

            nco();

            comboBox1.SelectedIndex = 1;

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

        {

            MATNR = comboBox1.Text.ToString();

            nco();

        }

    }

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Please try comment Line no. 15 .

Yarden.

Former Member
0 Kudos

That has solved the issue perfectly. Many thanks.

Answers (0)