BAPI中的设置表参数失败

问题描述 投票:0回答:1

所以,这是我第一次这样做,并将结构发送到由其他人创建的BAPI,该BAPI有效,我已经在SAP中进行了尝试,但是现在,我们需要我们的主系统才能使用它。

这是结构:

With both in and out

输入值具有3个值...

the 3 values

好,所以我可以正确连接并获取信息,但是我遇到了一个错误,我认为这是由于在发送之前已准备好结构...

这里是代码:

public string SendASFEmail(string id, string tipo, string correo)
        {
            string idCompuesto = "0000" + id;         
            SAPConnection sapConnection = new SAPConnection();
            RfcDestination rfcDes = sapConnection.getRfcDestination(sapConnection);
            RfcRepository rfcRep = rfcDes.Repository;
            IRfcFunction fun = rfcRep.CreateFunction("ZSLCM_UPDATE_EMAIL");
            //Create the structure with id, tipo and correo
            IRfcTable tablaEntrada = fun.GetTable("T_CORREOS_IN");
            //Assign parameters
            RfcStructureMetadata stru = rfcRep.GetStructureMetadata("T_CORREOS_IN");
            IRfcStructure datos = stru.CreateStructure();
            datos.SetValue("ZFKK_FAM", idCompuesto);
            datos.SetValue("BPKI", tipo);
            datos.SetValue("SMTP_ADDR", correo);
            tablaEntrada.Append(datos);
            fun.SetValue("T_CORREOS_IN", tablaEntrada);
            // RUN
            fun.Invoke(rfcDes);

            //Success and get the out table which contains the same parameters plus message in column #4 
            IRfcTable tablaSalida = fun.GetTable("T_CORREOS_OUT");
            DataTable dtMessages = GetDataTableFromRFCTable(tablaSalida); //this is to take the out structure and just get the string
            string respuesta = dtMessages.Rows[0][3].ToString();
            return respuesta;
        }

而且我不断收到错误:

附加信息:StructureOnly T_CORREOS_IN的元数据不可用:NOT_FOUND:T_CORREOS_IN不存在活动的名称标签

c# asp.net sap sap-dotnet-connector
1个回答
0
投票

您的问题出在陈述中:

RfcStructureMetadata stru = rfcRep.GetStructureMetadata("T_CORREOS_IN");

API函数GetStructureMetadata( )读取SAP 存储库(!)结构而不是RFC模块的参数,因此是错误。

为了填充RFC表,您需要像这样的内容:

IRfcFunction fn = repo.CreateFunction("ZSLCM_UPDATE_EMAIL");
var correos = fn.GetTable("T_CORREOS_IN");
foreach (ListViewItem lvi in correos.Items)
{
    //Create new correos row
    correos.Append();

    //Populate current row with data from list
    correos.SetValue("ZFFK_FAM", lvi.SubItems[0].Text);
    correos.SetValue("BKPI", lvi.SubItems[1].Text);
    correos.SetValue("SMTP_ADDR", lvi.SubItems[2].Text);
}

[Here is参考答案也适用于.Net dataTable类型的示例。

阅读有关NCo功能的official Help

© www.soinside.com 2019 - 2024. All rights reserved.