Ejemplo n.º 1
1
        //将RFC表转换DATATABLE格式
        public static DataTable GetDataTableFromRfcTable(IRfcTable rfcTable)
        {
            DataTable dtRet = new DataTable();

            for (int liElement = 0; liElement < rfcTable.ElementCount; liElement++)
            {
                RfcElementMetadata rfcEMD = rfcTable.GetElementMetadata(liElement);
                dtRet.Columns.Add(rfcEMD.Name);
            }

            foreach (IRfcStructure row in rfcTable)
            {
                DataRow dr = dtRet.NewRow();

                for (int liElement = 0; liElement < rfcTable.ElementCount; liElement++)
                {
                    RfcElementMetadata rfcEMD = rfcTable.GetElementMetadata(liElement);

                    dr[rfcEMD.Name] = row.GetString(rfcEMD.Name);
                    // Console.WriteLine("{0} is {1}", rfcEMD.Documentation, dr[rfcEMD.Name]);
                }

                dtRet.Rows.Add(dr);

            }

            return dtRet;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// sap table data convert to datatable
        /// </summary>
        /// <param name="rfcTable"></param>
        /// <returns></returns>
        private DataTable ConvertToDotNetTable(IRfcTable rfcTable)
        {
            DataTable dtTable = new DataTable();

            for (int i = 0; i < rfcTable.ElementCount; i++)
            {
                RfcElementMetadata metadta = rfcTable.GetElementMetadata(i);
                dtTable.Columns.Add(metadta.Name);
            }
            foreach (IRfcStructure row in rfcTable)
            {
                DataRow dr = dtTable.NewRow();
                for (int i = 0; i < rfcTable.ElementCount; i++)
                {
                    RfcElementMetadata metadata = rfcTable.GetElementMetadata(i);
                    if (metadata.DataType == RfcDataType.BCD && metadata.Name == "ABC")
                    {
                        dr[i] = row.GetInt(metadata.Name);
                    }
                    else
                    {
                        dr[i] = row.GetString(metadata.Name);
                    }
                }
                dtTable.Rows.Add(dr);
            }
            return(dtTable);
        }
Ejemplo n.º 3
0
        public DataTable GetSAPTable(string tableName)
        {
            DataTable data = new DataTable();

            IRfcTable functionRfcTable = this.rfcFunction.GetTable(tableName);

            for (int i = 0; i <= functionRfcTable.ElementCount - 1; i++)
            {
                RfcElementMetadata metadata = functionRfcTable.GetElementMetadata(i);
                data.Columns.Add(metadata.Name);
            }

            //Transfer rows from rfcTable to .Net table.
            foreach (IRfcStructure row in functionRfcTable)
            {
                DataRow rowAdd = data.NewRow();
                for (int j = 0; j <= functionRfcTable.ElementCount - 1; j++)
                {
                    RfcElementMetadata metadata = functionRfcTable.GetElementMetadata(j);
                    rowAdd[metadata.Name] = row.GetString(metadata.Name);
                }
                data.Rows.Add(rowAdd);
            }

            return(data);
        }
Ejemplo n.º 4
0
        //把RFCTABLE 转换成DataTable.
        public static DataTable RfcTableToDataTable(IRfcTable rfcTable)
        {
            DataTable dtRet = new DataTable();

            for (int liElement = 0; liElement < rfcTable.ElementCount; liElement++)
            {
                RfcElementMetadata rfcEMD = rfcTable.GetElementMetadata(liElement);
                //Console.WriteLine("Name:" + rfcEMD.Name);
                //Console.WriteLine("DatType:" + rfcEMD.DataType);
                dtRet.Columns.Add(rfcEMD.Name, RfcTypeConvertor.RfcTypeToSystemType(rfcEMD.DataType));
            }
            foreach (IRfcStructure row in rfcTable)
            {
                DataRow dr = dtRet.NewRow();
                for (int liElement = 0; liElement < rfcTable.ElementCount; liElement++)
                {
                    RfcElementMetadata rfcEMD = rfcTable.GetElementMetadata(liElement);
                    //Console.WriteLine("Name:" + rfcEMD.Name);
                    //Console.WriteLine("DatType:" + rfcEMD.DataType);
                    //Console.WriteLine("Object:" + row.GetValue(liElement));
                    Object o = Converts.RfcToDoNetValue(row.GetValue(liElement), rfcEMD.DataType);
                    if (String.IsNullOrWhiteSpace(o.ToString()))
                    {
                        o = "";
                    }
                    //Console.WriteLine("ConvertedValue:  " + o);
                    //Console.WriteLine("");
                    dr[rfcEMD.Name] = o;
                }
                dtRet.Rows.Add(dr);
            }
            return(dtRet);
        }
Ejemplo n.º 5
0
        public DataTable GetDataTableFromRFCTable(IRfcTable rfcTable)
        {
            DataTable dt = new DataTable();

            for (int i = 0; i <= rfcTable.ElementCount - 1; i++)
            {
                RfcElementMetadata metadata = rfcTable.GetElementMetadata(i);

                dt.Columns.Add(metadata.Name);
            }

            foreach (IRfcStructure rfcStructure in rfcTable)
            {
                DataRow dr = dt.NewRow();

                for (int j = 0; j <= rfcTable.ElementCount - 1; j++)
                {
                    RfcElementMetadata metadata = rfcTable.GetElementMetadata(j);

                    var rowData = rfcStructure.GetString(metadata.Name);

                    dr[metadata.Name] = rowData;
                }

                dt.Rows.Add(dr);
            }

            return(dt);
        }
Ejemplo n.º 6
0
        //Convierte a dropdownlist
        public DataTable toDropdownList(IRfcTable RFCTable, DropDownList ID_DropdownList, string TextField, string ValueField)
        {
            DataTable dtTable = new DataTable();

            for (int item = 0; item < RFCTable.ElementCount; item++)
            {
                RfcElementMetadata metadata = RFCTable.GetElementMetadata(item);
                dtTable.Columns.Add(metadata.Name);
            }

            foreach (IRfcStructure row in RFCTable)
            {
                DataRow dr = dtTable.NewRow();
                for (int item = 0; item < RFCTable.ElementCount; item++)
                {
                    RfcElementMetadata metadata = RFCTable.GetElementMetadata(item);
                    if (metadata.DataType == RfcDataType.BCD && metadata.Name == "ABC")
                    {
                        dr[item] = row.GetInt(metadata.Name);
                    }
                    else
                    {
                        dr[item] = row.GetString(metadata.Name);
                    }
                }
                dtTable.Rows.Add(dr);
            }
            ID_DropdownList.DataSource     = dtTable;
            ID_DropdownList.DataTextField  = TextField;
            ID_DropdownList.DataValueField = ValueField;
            ID_DropdownList.DataBind();
            return(dtTable);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// RFC数据转换成DataTable类型
        /// </summary>
        /// <param name="myrfcTable"></param>
        /// <returns></returns>
        public DataTable ConversionDataTableRFCTable(IRfcTable myrfcTable) //处理SAP数据 返回 datatabl
        {
            DataTable loTable1 = new DataTable();

            if (myrfcTable == null)
            {
                return(loTable1);
            }
            int liElement = 0;

            for (liElement = 0; liElement <= myrfcTable.ElementCount - 1; liElement++)
            {
                RfcElementMetadata metadata = myrfcTable.GetElementMetadata(liElement);
                loTable1.Columns.Add(metadata.Name);
            }
            foreach (IRfcStructure Row in myrfcTable)
            {
                DataRow ldr = loTable1.NewRow();
                for (liElement = 0; liElement <= myrfcTable.ElementCount - 1; liElement++)
                {
                    RfcElementMetadata metadata = myrfcTable.GetElementMetadata(liElement);
                    ldr[metadata.Name] = Row.GetString(metadata.Name);
                }
                loTable1.Rows.Add(ldr);
            }
            return(loTable1);
        }
Ejemplo n.º 8
0
        public DataTable ConvertToDotNetTable(IRfcTable RFCTable)
        {
            DataTable dtTable = new DataTable();

            //crear tabla
            for (int item = 0; item < RFCTable.ElementCount; item++)
            {
                RfcElementMetadata metadata = RFCTable.GetElementMetadata(item);
                dtTable.Columns.Add(metadata.Name);
            }
            foreach (IRfcStructure row in RFCTable)
            {
                DataRow dr = dtTable.NewRow();
                for (int item = 0; item < RFCTable.ElementCount; item++)
                {
                    RfcElementMetadata metadata = RFCTable.GetElementMetadata(item);
                    if (metadata.DataType == RfcDataType.BCD && metadata.Name == "ABC")
                    {
                        dr[item] = row.GetInt(metadata.Name);
                    }
                    else
                    {
                        dr[item] = row.GetString(metadata.Name);
                    }
                }
                dtTable.Rows.Add(dr);
            }
            return(dtTable);
        }
Ejemplo n.º 9
0
        //Convierte gridview
        public DataTable toGridView(IRfcTable RFCTable, GridView ID_GridView)
        {
            DataTable dtTable = new DataTable();

            for (int item = 0; item < RFCTable.ElementCount; item++)
            {
                RfcElementMetadata metadata = RFCTable.GetElementMetadata(item);
                dtTable.Columns.Add(metadata.Name);
            }

            foreach (IRfcStructure row in RFCTable)
            {
                DataRow dr = dtTable.NewRow();
                for (int item = 0; item < RFCTable.ElementCount; item++)
                {
                    RfcElementMetadata metadata = RFCTable.GetElementMetadata(item);
                    if (metadata.DataType == RfcDataType.BCD && metadata.Name == "ABC")
                    {
                        dr[item] = row.GetInt(metadata.Name);
                    }
                    else
                    {
                        dr[item] = row.GetString(metadata.Name);
                    }
                }
                dtTable.Rows.Add(dr);
            }

            ID_GridView.DataSource = dtTable;
            ID_GridView.DataBind();
            return(dtTable);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Konwersja tabel SAP na tabele .NET DataTable
        /// </summary>
        /// <param name="sapTable">Tabela Sap do konwersji.</param>
        /// <param name="name">Nazwa tworzonej i zwracanej tabeli .NET DataTable</param>
        /// <returns>adoTable</returns>
        public static DataTable ToDataTable(this IRfcTable sapTable, string name)
        {
            DataTable adoTable = new DataTable(name);

            // Tworzenie ADO.Net tabeli
            for (int element = 0; element < sapTable.ElementCount; element++)
            {
                RfcElementMetadata metadata = sapTable.GetElementMetadata(element);
                adoTable.Columns.Add(metadata.Name, GetDataType(metadata.DataType));
            }

            // Stworzenie wierszy tabeli ADO.Net na podstawie tabeli SAP
            foreach (IRfcStructure row in sapTable)
            {
                DataRow ldr = adoTable.NewRow();
                for (int element = 0; element < sapTable.ElementCount; element++)
                {
                    RfcElementMetadata metadata = sapTable.GetElementMetadata(element);

                    switch (metadata.DataType)
                    {
                    case RfcDataType.DATE:
                        ldr[metadata.Name] = row.GetString(metadata.Name).Substring(0, 4) + row.GetString(metadata.Name).Substring(5, 2) + row.GetString(metadata.Name).Substring(8, 2);
                        break;

                    case RfcDataType.BCD:
                        ldr[metadata.Name] = row.GetDecimal(metadata.Name);
                        break;

                    case RfcDataType.CHAR:
                        ldr[metadata.Name] = row.GetString(metadata.Name);
                        break;

                    case RfcDataType.STRING:
                        ldr[metadata.Name] = row.GetString(metadata.Name);
                        break;

                    case RfcDataType.INT2:
                        ldr[metadata.Name] = row.GetInt(metadata.Name);
                        break;

                    case RfcDataType.INT4:
                        ldr[metadata.Name] = row.GetInt(metadata.Name);
                        break;

                    case RfcDataType.FLOAT:
                        ldr[metadata.Name] = row.GetDouble(metadata.Name);
                        break;

                    default:
                        ldr[metadata.Name] = row.GetString(metadata.Name);
                        break;
                    }
                }

                adoTable.Rows.Add(ldr);
            }

            return(adoTable);
        }
Ejemplo n.º 11
0
        private static DataTable GetDataTableFromRFCTable(IRfcTable rfcTable)
        {
            if (rfcTable == null || rfcTable.RowCount == 0)
            {
                return(null);
            }

            DataTable data = new DataTable();

            int columns = 0;

            for (columns = 0; columns <= rfcTable.ElementCount - 1; columns++)
            {
                RfcElementMetadata metadata = rfcTable.GetElementMetadata(columns);
                data.Columns.Add(metadata.Name);
            }

            foreach (IRfcStructure Row in rfcTable)
            {
                DataRow ldr = data.NewRow();

                for (columns = 0; columns <= rfcTable.ElementCount - 1; columns++)
                {
                    RfcElementMetadata metadata = rfcTable.GetElementMetadata(columns);
                    ldr[metadata.Name] = Row.GetString(metadata.Name);
                }
                data.Rows.Add(ldr);
            }

            return(data);
        }
Ejemplo n.º 12
0
        //将RFC表转换DATATABLE格式
        public static DataTable GetDataTableFromRfcTable(IRfcTable rfcTable)
        {
            DataTable dtRet = new DataTable();

            for (int liElement = 0; liElement < rfcTable.ElementCount; liElement++)
            {
                RfcElementMetadata rfcEMD = rfcTable.GetElementMetadata(liElement);
                dtRet.Columns.Add(rfcEMD.Name);
            }

            foreach (IRfcStructure row in rfcTable)
            {
                DataRow dr = dtRet.NewRow();

                for (int liElement = 0; liElement < rfcTable.ElementCount; liElement++)
                {
                    RfcElementMetadata rfcEMD = rfcTable.GetElementMetadata(liElement);

                    dr[rfcEMD.Name] = row.GetString(rfcEMD.Name);
                    // Console.WriteLine("{0} is {1}", rfcEMD.Documentation, dr[rfcEMD.Name]);
                }

                dtRet.Rows.Add(dr);
            }

            return(dtRet);
        }
Ejemplo n.º 13
0
        private DataTable IRfcTable_To_DataTable(IRfcTable doc, string tableName)
        {
            DataTable table = new DataTable(tableName);

            for (int i = 0; i < doc.ElementCount; i++)
            {
                RfcElementMetadata metadata = doc.GetElementMetadata(i);
                if (metadata.DataType.ToString().Equals("CHAR"))
                {
                    table.Columns.Add(metadata.Name, System.Type.GetType("System.String"));
                }
                else if (metadata.DataType.ToString().Equals("BCD"))
                {
                    table.Columns.Add(metadata.Name, System.Type.GetType("System.Decimal"));
                }
                else if (metadata.DataType.ToString().Equals("DATE"))
                {
                    table.Columns.Add(metadata.Name, System.Type.GetType("System.String"));
                }
                else if (metadata.DataType.ToString().Equals("TIME"))
                {
                    table.Columns.Add(metadata.Name, System.Type.GetType("System.String"));
                }
                else if (metadata.DataType.ToString().Equals("NUM"))
                {
                    table.Columns.Add(metadata.Name, System.Type.GetType("System.Int32"));
                }
            }
            foreach (IRfcStructure row in doc)
            {
                DataRow dr = table.NewRow();
                for (int i = 0; i < doc.ElementCount; i++)
                {
                    RfcElementMetadata metadata = doc.GetElementMetadata(i);
                    if (metadata.DataType.ToString().Equals("CHAR"))
                    {
                        dr[metadata.Name] = row.GetString(metadata.Name);
                    }
                    else if (metadata.DataType.ToString().Equals("BCD"))
                    {
                        dr[metadata.Name] = row.GetDecimal(metadata.Name);
                    }
                    else if (metadata.DataType.ToString().Equals("DATE"))
                    {
                        dr[metadata.Name] = row.GetString(metadata.Name);
                    }
                    else if (metadata.DataType.ToString().Equals("TIME"))
                    {
                        dr[metadata.Name] = row.GetString(metadata.Name);
                    }
                    else if (metadata.DataType.ToString().Equals("NUM"))
                    {
                        dr[metadata.Name] = row.GetInt(metadata.Name);
                    }
                }
                table.Rows.Add(dr);
            }
            return(table);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Converts SAP table to .NET DataTable table
        /// </summary>
        /// <param name="sapTable">The SAP table to convert.</param>
        /// <returns></returns>
        public static DataTable RfcTableToDataTable(IRfcTable sapTable, string name)
        {
            DataTable adoTable = new DataTable(name);

            //... Create ADO.Net table.
            for (int liElement = 0; liElement < sapTable.ElementCount; liElement++)
            {
                RfcElementMetadata metadata = sapTable.GetElementMetadata(liElement);
                adoTable.Columns.Add(metadata.Name, GetDataType(metadata.DataType));
            }

            //Transfer rows from SAP Table ADO.Net table.
            foreach (IRfcStructure row in sapTable)
            {
                DataRow ldr = adoTable.NewRow();
                for (int liElement = 0; liElement < sapTable.ElementCount; liElement++)
                {
                    RfcElementMetadata metadata = sapTable.GetElementMetadata(liElement);

                    switch (metadata.DataType)
                    {
                    case RfcDataType.DATE:
                        ldr[metadata.Name] = row.GetString(metadata.Name).Substring(0, 4) + row.GetString(metadata.Name).Substring(5, 2) + row.GetString(metadata.Name).Substring(8, 2);
                        break;

                    case RfcDataType.BCD:
                        ldr[metadata.Name] = row.GetDecimal(metadata.Name);
                        break;

                    case RfcDataType.CHAR:
                        ldr[metadata.Name] = row.GetString(metadata.Name);
                        break;

                    case RfcDataType.STRING:
                        ldr[metadata.Name] = row.GetString(metadata.Name);
                        break;

                    case RfcDataType.INT2:
                        ldr[metadata.Name] = row.GetInt(metadata.Name);
                        break;

                    case RfcDataType.INT4:
                        ldr[metadata.Name] = row.GetInt(metadata.Name);
                        break;

                    case RfcDataType.FLOAT:
                        ldr[metadata.Name] = row.GetDouble(metadata.Name);
                        break;

                    default:
                        ldr[metadata.Name] = row.GetString(metadata.Name);
                        break;
                    }
                }
                adoTable.Rows.Add(ldr);
            }
            return(adoTable);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Converts SAP table to .NET DataTable table
        /// </summary>
        /// <param name="sapTable">The SAP table to convert.</param>
        /// <returns></returns>
        public static DataTable RfcTableToDataTable(IRfcTable sapTable, string name)
        {
            DataTable adoTable = new DataTable(name);
            //... Create ADO.Net table.
            for (int liElement = 0; liElement < sapTable.ElementCount; liElement++)
            {
                RfcElementMetadata metadata = sapTable.GetElementMetadata(liElement);
                adoTable.Columns.Add(metadata.Name, GetDataType(metadata.DataType));
            }

            //Transfer rows from SAP Table ADO.Net table.
            foreach (IRfcStructure row in sapTable)
            {
                DataRow ldr = adoTable.NewRow();
                for (int liElement = 0; liElement < sapTable.ElementCount; liElement++)
                {
                    RfcElementMetadata metadata = sapTable.GetElementMetadata(liElement);

                    switch (metadata.DataType)
                    {
                        case RfcDataType.DATE:
                            ldr[metadata.Name] = row.GetString(metadata.Name).Substring(0, 4) + row.GetString(metadata.Name).Substring(5, 2) + row.GetString(metadata.Name).Substring(8, 2);
                            break;
                        case RfcDataType.BCD:
                            ldr[metadata.Name] = row.GetDecimal(metadata.Name);
                            break;
                        case RfcDataType.CHAR:
                            ldr[metadata.Name] = row.GetString(metadata.Name);
                            break;
                        case RfcDataType.STRING:
                            ldr[metadata.Name] = row.GetString(metadata.Name);
                            break;
                        case RfcDataType.INT2:
                            ldr[metadata.Name] = row.GetInt(metadata.Name);
                            break;
                        case RfcDataType.INT4:
                            ldr[metadata.Name] = row.GetInt(metadata.Name);
                            break;
                        case RfcDataType.FLOAT:
                            ldr[metadata.Name] = row.GetDouble(metadata.Name);
                            break;
                        default:
                            ldr[metadata.Name] = row.GetString(metadata.Name);
                            break;
                    }
                }
                adoTable.Rows.Add(ldr);
            }
            return adoTable;
        }
Ejemplo n.º 16
0
        public static DataTable ToDataTable(IRfcTable itab)
        {
            DataTable dataTable = new DataTable();

            // dataTable columns definition
            for (int i = 0; i < itab.ElementCount; i++)
            {
                RfcElementMetadata metadata = itab.GetElementMetadata(i);
                dataTable.Columns.Add(metadata.Name);
            }

            // line items
            for (int rowIdx = 0; rowIdx < itab.RowCount; rowIdx++)
            {
                DataRow dRow = dataTable.NewRow();

                // every line is of type structure
                for (int idx = 0; idx < itab.ElementCount; idx++)
                {
                    dRow[idx] = itab[rowIdx].GetString(idx);
                }

                dataTable.Rows.Add(dRow);
            }

            return(dataTable);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// SAP内表转换成DataTable
        /// </summary>
        /// <param name="itab"></param>
        /// <returns></returns>
        private DataTable ToDataTable(IRfcTable itab)
        {
            // purpose: convert IRfcTable to DataTable

            DataTable dataTable = new DataTable();

            // dataTable column definition
            for (int i = 0; i < itab.ElementCount; i++)
            {
                RfcElementMetadata metadata = itab.GetElementMetadata(i);
                dataTable.Columns.Add(metadata.Name);
            }

            // line items
            for (int rowIdx = 0; rowIdx < itab.RowCount; rowIdx++)
            {
                DataRow dRow = dataTable.NewRow();

                // each line is a structure
                for (int idx = 0; idx < itab.ElementCount; idx++)
                {
                    dRow[idx] = itab[rowIdx].GetString(idx);//全部转换成string类型
                }

                dataTable.Rows.Add(dRow);
            }

            return(dataTable);
        }
Ejemplo n.º 18
0
        public bool EnviarDatosCobranza(DataTable dt)
        {
            RfcConfigParameters rfc = new RfcConfigParameters();

            rfc.Add(RfcConfigParameters.Name, ConfigurationManager.AppSettings["Name"]);
            rfc.Add(RfcConfigParameters.AppServerHost, ConfigurationManager.AppSettings["AppServerHost"]);
            rfc.Add(RfcConfigParameters.Client, ConfigurationManager.AppSettings["Client"]);
            rfc.Add(RfcConfigParameters.User, ConfigurationManager.AppSettings["User"]);
            rfc.Add(RfcConfigParameters.Password, ConfigurationManager.AppSettings["Password"]);
            rfc.Add(RfcConfigParameters.SystemNumber, "00");
            rfc.Add(RfcConfigParameters.Language, "ES");
            rfc.Add(RfcConfigParameters.PoolSize, "5");
            rfc.Add(RfcConfigParameters.MaxPoolSize, "100");
            rfc.Add(RfcConfigParameters.IdleTimeout, "900");
            RfcDestination rfcDest = null;

            try
            {
                rfcDest = RfcDestinationManager.GetDestination(rfc);
            }
            catch (Exception e)
            {
                e.ToString();
            }

            IRfcFunction         function = rfcDest.Repository.CreateFunction("ZSD_REXSAP_010"); // A la espera del nombre de la funcio
            IRfcTable            doc      = function.GetTable("TI_DOCREXSAP");                   //A la espera del nombre de la tabla
            RfcStructureMetadata metadata = doc.Metadata.LineType;

            List <string> nombresColumna = new List <string>();


            for (int i = 0; i < metadata.FieldCount; i++)
            {
                nombresColumna.Add(doc.GetElementMetadata(i).Name);
            }
            foreach (DataRow row in dt.Rows)
            {
                doc.Append();

                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    if (ExisteNombreColumna(nombresColumna, dt.Columns[i].ColumnName))
                    {
                        doc.SetValue(dt.Columns[i].ColumnName, row[dt.Columns[i].ColumnName]);
                    }
                }
            }


            try {
                function.Invoke(rfcDest);
                return(true);
            } catch (Exception e) {
                return(false);
            }
        }
Ejemplo n.º 19
0
        public DataTable ConvertToDoNetTable(IRfcTable RFCTable)
        {
            DataTable dt = new DataTable();

            for (int i = 0; i < RFCTable.ElementCount; i++)
            {
                RfcElementMetadata metadata = RFCTable.GetElementMetadata(i);
                dt.Columns.Add(metadata.Name);
            }
            foreach (IRfcStructure row in RFCTable)
            {
                DataRow dr = dt.NewRow();
                for (int i = 0; i < RFCTable.ElementCount; i++)
                {
                    RfcElementMetadata metadata = RFCTable.GetElementMetadata(i);
                    dr[i] = row.GetString(metadata.Name);
                }
                dt.Rows.Add(dr);
            }
            return(dt);
        }
Ejemplo n.º 20
0
        //llena los gridview
        public DataTable ConvertToDonNet(IRfcTable RFCTable, GridView ID_GridView)
        {
            DataTable dtTable = new DataTable();

            for (int item = 0; item < RFCTable.ElementCount; item++)
            {
                RfcElementMetadata metadata = RFCTable.GetElementMetadata(item);
                dtTable.Columns.Add(metadata.Name);
            }

            foreach (IRfcStructure row in RFCTable)
            {
                DataRow dr = dtTable.NewRow();
                for (int item = 0; item < RFCTable.ElementCount; item++)
                {
                    RfcElementMetadata metadata = RFCTable.GetElementMetadata(item);
                    if (metadata.DataType == RfcDataType.BCD && metadata.Name == "ABC")
                    {
                        dr[item] = row.GetInt(metadata.Name);
                    }
                    else
                    {
                        dr[item] = row.GetString(metadata.Name);
                    }
                }
                dtTable.Rows.Add(dr);
            }

            if (dtTable.Rows.Count == 0)
            {
                ClientScript.RegisterStartupScript(GetType(), "not_data", "not_data();", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "data", "data();", true);
                ID_GridView.DataSource = dtTable;
                ID_GridView.DataBind();
            }
            return(dtTable);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 转换IRfcTable为Datatable
        /// </summary>
        /// <param name="myrfcTable"></param>
        /// <returns></returns>
        private static DataTable GetDataTableFromRFCTable(IRfcTable myrfcTable)
        {
            DataTable loTable   = new DataTable();
            int       liElement = 0;

            for (liElement = 0; liElement <= myrfcTable.ElementCount - 1; liElement++)
            {
                RfcElementMetadata metadata = myrfcTable.GetElementMetadata(liElement);
                loTable.Columns.Add(metadata.Name);
            }
            foreach (IRfcStructure Row in myrfcTable)
            {
                DataRow ldr = loTable.NewRow();
                for (liElement = 0; liElement <= myrfcTable.ElementCount - 1; liElement++)
                {
                    RfcElementMetadata metadata = myrfcTable.GetElementMetadata(liElement);
                    ldr[metadata.Name] = Row.GetString(metadata.Name);
                }
                loTable.Rows.Add(ldr);
            }
            return(loTable);
        }
Ejemplo n.º 22
0
        public static List <Dictionary <string, object> > ToListOfDictionaries(this IRfcTable table)
        {
            List <Dictionary <string, object> > results = new List <Dictionary <string, object> >();

            foreach (IRfcStructure row in table)
            {
                Dictionary <string, object> sapTableRecord = new Dictionary <string, object>();
                for (int liElement = 0; liElement < row.ElementCount; liElement++)
                {
                    RfcElementMetadata metadata = table.GetElementMetadata(liElement);
                    switch (metadata.DataType)
                    {
                    case RfcDataType.DATE:
                        sapTableRecord[metadata.Name] = row.GetString(metadata.Name).Substring(0, 4) + row.GetString(metadata.Name).Substring(5, 2) + row.GetString(metadata.Name).Substring(8, 2);
                        break;

                    case RfcDataType.BCD:
                        sapTableRecord[metadata.Name] = row.GetDecimal(metadata.Name);
                        break;

                    case RfcDataType.CHAR:
                        sapTableRecord[metadata.Name] = row.GetString(metadata.Name);
                        break;

                    case RfcDataType.STRING:
                        sapTableRecord[metadata.Name] = row.GetString(metadata.Name);
                        break;

                    case RfcDataType.INT2:
                        sapTableRecord[metadata.Name] = row.GetInt(metadata.Name);
                        break;

                    case RfcDataType.INT4:
                        sapTableRecord[metadata.Name] = row.GetInt(metadata.Name);
                        break;

                    case RfcDataType.FLOAT:
                        sapTableRecord[metadata.Name] = row.GetDouble(metadata.Name);
                        break;

                    default:
                        sapTableRecord[metadata.Name] = row.GetString(metadata.Name);
                        break;
                    }
                }

                results.Add(sapTableRecord);
            }

            return(results);
        }
Ejemplo n.º 23
0
        public static DataTable DataTableSet(IRfcTable rfcTable)
        {
            DataTable netTable = new DataTable();

            //테이블 row의 컬럼생성
            for (int i = 0; i < rfcTable.ElementCount; i++)
            {
                netTable.Columns.Add(rfcTable.GetElementMetadata(i).Name);
            }

            foreach (IRfcStructure row in rfcTable)
            {
                DataRow dr = netTable.NewRow();

                for (int i = 0; i < rfcTable.ElementCount; i++)
                {
                    dr[rfcTable.GetElementMetadata(i).Name] = row.GetString(rfcTable.GetElementMetadata(i).Name);
                }

                netTable.Rows.Add(dr);
            }

            return(netTable);
        }
        public static DataTable ToAdoTable(IRfcTable rfcTable)
        {
            Console.WriteLine("ToAdoTable------");
            DataTable loTable = new DataTable();

            //
            for (int liElement = 0; liElement < rfcTable.ElementCount; liElement++)
            {
                RfcElementMetadata metadata = rfcTable.GetElementMetadata(liElement);
                loTable.Columns.Add(metadata.Name);
            }
            //
            foreach (IRfcStructure row in rfcTable)
            {
                DataRow ldr = loTable.NewRow();
                for (int liElement = 0; liElement < rfcTable.ElementCount; liElement++)
                {
                    RfcElementMetadata metadata = rfcTable.GetElementMetadata(liElement);
                    ldr[metadata.Name] = row.GetString(metadata.Name);
                }
                loTable.Rows.Add(ldr);
            }
            return(loTable);
        }
Ejemplo n.º 25
0
        // class สำหรับ convert sap table    เป็น datatable
        public DataTable GetDataTableFromRFCTable(IRfcTable lrfcTable)
        {
            //sapnco_util
            DataTable loTable = new DataTable();

            //... Create ADO.Net table.
            for (int liElement = 0; liElement < lrfcTable.ElementCount; liElement++)
            {
                RfcElementMetadata metadata = lrfcTable.GetElementMetadata(liElement);
                loTable.Columns.Add(metadata.Name);
            }
            //... Transfer rows from lrfcTable to ADO.Net table.
            foreach (IRfcStructure row in lrfcTable)
            {
                DataRow ldr = loTable.NewRow();
                for (int liElement = 0; liElement < lrfcTable.ElementCount; liElement++)
                {
                    RfcElementMetadata metadata = lrfcTable.GetElementMetadata(liElement);
                    ldr[metadata.Name] = row.GetString(metadata.Name);
                }
                loTable.Rows.Add(ldr);
            }
            return(loTable);
        }
Ejemplo n.º 26
0
        public static DataTable generateDataTable(DataTable dt, IRfcTable rfcTable)
        {
            foreach (IRfcStructure row in rfcTable)
            {
                DataRow newRow = dt.NewRow();
                for (int element = 0; element < rfcTable.ElementCount; element++)
                {
                    RfcElementMetadata metadata = rfcTable.GetElementMetadata(element);
                    var nrow = newRow[element];
                    var rrow = row.GetString(metadata.Name);
                    newRow[element] = row.GetString(metadata.Name);
                }
                dt.Rows.Add(newRow);
            }

            return(dt);
        }
Ejemplo n.º 27
0
        public List <T> IRcTabeltoList <T>(IRfcTable table) where T : new()
        {
            List <T> listt = new List <T>();

            System.Reflection.PropertyInfo[] propertiesT = typeof(T).GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);


            for (int i = 0; i < table.Count; i++)
            {
                T t = new T();
                table.CurrentIndex = i;
                for (int j = 0; j < table.ElementCount; j++)
                {
                    foreach (System.Reflection.PropertyInfo itemT in propertiesT)
                    {
                        if (itemT.Name.ToLower() == table.GetElementMetadata(j).Name.ToLower())
                        {
                            switch (itemT.PropertyType.Name.ToLower())
                            {
                            case "string":
                                itemT.SetValue(t, table.GetString(j), null);
                                break;

                            case "int":
                                itemT.SetValue(t, Convert.ToInt32(table.GetInt(j)), null);
                                break;

                            case "int32":
                                itemT.SetValue(t, Convert.ToInt32(table.GetInt(j)), null);
                                break;

                            case "datetime":
                                itemT.SetValue(t, Convert.ToDateTime(table.GetString(j)), null);

                                break;
                            }
                        }
                    }
                }

                listt.Add(t);
            }

            return(listt);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 将SAP内表转换成DataTable
        /// </summary>
        /// <param name="rfcTable">内表名称</param>
        /// <returns>返回一个DataTable</returns>
        public DataTable ConvertToTable(IRfcTable rfcTable)
        {
            DataTable dt = new DataTable();

            //建立表结构
            for (int col = 0; col < rfcTable.ElementCount; col++)
            {
                RfcElementMetadata rfcCol     = rfcTable.GetElementMetadata(col);
                string             columnName = rfcCol.Name;
                dt.Columns.Add(columnName);
            }

            for (int rx = 0; rx < rfcTable.RowCount; rx++)
            {
                object[] dr = new object[rfcTable.ElementCount];

                for (int cx = 0; cx < dt.Columns.Count; cx++)
                {
                    dr[cx] = rfcTable[rx][dt.Columns[cx].ColumnName].GetValue();
                }
                dt.Rows.Add(dr);
            }
            return(dt);
        }
Ejemplo n.º 29
0
 public override string GetName(int ordinal)
 {
     return(IRfcTable.GetElementMetadata(ordinal).Name);
 }
Ejemplo n.º 30
0
        //把RFCTABLE 转换成DataTable.
        public static DataTable RfcTableToDataTable(IRfcTable rfcTable)
        {
            DataTable dtRet = new DataTable();
            for (int liElement = 0; liElement < rfcTable.ElementCount; liElement++)
            {

                RfcElementMetadata rfcEMD = rfcTable.GetElementMetadata(liElement);
                //Console.WriteLine("Name:" + rfcEMD.Name);
                //Console.WriteLine("DatType:" + rfcEMD.DataType);
                dtRet.Columns.Add(rfcEMD.Name, RfcTypeConvertor.RfcTypeToSystemType(rfcEMD.DataType));
            }
            foreach (IRfcStructure row in rfcTable)
            {
                DataRow dr = dtRet.NewRow();
                for (int liElement = 0; liElement < rfcTable.ElementCount; liElement++)
                {
                    RfcElementMetadata rfcEMD = rfcTable.GetElementMetadata(liElement);
                    //Console.WriteLine("Name:" + rfcEMD.Name);
                    //Console.WriteLine("DatType:" + rfcEMD.DataType);
                    //Console.WriteLine("Object:" + row.GetValue(liElement));
                    Object o = Converts.RfcToDoNetValue(row.GetValue(liElement), rfcEMD.DataType);
                    if (String.IsNullOrWhiteSpace(o.ToString()))
                    {
                        o = "";
                    }
                    //Console.WriteLine("ConvertedValue:  " + o);
                    //Console.WriteLine("");
                    dr[rfcEMD.Name] = o;
                }
                dtRet.Rows.Add(dr);
            }
            return dtRet;
        }
 private static void WriteRowProperties(IRfcTable table, JsonWriter writer)
 {
     for (int columnNumber = 0; columnNumber < table.ElementCount; columnNumber++)
     {
         var name = table.GetElementMetadata(columnNumber).Name;
         var value = table.GetString(columnNumber);
         writer.WritePropertyName(name);
         writer.WriteValue(value);
     }
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Converts SAP table to .NET DataTable table
        /// </summary>
        /// <param name="sapTable">The SAP table to convert.</param>
        /// <param name="tableName">Table Name </param>
        /// <returns></returns>
        public static DataTable ToDataTable(this IRfcTable sapTable, string tableName = null)
        {
            DataTable adoTable = new DataTable(tableName);

            //... Create ADO.Net table.
            for (int liElement = 0; liElement < sapTable.ElementCount; liElement++)
            {
                RfcElementMetadata metadata = sapTable.GetElementMetadata(liElement);
                adoTable.Columns.Add(metadata.Name, GetDataType(metadata.DataType));
            }

            //Transfer rows from SAP Table ADO.Net table.
            foreach (IRfcStructure row in sapTable)
            {
                DataRow ldr = adoTable.NewRow();
                for (int liElement = 0; liElement < sapTable.ElementCount; liElement++)
                {
                    RfcElementMetadata metadata = sapTable.GetElementMetadata(liElement);

                    switch (metadata.DataType)
                    {
                    case RfcDataType.DATE:
                        //ldr[metadata.Name] = row.GetString(metadata.Name).Substring(0, 4) + row.GetString(metadata.Name).Substring(5, 2) + row.GetString(metadata.Name).Substring(8, 2);
                        if (row.GetString(metadata.Name) != "0000-00-00")
                        {
                            ldr[metadata.Name] = row.GetString(metadata.Name).Substring(0, 4) + "-" + row.GetString(metadata.Name).Substring(5, 2) + "-" + row.GetString(metadata.Name).Substring(8, 2);
                        }
                        else
                        {
                            DateTime dtSonuc = new DateTime(1901, 01, 01);
                            ldr[metadata.Name] = dtSonuc;
                        }
                        break;

                    case RfcDataType.BCD:
                        ldr[metadata.Name] = row.GetDecimal(metadata.Name);
                        break;

                    case RfcDataType.CHAR:
                        ldr[metadata.Name] = row.GetString(metadata.Name);
                        break;

                    case RfcDataType.STRING:
                        ldr[metadata.Name] = row.GetString(metadata.Name);
                        break;

                    case RfcDataType.INT2:
                        ldr[metadata.Name] = row.GetInt(metadata.Name);
                        break;

                    case RfcDataType.INT4:
                        ldr[metadata.Name] = row.GetInt(metadata.Name);
                        break;

                    case RfcDataType.FLOAT:
                        //ldr[metadata.Name] = row.GetDouble(metadata.Name);
                        ldr[metadata.Name] = metadata.Name.isNumeric() ? row.GetDouble(metadata.Name) : 0;
                        break;

                    default:
                        ldr[metadata.Name] = row.GetString(metadata.Name);
                        break;
                    }
                }
                adoTable.Rows.Add(ldr);
            }
            return(adoTable);
        }
Ejemplo n.º 33
0
        public void InvokeRFCFunctionZPSRFC04(WBSInfo wbsInfo)
        {
            IRfcFunction function = null;

            try
            {
                try
                {
                    function = _rfcDestination.Repository.CreateFunction("ZPSRFC04");


                    IRfcTable wbsTable = function.GetTable("LT_GSDATA");



                    for (int i = 0; i < wbsInfo.WbsFolders.Count(); i++)
                    {
                        for (int j = 0; j < wbsInfo.WbsFolders[i].TimeCosts.Count(); j++)
                        {
                            wbsTable.Insert();
                            wbsTable.CurrentRow.SetValue("PSPID", wbsInfo.ProjectUniqueID);                      //项目定义编码
                            wbsTable.CurrentRow.SetValue("ZPOSID", wbsInfo.WbsFolders[i].WBSUniqueNo);           //传入wbs的DS 阶段 ID
                            wbsTable.CurrentRow.SetValue("SYGID", wbsInfo.WbsFolders[i].TimeCosts[j].LoginName); //员工ID 00000002
                            wbsTable.CurrentRow.SetValue("MJAHR", wbsInfo.WbsFolders[i].TimeCosts[j].Yeart);     //年
                            wbsTable.CurrentRow.SetValue("SGSYF", wbsInfo.WbsFolders[i].TimeCosts[j].Montht);    //月
                            wbsTable.CurrentRow.SetValue("SJGSZ", wbsInfo.WbsFolders[i].TimeCosts[j].TotalTime);
                        }
                    }

                    function.SetValue("LT_GSDATA", wbsTable);


                    function.Invoke(_rfcDestination);
                }
                catch (Exception ex)
                {
                    //LogHelper.WriteLog("连接SAP远程服务器出错:" + ex.Message);
                    LogHelper.Error("连接SAP远程服务器出错:" + ex.Message, ex);
                }


                //获取调用SAP的ZPSRFC04返回值到DataTable
                IRfcTable myrfcTable = function.GetTable("LT_RETURN");//rfc server function 返回值table结构名称

                int liElement = 0;
                for (liElement = 0; liElement <= myrfcTable.ElementCount - 1; liElement++)
                {
                    RfcElementMetadata metadata = myrfcTable.GetElementMetadata(liElement);
                    dtr.Columns.Add(metadata.Name);      //循环创建列
                }
                foreach (IRfcStructure dr in myrfcTable) //循环table结构表
                {
                    DataRow row = dtr.NewRow();          //创建新行
                    for (liElement = 0; liElement <= myrfcTable.ElementCount - 1; liElement++)
                    {
                        RfcElementMetadata metadata = myrfcTable.GetElementMetadata(liElement);
                        row[metadata.Name] = dr.GetString(metadata.Name).Trim();
                    }
                    dtr.Rows.Add(row);
                }

                //输出调用返回日志
                for (int i = 0; i < dtr.Rows.Count; i++)
                {
                    LogHelper.WriteLog("SAP返回结果:消息类型:" + dtr.Rows[i]["TYPE"].ToString() + "\t消息文本" + dtr.Rows[i]["MESSAGE"].ToString());
                }
            }
            catch (Exception ex)
            {
                // LogHelper.WriteLog("调用SAP函数ZPSRFC04出错:" + ex.Message);
                LogHelper.Error("调用SAP函数ZPSRFC04出错:" + ex.Message, ex);
            }
        }
Ejemplo n.º 34
0
        /// <summary>
        /// 调用SAP提供的RFC函数ZPSRFC03传递项目信息和wbs信息给SAP
        /// </summary>
        /// <param name="project">项目信息</param>
        /// <param name="wbsInfo">wbs信息</param>
        public List <ReturnMessage> InvokeRFCFunctionZPSRFC03(Project project, WBSInfo wbsInfo)
        {
            IRfcFunction         function      = null;
            List <ReturnMessage> returnMessage = new List <ReturnMessage>();

            try
            {
                try
                {
                    function = _rfcDestination.Repository.CreateFunction("ZPSRFC03");
                    //  function.Invoke(_rfcDestination);
                    // IRfcStructure itb = function.GetStructure("ZSPS_003");
                    IRfcTable projectTable = function.GetTable("LT_XMDY");
                    projectTable.Insert();

                    //IRfcStructure struSAP = projectTable.Metadata.LineType.CreateStructure();
                    //struSAP.SetValue("POSID", project.ProjectUniqueID);//传入项目编码
                    //struSAP.SetValue("POST1", project.ProjectName);//传入项目名称
                    //struSAP.SetValue("PROFL", project.ProjectTypeID);//传入项目编码
                    //struSAP.SetValue("VERNR", project.ProjectManager);//传入项目经理
                    //struSAP.SetValue("PXMDH", project.ProjectCodeName);//传入项目代号
                    //struSAP.SetValue("PXMLX", project.ProjectType);//传入项目类型
                    //struSAP.SetValue("PWTBM", project.DelegateDepartment);//传入委托部门
                    //struSAP.SetValue("PCDBM", project.UnderTaskDepartment);//传入承担部门
                    //struSAP.SetValue("FZDDJ", project.ProjectComplexLevel);//传入项目复杂度等级
                    //struSAP.SetValue("PXYXJ", project.ProjectPriority);//传入项目优先级
                    //struSAP.SetValue("ESTAT", project.ProjectStatus);//传入项目状态
                    //projectTable.Append(struSAP);

                    //function.SetValue("LT_XMDY", projectTable);
                    //function.Invoke(_rfcDestination);

                    projectTable.CurrentRow.SetValue("POSID", project.ProjectUniqueID); //传入项目编码
                    //projectTable.CurrentRow.SetValue("POSID", "B1909007");//传入项目编码
                    projectTable.CurrentRow.SetValue("POST1", project.ProjectName);     //传入项目名称
                    projectTable.CurrentRow.SetValue("PROFL", project.ProjectTypeID);   //传入项目编码

                    //projectTable.CurrentRow.SetValue("VERNR", project.ProjectManager);//传入项目经理(20190926讨论后,决定不需要传项目经理)
                    //projectTable.CurrentRow.SetValue("VERNR", 00000002);//传入项目经理
                    projectTable.CurrentRow.SetValue("PXMDH", project.ProjectCodeName);     //传入项目代号
                    projectTable.CurrentRow.SetValue("PXMLX", project.ProjectType);         //传入项目类型
                    projectTable.CurrentRow.SetValue("PWTBM", project.DelegateDepartment);  //传入委托部门
                    //projectTable.CurrentRow.SetValue("PWTBM", "10000010");//传入委托部门
                    projectTable.CurrentRow.SetValue("PCDBM", project.UnderTaskDepartment); //传入承担部门
                    //projectTable.CurrentRow.SetValue("PCDBM", "10000010");//传入承担部门
                    projectTable.CurrentRow.SetValue("FZDDJ", project.ProjectComplexLevel); //传入项目复杂度等级
                    projectTable.CurrentRow.SetValue("PXYXJ", project.ProjectPriority);     //传入项目优先级
                    projectTable.CurrentRow.SetValue("ESTAT", project.ProjectStatus);       //传入项目状态

                    // function = _rfcDestination.Repository.CreateFunction("ZPSRFC03");
                    function.SetValue("LT_XMDY", projectTable);
                    // function.Invoke(_rfcDestination);

                    IRfcTable wbsTable = function.GetTable("LT_WBSD");

                    //for (int i = 0; i < wbsInfo.WbsFolders.Count(); i++)
                    //{

                    //    IRfcStructure struSAP2 = wbsTable.Metadata.LineType.CreateStructure();
                    //    struSAP2.SetValue("ZPOSID", wbsInfo.WbsFolders[i].WBSUniqueNo);//传入wbs的DS 阶段 ID
                    //    struSAP2.SetValue("POSIDNAME", wbsInfo.WbsFolders[i].WBSName);//传入wbs的DS 阶段名称
                    //    struSAP2.SetValue("PSPID", wbsInfo.ProjectUniqueID);
                    //    wbsTable.Append(struSAP2);
                    //}

                    for (int i = 0; i < wbsInfo.WbsFolders.Count(); i++)
                    {
                        wbsTable.Insert();
                        wbsTable.CurrentRow.SetValue("ZPOSID", wbsInfo.WbsFolders[i].WBSUniqueNo); //传入wbs的DS 阶段 ID
                        wbsTable.CurrentRow.SetValue("POSIDNAME", wbsInfo.WbsFolders[i].WBSName);  //传入wbs的DS 阶段名称
                        wbsTable.CurrentRow.SetValue("PSPID", wbsInfo.ProjectUniqueID);
                        //wbsTable.CurrentRow.SetValue("PSPID", "B1909007");
                    }


                    //  function = _rfcDestination.Repository.CreateFunction("ZPSRFC03");
                    function.SetValue("LT_WBSD", wbsTable);

                    // function.SetParameterActive(0, true);
                    function.Invoke(_rfcDestination);
                }
                catch (Exception ex)
                {
                    //LogHelper.WriteLog("连接SAP远程服务器出错:" + ex.Message);
                    LogHelper.Error("连接SAP远程服务器出错:" + ex.Message, ex);
                }
                // function.GetElementMetadata(2).ValueMetadataAsTableMetadata.LineType.Name.ElementAt.SetValue("POSID", project.ProjectUniqueID);//传入项目编码

                //function.SetValue("POSID", project.ProjectUniqueID);//传入项目编码
                //function.SetValue("POST1", project.ProjectName);//传入项目名称
                //function.SetValue("PROFL", project.ProjectTypeID);//传入项目编码
                //function.SetValue("VERNR", project.ProjectManager);//传入项目经理
                //function.SetValue("PXMDH", project.ProjectCodeName);//传入项目代号
                //function.SetValue("PXMLX", project.ProjectType);//传入项目类型
                //function.SetValue("PWTBM", project.DelegateDepartment);//传入委托部门
                //function.SetValue("PCDBM", project.UnderTaskDepartment);//传入承担部门
                //function.SetValue("FZDDJ", project.ProjectComplexLevel);//传入项目复杂度等级
                //function.SetValue("PXYXJ", project.ProjectPriority);//传入项目优先级
                //function.SetValue("ESTAT", project.ProjectStatus);//传入项目状态


                // var Nos = from c in wbsInfo.WbsFolders select c.WBSUniqueNo;
                // var Names = from n in wbsInfo.WbsFolders select n.WBSName;
                // string wbsUniqueNos = string.Join("、",Nos.ToArray());
                //string wbsNames = string.Join("、",Names.ToArray());

                //foreach (var item in wbsInfo.WbsFolders)
                //{
                //    function.SetValue("ZPOSID", item.WBSUniqueNo);//传入wbs的DS 阶段 ID
                //    function.SetValue("POSIDNAME", item.WBSName);//传入wbs的DS 阶段名称
                //}
                //function.SetValue("PSPID", wbsInfo.ProjectUniqueID);//传入项目编码

                //function.SetParameterActive(0,true);
                //function.Invoke(_rfcDestination);

                //获取调用SAP的ZPSRFC03返回值到DataTable
                IRfcTable myrfcTable = function.GetTable("LT_RETURN");//rfc server function 返回值table结构名称

                int liElement = 0;
                for (liElement = 0; liElement <= myrfcTable.ElementCount - 1; liElement++)
                {
                    RfcElementMetadata metadata = myrfcTable.GetElementMetadata(liElement);
                    dtr.Columns.Add(metadata.Name);      //循环创建列
                }
                foreach (IRfcStructure dr in myrfcTable) //循环table结构表
                {
                    DataRow row = dtr.NewRow();          //创建新行
                    for (liElement = 0; liElement <= myrfcTable.ElementCount - 1; liElement++)
                    {
                        RfcElementMetadata metadata = myrfcTable.GetElementMetadata(liElement);
                        row[metadata.Name] = dr.GetString(metadata.Name).Trim();
                    }
                    dtr.Rows.Add(row);
                }

                //输出调用返回日志
                for (int i = 0; i < dtr.Rows.Count; i++)
                {
                    returnMessage.Add(new ReturnMessage()
                    {
                        Type    = dtr.Rows[i]["TYPE"].ToString(),
                        Message = dtr.Rows[i]["MESSAGE"].ToString(),
                    });
                    LogHelper.WriteLog("SAP返回结果:消息类型:" + dtr.Rows[i]["TYPE"].ToString() + "\t消息文本" + dtr.Rows[i]["MESSAGE"].ToString());
                }
            }
            catch (Exception ex)
            {
                // LogHelper.WriteLog("调用SAP函数ZPSRFC03出错:" + ex.Message);
                LogHelper.Error("调用SAP函数ZPSRFC03出错:" + ex.Message, ex);
            }
            return(returnMessage);
        }