viernes, 9 de junio de 2017

Store procedure SAP Hana

Estimados,

En esta ocasión veremos como generar un store procedure en Hana Studio e invocarlo desde visual Studio .net, asimismo adjuntare las DLL necesarias para la conexion asi como la cadena de conexion,  sabemos que no hay mucha información sobre Hana studio hasta el momento, seria bueno sus comentarios,

Saludos,

DROP PROCEDURE "Pa_OrdenCompra_Listar";

CREATE PROCEDURE "Pa_OrdenCompra_Listar" (
IN Id int)

as
BEGIN




select "DocNum" ID, "CardCode" as Codigo,"CardName" as Proveedor, "Address" Direccion, "DocTotal" Total ,cast(  "DocDate" as char(10)) Fecha , "DocCur" Moneda
from opor

;

END

  void DataHana()
    {

        HanaConnection oHanaConnection = new HanaConnection("Server=192.168.1.XX:TUPUERTO;UserID=TUUSUARIO;Password=TUCLAVE");
        oHanaConnection.Open();

        String strSQL = "select * from BD.OIGN ";

        //Execute the SQL statement
        HanaCommand cmd = new HanaCommand(strSQL, oHanaConnection);
        String strCommand = @"call  ""BD"".""Pa_OrdenCompra_Listar"" (1)";
        DataTable oDataTable = new DataTable();
        HanaCommand oHanaCommand = new HanaCommand();
        oHanaCommand.Connection = oHanaConnection;
        //  oHanaCommand.CommandType = CommandType.StoredProcedure;
        oHanaCommand.CommandText = strCommand;// @"ZZ_DESARROLLO.bpvs_CL_LY_VOUCHER";

        // CALL "bpvs_CL_LY_VOUCHER" ({?DocKey@})

        //oHanaCommand.Parameters.AddWithValue("Id", 1);

        HanaDataAdapter oHanaDataAdapter = new HanaDataAdapter(oHanaCommand);

        //Read and store the result set
        HanaDataReader reader = cmd.ExecuteReader();


        oHanaDataAdapter.Fill(oDataTable);


        string Filas = oDataTable.Rows.Count.ToString();

        //Bind the result set to a DataGridViewer/
        GridFamiliaProductos.DataSource = oDataTable;
        GridFamiliaProductos.DataBind();

        //Close the reader connection

        reader.Close();

        //Close the database connection

        oHanaConnection.Close();

    }