0

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:

With both in and out

The in values has 3 values...

the 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;
        }
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Henry B
  • 29
  • 8

1 Answers1

0

Your problem is in the statement:

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

API function GetStructureMetadata( ) reads SAP repository (!) structure and not parameters of RFC module, hence is the error.

For filling RFC table you need smth like this:

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 the reference answer also with .Net dataTable type sample.

Read official Help about NCo functions.

Suncatcher
  • 10,355
  • 10
  • 52
  • 90