5
votes

I am creating a system to integrate with SAP.

The client gave me the function and parameters, according to him, this function was usually performed in SAP but in my code when I try to retrieve the parameter, it returns me null.

Here my code

SAPFunctionsOCX.SAPFunctionsClass func = new SAPFunctionsOCX.SAPFunctionsClass();
func.Connection = connection;
SAPFunctionsOCX.IFunction ifunc = (SAPFunctionsOCX.IFunction)func.Add(functionName);
SAPTableFactoryCtrl.Tables tables = (SAPTableFactoryCtrl.Tables)ifunc.Tables;
SAPTableFactoryCtrl.Table objTable = (SAPTableFactoryCtrl.Table)tables[tableName];

//Paramters (Find one column "MATNR"
SAPTableFactoryCtrl.Columns cols2 = (SAPTableFactoryCtrl.Columns)objTable.Columns;
for (int i = 1; i <= cols2.Count; i++)
{
    SAPTableFactoryCtrl.Column col = (SAPTableFactoryCtrl.Column)cols2[i];
    Console.WriteLine(col.Name);
}

//Error here!  matnr == null
SAPFunctionsOCX.IParameter matnr = (SAPFunctionsOCX.IParameter)ifunc.get_Exports("MATNR");

Searching the internet found several examples similar to mine, here, here and here!

Why the method. get_Exports("MATNR"); returns null?

2
is this a standard function module? I can't see it in the code. The export parameter list could be null, maybe there are table parameters you need to check instead. - Stefan Ernst
functionName, tableName are variable containing the name of the function and table name respectively. Table parameters can not recover, there is a method get_Exports and function. (See examples on here, here and here - ridermansb
I dont think example 3 is correct. Normally you assign import parameters not export parameters. - Stefan Ernst
Actually I tried the method get_Imports too, but he also returned null - ridermansb

2 Answers

1
votes

What are the exact parameters that where given to you for the RFC function ?
In the first part you seems to be looping over the column name of a table, and in the second one, you're searching for a parameter (ie not in the table).

regards
Guillaume

PS : ABAP is SAP proprietary language

0
votes

I think you forgot the actual function call, at least in the code sample