3

In my C# program which uses the SAP .NET connector, I want to call the RFC function "BAPI_GET_PAYROLL_RESULT_LIST" and read the result.

I looked at the function with SE37. There I found out that the export parameter should be BAPIRETURN1, which is a structure.

So I searched for an example code of an RFC call and modified it for my case.

I have already tried to read the table BAPI7004_RL, because it was in the information in SE37 and I don't know if I have to use the export parameter or the table.

This is my code:

string appServerHost = ConfigurationManager.AppSettings["AppServerHost"];
string name = ConfigurationManager.AppSettings["Name"];
string systemnumber = ConfigurationManager.AppSettings["SystemNumber"];
string user = ConfigurationManager.AppSettings["User"];
string pw = ConfigurationManager.AppSettings["Password"];
string client = ConfigurationManager.AppSettings["Client"];
string language = ConfigurationManager.AppSettings["Language"];

RfcConfigParameters parms = new RfcConfigParameters
{
    { RfcConfigParameters.AppServerHost, appServerHost },
    { RfcConfigParameters.Name, name },
    { RfcConfigParameters.SystemNumber, systemnumber },
    { RfcConfigParameters.User, user },
    { RfcConfigParameters.Password, pw },
    { RfcConfigParameters.Client, client },
    { RfcConfigParameters.Language, language }
};

RfcDestination dest = RfcDestinationManager.GetDestination(parms);
RfcRepository repo = dest.Repository;

IRfcFunction fnc = dest.Repository.CreateFunction("BAPI_GET_PAYROLL_RESULT_LIST");
fnc.SetValue("employeenumber", "0001");

fnc.Invoke(dest);

RfcStructureMetadata TableMetaData = dest.Repository.GetStructureMetadata("BAPIRETURN1");

IRfcStructure stru = fnc.GetStructure("BAPIRETURN1"); //BAPI7004_RL

//IRfcTable tabDetail = fnc.GetTable("BAPI7004_RL"); //BAPIRETURN1

After the line IRfcStructure stru = fnc.GetStructure("BAPIRETURN1") an exception is thrown at runtime, which says:

Element BAPIRETURN1 of container BAPI_GET_PAYROLL_RESULT_LIST unknown

When I try it with the table, I get the same result.

Where is the error in my code? Or is it maybe a permission problem?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
JamesnxD
  • 153
  • 1
  • 14
  • I edited your question to indicate it's a C# program and to add the C# tag (although the answer concerns the ABAP side) – Sandra Rossi Jul 05 '19 at 18:18

1 Answers1

6

The name of the parameter is "RETURN" and not "BAPIRETURN1" as specified by you. "BAPIRETURN1" is the type name, i.e. the name for the associated meta data.

Trixx
  • 1,796
  • 1
  • 15
  • 18