Reputation: 31
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));
}
Upvotes: 0
Views: 1763
Reputation: 31
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")
Upvotes: 0
Reputation: 16575
"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?
Upvotes: 1