cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass input parameters to ZRFC using sap connector 3.0

Former Member
0 Kudos

Hi,

In the connector 2.0 we were passing parameters (vendor# as input) to rfc as ( eg: rfc_name(I_vendor, E_VendorTBL) and able get the results in the output table .

How do we do this using new NCO3.0.

Thanks,

Rajender

Accepted Solutions (1)

Accepted Solutions (1)

bryan_lanning2
Explorer
0 Kudos
static void Main(string[] args)
        {
            RfcDestinationManager.RegisterDestinationConfiguration(new MyBackendConfig());
            RfcDestination prd = RfcDestinationManager.GetDestination("PRD_000");
            RfcRepository repo = prd.Repository;
            IRfcFunction companyBapi = repo.CreateFunction("BAPI_SALESORDER_GETLIST");
            companyBapi.SetValue("CUSTOMER_NUMBER", "246");

The code above shows how to pass parameters such as the vendor number to the BAPI. I've been able to make it work for the example BAPI (BAPI_COMPANY_DETAIL) that is in the SAP .NET Connector 3.0 Overview document on page 9.

I don't know how to pass or catch returned IRfcTable objects though...

Former Member
0 Kudos

Thanks for the sample code to pass the input values to RFC. Also, as you said, is there any way in NCO 3.0 to convert rfcTable to .Net datatable (like in connector 2.0, we have "ToADOtable", "FromADOtable") so that we can bind the output table directly to gridview.

It seems to be big drawback that, unable to get intellisence.

Former Member
0 Kudos

Here is something I wrote that should get you started...

IRfcTable lrfcTable = bapi.GetTable("TICKETS") ;

DataTable loTable = new DataTable();

//... Create ADO.Net table.

for (int liElement = 0; liElement < lrfcTable.ElementCount; liElement++) {

RfcElementMetadata metadata = lrfcTable.GetElementMetadata(liElement);

loTable.Columns.Add(metadata.Name);

}

//... Transfer rows from lrfcTable to ADO.Net table.

foreach (IRfcStructure row in lrfcTable) {

DataRow ldr = loTable.NewRow();

for (int liElement = 0; liElement < lrfcTable.ElementCount; liElement++) {

RfcElementMetadata metadata = lrfcTable.GetElementMetadata(liElement);

ldr[metadata.Name] = row.GetString(metadata.Name);

}

loTable.Rows.Add(ldr);

}

//... Bind ADO.Net table.

DataGrid1.DataSource = loTable;

DataGrid1.DataBind();

Former Member
0 Kudos

I have implemented an example similar to the above which stores the results of a table in a .net DataTable. I am trying to bind the DataTable to a DataGridView but the DataGridView is simply blank.

DataTable dt = svc.getTableData("crmd_orderadm_h");

                bindingSource.DataSource = dt;
                dataGridView1.DataSource = bindingSource;

Any ideas on why the DataGridView is empty?

Former Member
0 Kudos

>

> I have implemented an example similar to the above which stores the results of a table in a .net DataTable. I am trying to bind the DataTable to a DataGridView but the DataGridView is simply blank.

>

>

>

DataTable dt = svc.getTableData("crmd_orderadm_h");
> 
>                 bindingSource.DataSource = dt;
>                 dataGridView1.DataSource = bindingSource;

>

>

> Any ideas on why the DataGridView is empty?

For the benefit of others here, I resolved the problem by examining the properties of the datagridview control. In this case, the datagridview control binding property was being set in the visual studio designer and for some reason was not able to be set at runtime. I removed the binding property in the visual studio property window and the problem was resolved.

Thanks for those who contributed answers to this issue.

Edited by: Mike Powell on Mar 1, 2011 3:30 PM

Answers (1)

Answers (1)

former_member197445
Contributor
0 Kudos

Have you tried:

dataGridView1.DataSource = dt;
dataGridView1.DataBind();

Former Member
0 Kudos

You can make a Class with all parameters from your table and then make an array object of that class. Get the returned data

into that array and pass it to Gridview.datasource. It Works!