0

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));
    }
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Sup3rUser
  • 21
  • 1
  • 1
  • 6
  • Check the transaction `ST22` in the ABAP system - any short dumps there? – vwegert Sep 11 '14 at 17:17
  • I have no authorization to ST22. – Sup3rUser Sep 29 '14 at 15:23
  • try contacting your admins. The short dump should give you an idea of what's going wrong. And you can get rid of the line "func.SetValue("FUNCLOC_RA", tbl);". The table is already part of the function module object, you don't need to set it again. Btw I tested the FM in one of our ECC 6.0 systems and your parameters seem valid, at least it didn't dump on me. – Dirk Trilsbeek Sep 30 '14 at 08:52
  • You Do not need to Set the table with setValue back to the function. Try it without – etalon11 Jul 13 '15 at 19:55

2 Answers2

1

"Syntax or generation error in a screen."

It looks like BAPI_FUNCLOC_GETLIST (or some subroutine it is calling internally) has syntax errors. As this is a standard BAPI delivered by SAP, this is quite unusual... :-)

And when you try to call a function module with syntax errors, the SAP system dumps and aborts the connection. (Though I would expect an RfcSystemException in this case, not an RfcCommunicationException!?)

Can it be that the import of some patch or hotpackage into your SAP system has failed and damaged the ABAP code of that function module (or of internally used components) or left it in an inconsistent state?

Lanzelot
  • 15,976
  • 4
  • 18
  • 14
0

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")
Sup3rUser
  • 21
  • 1
  • 1
  • 6