Skip to Content
0
May 18, 2020 at 04:48 PM

Sending a table thru a BAPI and using net

463 Views

So, this is my first time doing this and sending an structure to a BAPI that was created by someone else, the BAPI works, Ive tried it in SAP, but now, we need our master system to use it.

This is the structure:

The in values has 3 values...

Ok, so I can connect correctly and get the information, but I am getting an error, and I think this is due to the structure being prepared before being sent...

Here is the code:

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();
            tablaEntrada.SetValue("ZFKK_FAM", idCompuesto);
            tablaEntrada.SetValue("BPKI", tipo);
            tablaEntrada.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;
        }
<br>

And I keep getting the error:

Additional information: metadata for StructureOnly T_CORREOS_IN not available: NOT_FOUND: No active nametab exists for T_CORREOS_IN