0

IRfcFunction を呼び出そうとすると、RfcCommunicationException の問題が発生します。BAPI_MATERIAL_GETLIST を次のように処理すると、結果が得られます。

    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));
    }

しかし、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));
    }

ここの指示に従いましたが、BAPI_FUNCLOC_GETLIST を処理できないようです。

4

2 に答える 2