So, this is my first time doing this and sending an structure to a BAPI that was created by someone else, the BAPI works, I've 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 this error:
Additional information: metadata for StructureOnly T_CORREOS_IN not available: NOT_FOUND: No active nametab exists for T_CORREOS_IN
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();
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;
}