sap-erpbapisap-dotnet-connector

SAP .NET Connector BAPI_FUNCLOC_GETLIST RfcCommunicationException


When I attempt to invoke the IRfcFunction BAPI_FUNCLOC_GETLIST, I get an RfcCommunicationException that says

Syntax or generation error in a screen

I followed the instructions here, but can't seem to get BAPI_FUNCLOC_GETLIST to process.

What is the problem with the code?

NB: I can process BAPI_MATERIAL_GETLIST like so and I get results.

Code to call BAPI_FUNCLOC_GETLIST (RfcCommunicationException):

    SAPSystemConnect cfg = new SAPSystemConnect();
    RfcDestinationManager.RegisterDestinationConfiguration(cfg);
    RfcDestination dest = RfcDestinationManager.GetDestination("mySAPdestination");
    RfcRepository repo = dest.Repository;
    IRfcFunction func = repo.CreateFunction("BAPI_FUNCLOC_GETLIST");

    IRfcTable tbl = func.GetTable("FUNCLOC_RA");

    tbl.Append();
    tbl.SetValue("SIGN", "I");
    tbl.SetValue("OPTION", "CP");
    tbl.SetValue("LOW", "MY-FL*");            

    func.SetValue("FUNCLOC_RA", tbl);
    IRfcTable tbl2 = func.GetTable("FUNCLOC_LIST");

    func.Invoke(dest); // I get an RfcCommunicationException here that says
                       // "Syntax or generation error in a screen."

    DataTable dt = tbl2.ToDataTable("table1");

    foreach (DataRow row in dt.Rows)
    {
        Console.WriteLine("{0}", row.Field<string>(0));
    }

Code to call BAPI_MATERIAL_GETLIST (works fine):

    SAPSystemConnect cfg = new SAPSystemConnect();
    RfcDestinationManager.RegisterDestinationConfiguration(cfg);
    RfcDestination dest = RfcDestinationManager.GetDestination("mySAPdestination");
    RfcRepository repo = dest.Repository;
    IRfcFunction func = repo.CreateFunction("BAPI_MATERIAL_GETLIST");

    IRfcTable tbl = func.GetTable("MATNRSELECTION");            
                    
    tbl.Append();
    tbl.SetValue("SIGN", "I");
    tbl.SetValue("OPTION", "BT");
    tbl.SetValue("MATNR_LOW", "10");
    tbl.SetValue("MATNR_HIGH", "20");

    func.SetValue("MATNRSELECTION", tbl);
    IRfcTable tbl2 = func.GetTable("MATNRLIST");

    func.Invoke(dest);
                   
    DataTable dt = tbl2.ToDataTable("table1");

    foreach (DataRow row in dt.Rows)
    {
        Console.WriteLine("{0}", row.Field<string>(0));
    }

Solution

  • This is really old, but thought I'd share what I found. Some BAPIs seem to work regardless of how your config parameters are set. Here's an example:

    public RfcConfigParameters GetParameters(string destinationName)
        {
    
            RfcConfigParameters parms = new RfcConfigParameters();
    
            if (destinationName.Equals("mySAPdestination"))
            {
                parms.Add(RfcConfigParameters.AppServerHost, "sapnode.mycompany.net");
                parms.Add(RfcConfigParameters.SystemNumber, "21");
                parms.Add(RfcConfigParameters.SystemID, "CF1");
                parms.Add(RfcConfigParameters.User, "mySAPuser");
                parms.Add(RfcConfigParameters.Password, "mySAPpassword");
                parms.Add(RfcConfigParameters.Client, "100");
                parms.Add(RfcConfigParameters.Language, "EN"); 
                parms.Add(RfcConfigParameters.PoolSize, "5");
            }
            return parms;
    
        }
    

    What I found I needed to get any BAPI, that was available to me, to work, was to ensure I connected using the "RfcConfigParameters.LogonGroup" parameter...

    parms.Add(RfcConfigParameters.LogonGroup, "GRPX")