5

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's my code (EDIT: based on the RFC client provided within SAP GUI for Windows):

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?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
ridermansb
  • 10,779
  • 24
  • 115
  • 226
  • 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 Mar 01 '11 at 15:01
  • 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](http://forums.sdn.sap.com/thread.jspa?threadID=1425169), [here](http://sunhongwei2002.blog.163.com/blog/static/149007012201062165717737/) and [here](http://blog.csdn.net/robaot/archive/2009/10/20/4704127.aspx) – ridermansb Mar 01 '11 at 17:12
  • I dont think example 3 is correct. Normally you assign import parameters not export parameters. – Stefan Ernst Mar 02 '11 at 09:47
  • Actually I tried the method get_Imports too, but he also returned null – ridermansb Mar 02 '11 at 12:12

2 Answers2

1

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

PATRY Guillaume
  • 4,287
  • 1
  • 32
  • 41
  • The loop was just to list the names of the columns. It is of no use beyond this. The parameter you want to retrieve is the "MATNR" – ridermansb Mar 01 '11 at 17:06
  • is MATNR a field of the table ? as i said, you're trying to get a parameters. Without the technical description of the function, there is not much we can do. Is this a standard function or a specific one (in which case it will begin by 'Z' or 'Y') ? – PATRY Guillaume Mar 01 '11 at 19:46
  • function begins with "y " (I'll get the full name of the function is comment here) MATNR is a field. – ridermansb Mar 01 '11 at 19:56
  • **Function name is:** YYPCL_RFC_ESTOQUES. **Paramter is:** MATNR – ridermansb Mar 03 '11 at 17:16
0

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

Stefan Ernst
  • 2,781
  • 4
  • 25
  • 34
  • I'm not sure. If the example links are right, he's trying to get the parameter to fill it before the call... – PATRY Guillaume Mar 01 '11 at 15:16
  • I can not call the function without passing the parameter before because otherwise it will bring all the records (no filter). – ridermansb Mar 01 '11 at 17:07
  • why are you trying to access the export parameter list? It wont hold any values until the function module is executed – Stefan Ernst Mar 02 '11 at 09:44
  • because I need to pass a parameter to the function to be able to filter the results. I'm just following the examples listed above – ridermansb Mar 02 '11 at 12:11
  • that's bugging me also... normally you get the "import" parameters, fill them, execute and get the export parameters. In you code and the exemples, you're filling an export. Perhaps this is a "Modification" param. That's why we're asking for the function definition – PATRY Guillaume Mar 03 '11 at 09:16
  • **Function name is:** YYPCL_RFC_ESTOQUES. **Paramter is:** MATNR – ridermansb Mar 03 '11 at 11:28
  • Searching the internet I saw a VB6 way to pass parameter. But an error occurs. [Here](http://jsfiddle.net/Riderman/amBub/) is my code in C #. **Error:** Parameter not optional DISP_E_PARAMNOTOPTIONAL. **Full Error:** System.Runtime.InteropServices.COMException (0x8002000F): Parameter not optional. (Exception from HRESULT: 0x8002000F (DISP_E_PARAMNOTOPTIONAL)) at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) at SAPTableFactoryCtrl._CSAPTaFacRow.set_Cell(Int32 lRow, Object vaColumn, Object ) – ridermansb Mar 03 '11 at 13:26