Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integration with SAP

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?

like image 517
ridermansb Avatar asked Nov 14 '22 02:11

ridermansb


1 Answers

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

like image 192
PATRY Guillaume Avatar answered Dec 14 '22 09:12

PATRY Guillaume