Beispiel #1
0
        /// <summary>
        /// 读取RFCFunction的所有元数据,并以DataTable的形式输出
        /// </summary>
        /// <param name="sysName"></param>
        /// <param name="funame"></param>
        /// <returns></returns>
        public static FunctionMetaAsDataTable GetRfcFuncMetaAsDataTable(string sysName, string funame)
        {
            FunctionMetaAsDataTable metaTable = null;

            try
            {
                RfcFunctionMetadata MetaData = GetRfcFunctionMetadata(sysName, funame);
                metaTable = new FunctionMetaAsDataTable();
                DataTable dtImport   = FunctionMetaAsDataTable.ParameterDefinitionView();
                DataTable dtExport   = dtImport.Copy();
                DataTable dtChanging = dtImport.Copy();
                DataTable dtTables   = dtImport.Copy();
                //根据参数的方向,分为四种(CHANGING,EXPORT,IMPORT,TABLES);
                for (int i = 0; i < MetaData.ParameterCount; i++)
                {
                    RfcParameterMetadata pMetadata = MetaData[i];
                    switch (pMetadata.Direction)
                    {
                    //创建四个方向的参数列表
                    case RfcDirection.CHANGING:
                        AddMetadataToTable(ref pMetadata, ref dtChanging);
                        break;

                    case RfcDirection.EXPORT:
                        AddMetadataToTable(ref pMetadata, ref dtExport);
                        break;

                    case RfcDirection.IMPORT:
                        AddMetadataToTable(ref pMetadata, ref dtImport);
                        break;

                    case RfcDirection.TABLES:
                        AddMetadataToTable(ref pMetadata, ref dtTables);
                        break;
                    }
                    if (pMetadata.DataType == RfcDataType.STRUCTURE)
                    {
                        RfcStructureMetadata strucmeta = pMetadata.ValueMetadataAsStructureMetadata;
                        RfcContainerMetadata <RfcFieldMetadata> meta = pMetadata.ValueMetadataAsStructureMetadata;
                        if (!metaTable.StructureDetail.Keys.Contains(meta.Name))
                        {
                            //在这里创建结构体的定义表格
                            DataTable dtStructure = FunctionMetaAsDataTable.StructDefinitionView();
                            for (int f = 0; f < strucmeta.FieldCount; f++)
                            {
                                DataRow          dr     = dtStructure.NewRow();
                                RfcFieldMetadata fieldm = strucmeta[f];
                                dr["Name"]          = fieldm.Name;
                                dr["DataType"]      = fieldm.DataType.ToString();
                                dr["Decimals"]      = fieldm.Decimals;
                                dr["Length"]        = fieldm.NucLength;
                                dr["Documentation"] = fieldm.Documentation;
                                dtStructure.Rows.Add(dr);
                            }
                            metaTable.StructureDetail.Add(meta.Name, dtStructure);
                        }
                        if (!metaTable.InputTable.Keys.Contains(pMetadata.Name))
                        {
                            //用于输入数据的DataTable;
                            DataTable dtInput = new DataTable();
                            for (int f = 0; f < strucmeta.FieldCount; f++)
                            {
                                RfcFieldMetadata fieldm  = strucmeta[f];
                                DataColumn       dc      = null;
                                String           colName = fieldm.Name;
                                dc           = new DataColumn(colName, Type.GetType("System.String"));
                                dc.MaxLength = fieldm.NucLength;
                                dc.Caption   = fieldm.Documentation;
                                dtInput.Columns.Add(dc);
                            }
                            metaTable.InputTable.Add(pMetadata.Name, dtInput);
                        }
                    }
                    else if (pMetadata.DataType == RfcDataType.TABLE)
                    {
                        //在这里创建表的定义明细表格
                        RfcTableMetadata tablem = pMetadata.ValueMetadataAsTableMetadata;
                        if (!metaTable.StructureDetail.Keys.Contains(tablem.LineType.Name))
                        {
                            DataTable dtTable = FunctionMetaAsDataTable.StructDefinitionView();
                            for (int f = 0; f < tablem.LineType.FieldCount; f++)
                            {
                                DataRow          dr     = dtTable.NewRow();
                                RfcFieldMetadata fieldm = tablem.LineType[f];
                                dr["Name"]          = fieldm.Name;
                                dr["DataType"]      = fieldm.DataType;
                                dr["Decimals"]      = fieldm.Decimals;
                                dr["Length"]        = fieldm.NucLength;
                                dr["Documentation"] = fieldm.Documentation;
                                dtTable.Rows.Add(dr);
                            }
                            metaTable.StructureDetail.Add(tablem.LineType.Name, dtTable);
                        }
                        if (!metaTable.InputTable.Keys.Contains(pMetadata.Name))
                        {
                            //用于输入数据的DataTable;
                            DataTable dtInput = new DataTable();
                            for (int f = 0; f < tablem.LineType.FieldCount; f++)
                            {
                                RfcFieldMetadata fieldm  = tablem.LineType[f];
                                DataColumn       dc      = null;
                                String           colName = fieldm.Name;
                                dc           = new DataColumn(colName, Type.GetType("System.String"));
                                dc.MaxLength = fieldm.NucLength;
                                dc.Caption   = fieldm.Documentation;
                                dtInput.Columns.Add(dc);
                            }
                            metaTable.InputTable.Add(pMetadata.Name, dtInput);
                        }
                    }
                }
                metaTable.Import   = dtImport;
                metaTable.Export   = dtExport;
                metaTable.Changing = dtChanging;
                metaTable.Tables   = dtTables;
            }
            catch (Exception ee)
            {
                metaTable = null;
                throw new SAPException(ee.Message);
            }
            return(metaTable);
        }
Beispiel #2
0
        public static FunctionMetaAsDataTable GetFuncMetaAsDataTable(string sysName, String funame)
        {
            FunctionMetaAsDataTable metaTable = null;

            List <CParams> parameters = getFunctionDef(sysName, funame);

            metaTable = new FunctionMetaAsDataTable();


            if (Is_rfc == true)
            {
                metaTable        = GetRfcFuncMetaAsDataTable(sysName, funame);
                metaTable.Is_RFC = Is_rfc;
                return(metaTable);
            }
            metaTable.Is_RFC = Is_rfc;
            DataTable dtImport   = FunctionMetaAsDataTable.ParameterDefinitionView();
            DataTable dtExport   = dtImport.Copy();
            DataTable dtChanging = dtImport.Copy();
            DataTable dtTables   = dtImport.Copy();


            for (int i = 0; i < parameters.Count; i++)
            {
                var item = parameters[i];
                switch (item.paramclass)
                {
                case "I":
                    AddMetadataToTable2(ref item, ref dtImport);
                    break;

                case "E":
                    AddMetadataToTable2(ref item, ref dtExport);
                    break;

                case "T":
                    AddMetadataToTable2(ref item, ref dtTables);
                    break;

                case "C":
                    AddMetadataToTable2(ref item, ref dtChanging);
                    break;

                case "X":
                    //AddMetadataToTable2(ref item, ref );
                    break;

                default:
                    break;
                }



                if (item.paramclass == "T")
                {
                    if (!metaTable.StructureDetail.Keys.Contains(item.tabname))
                    {
                        //在这里创建结构体的定义表格
                        DataTable dtStructure = FunctionMetaAsDataTable.StructDefinitionView();
                        var       tableInfo   = new SAPTableInfo(sysName, item.tabname);

                        var fields = tableInfo.Fields;

                        foreach (var field in fields)
                        {
                            DataRow dr = dtStructure.NewRow();
                            dr["Name"]          = field.FIELDNAME;
                            dr["DataType"]      = field.DOMNAME;
                            dr["Decimals"]      = field.DECIMALS;
                            dr["Length"]        = field.OUTPUTLEN;
                            dr["Documentation"] = field.SCRTEXT_L;

                            dtStructure.Rows.Add(dr);
                        }

                        metaTable.StructureDetail.Add(item.tabname, dtStructure);
                    }
                }
            }

            metaTable.Import   = dtImport;
            metaTable.Export   = dtExport;
            metaTable.Changing = dtChanging;
            metaTable.Tables   = dtTables;
            return(metaTable);
        }
        /// <summary>
        /// 读取RFCFunction的所有元数据,并以DataTable的形式输出
        /// </summary>
        /// <param name="sysName"></param>
        /// <param name="funame"></param>
        /// <returns></returns>
        public static FunctionMetaAsDataTable GetRfcFuncMetaAsDataTable(string sysName, string funame)
        {
            FunctionMetaAsDataTable metaTable = null;
            try
            {
                RfcFunctionMetadata MetaData = GetRfcFunctionMetadata(sysName, funame);
                metaTable = new FunctionMetaAsDataTable();
                DataTable dtImport = FunctionMetaAsDataTable.ParameterDefinitionView();
                DataTable dtExport = dtImport.Copy();
                DataTable dtChanging = dtImport.Copy();
                DataTable dtTables = dtImport.Copy();
                //根据参数的方向,分为四种(CHANGING,EXPORT,IMPORT,TABLES);
                for (int i = 0; i < MetaData.ParameterCount; i++)
                {
                    RfcParameterMetadata pMetadata = MetaData[i];
                    switch (pMetadata.Direction)
                    {
                        //创建四个方向的参数列表
                        case RfcDirection.CHANGING:
                            AddMetadataToTable(ref pMetadata, ref dtChanging);
                            break;
                        case RfcDirection.EXPORT:
                            AddMetadataToTable(ref pMetadata, ref dtExport);
                            break;
                        case RfcDirection.IMPORT:
                            AddMetadataToTable(ref pMetadata, ref dtImport);
                            break;
                        case RfcDirection.TABLES:
                            AddMetadataToTable(ref pMetadata, ref dtTables);
                            break;
                    }
                    if (pMetadata.DataType == RfcDataType.STRUCTURE)
                    {
                        RfcStructureMetadata strucmeta = pMetadata.ValueMetadataAsStructureMetadata;
                        RfcContainerMetadata<RfcFieldMetadata> meta = pMetadata.ValueMetadataAsStructureMetadata;
                        if (!metaTable.StructureDetail.Keys.Contains(meta.Name))
                        {
                            //在这里创建结构体的定义表格
                            DataTable dtStructure = FunctionMetaAsDataTable.StructDefinitionView();
                            for (int f = 0; f < strucmeta.FieldCount; f++)
                            {
                                DataRow dr = dtStructure.NewRow();
                                RfcFieldMetadata fieldm = strucmeta[f];
                                dr["Name"] = fieldm.Name;
                                dr["DataType"] = fieldm.DataType.ToString();
                                dr["Decimals"] = fieldm.Decimals;
                                dr["Length"] = fieldm.NucLength;
                                dr["Documentation"] = fieldm.Documentation;
                                dtStructure.Rows.Add(dr);
                            }
                            metaTable.StructureDetail.Add(meta.Name, dtStructure);
                        }
                        if (!metaTable.InputTable.Keys.Contains(pMetadata.Name))
                        {
                            //用于输入数据的DataTable;
                            DataTable dtInput = new DataTable();
                            for (int f = 0; f < strucmeta.FieldCount; f++)
                            {
                                RfcFieldMetadata fieldm = strucmeta[f];
                                DataColumn dc = null;
                                String colName = fieldm.Name;
                                dc = new DataColumn(colName, Type.GetType("System.String"));
                                dc.MaxLength = fieldm.NucLength;
                                dc.Caption = fieldm.Documentation;
                                dtInput.Columns.Add(dc);
                            }
                            metaTable.InputTable.Add(pMetadata.Name, dtInput);
                        }

                    }
                    else if (pMetadata.DataType == RfcDataType.TABLE)
                    {
                        //在这里创建表的定义明细表格
                        RfcTableMetadata tablem = pMetadata.ValueMetadataAsTableMetadata;
                        if (!metaTable.StructureDetail.Keys.Contains(tablem.LineType.Name))
                        {
                            DataTable dtTable = FunctionMetaAsDataTable.StructDefinitionView();
                            for (int f = 0; f < tablem.LineType.FieldCount; f++)
                            {
                                DataRow dr = dtTable.NewRow();
                                RfcFieldMetadata fieldm = tablem.LineType[f];
                                dr["Name"] = fieldm.Name;
                                dr["DataType"] = fieldm.DataType;
                                dr["Decimals"] = fieldm.Decimals;
                                dr["Length"] = fieldm.NucLength;
                                dr["Documentation"] = fieldm.Documentation;
                                dtTable.Rows.Add(dr);
                            }
                            metaTable.StructureDetail.Add(tablem.LineType.Name, dtTable);
                        }
                        if (!metaTable.InputTable.Keys.Contains(pMetadata.Name))
                        {
                            //用于输入数据的DataTable;
                            DataTable dtInput = new DataTable();
                            for (int f = 0; f < tablem.LineType.FieldCount; f++)
                            {
                                RfcFieldMetadata fieldm = tablem.LineType[f];
                                DataColumn dc = null;
                                String colName = fieldm.Name;
                                dc = new DataColumn(colName, Type.GetType("System.String"));
                                dc.MaxLength = fieldm.NucLength;
                                dc.Caption = fieldm.Documentation;
                                dtInput.Columns.Add(dc);
                            }
                            metaTable.InputTable.Add(pMetadata.Name, dtInput);
                        }

                    }
                }
                metaTable.Import = dtImport;
                metaTable.Export = dtExport;
                metaTable.Changing = dtChanging;
                metaTable.Tables = dtTables;
            }
            catch (Exception ee)
            {
                metaTable = null;
                throw new SAPException(ee.Message);
            }
            return metaTable;
        }
        public static FunctionMetaAsDataTable GetFuncMetaAsDataTable(string sysName, String funame)
        {
            FunctionMetaAsDataTable metaTable = null;

            List<CParams> parameters = getFunctionDef(sysName, funame);
            metaTable = new FunctionMetaAsDataTable();

            if (Is_rfc == true)
            {
                metaTable = GetRfcFuncMetaAsDataTable(sysName, funame);
                metaTable.Is_RFC = Is_rfc;
                return metaTable;
            }
            metaTable.Is_RFC = Is_rfc;
            DataTable dtImport = FunctionMetaAsDataTable.ParameterDefinitionView();
            DataTable dtExport = dtImport.Copy();
            DataTable dtChanging = dtImport.Copy();
            DataTable dtTables = dtImport.Copy();

            for (int i = 0; i < parameters.Count; i++)
            {
                var item = parameters[i];
                switch (item.paramclass)
                {
                    case "I":
                        AddMetadataToTable2(ref item, ref dtImport);
                        break;
                    case "E":
                        AddMetadataToTable2(ref item, ref dtExport);
                        break;
                    case "T":
                        AddMetadataToTable2(ref item, ref dtTables);
                        break;
                    case "C":
                        AddMetadataToTable2(ref item, ref dtChanging);
                        break;
                    case "X":
                        //AddMetadataToTable2(ref item, ref );
                        break;
                    default:
                        break;
                }

                if (item.paramclass == "T")
                {
                    if (!metaTable.StructureDetail.Keys.Contains(item.tabname))
                    {
                        //在这里创建结构体的定义表格
                        DataTable dtStructure = FunctionMetaAsDataTable.StructDefinitionView();
                        var tableInfo = new SAPTableInfo(sysName, item.tabname);

                        var fields = tableInfo.Fields;

                        foreach (var field in fields)
                        {
                            DataRow dr = dtStructure.NewRow();
                            dr["Name"] = field.FIELDNAME;
                            dr["DataType"] = field.DOMNAME;
                            dr["Decimals"] = field.DECIMALS;
                            dr["Length"] = field.OUTPUTLEN;
                            dr["Documentation"] = field.SCRTEXT_L;

                            dtStructure.Rows.Add(dr);
                        }

                        metaTable.StructureDetail.Add(item.tabname, dtStructure);
                    }
                }
            }

            metaTable.Import = dtImport;
            metaTable.Export = dtExport;
            metaTable.Changing = dtChanging;
            metaTable.Tables = dtTables;
            return metaTable;
        }
 /// <summary>
 /// 连接SAP系统,读取RFC的元数据,以DataTable的形式存储。
 /// 同时,如果参数是结构体,也存储结构体的具体信息。
 /// </summary>
 private void GetFunMetaListAsDataTable()
 {
     this._funcMeta  = SAPFunctionMeta.GetFuncMetaAsDataTable(_sysTemName, _functionName);
     _tableValueList = _funcMeta.InputTable;
 }
 /// <summary>
 /// 连接SAP系统,读取RFC的元数据,以DataTable的形式存储。
 /// 同时,如果参数是结构体,也存储结构体的具体信息。
 /// </summary>
 private void GetFunMetaListAsDataTable()
 {
     this._funcMeta = SAPFunctionMeta.GetFuncMetaAsDataTable(_sysTemName, _functionName);
     _tableValueList = _funcMeta.InputTable;
 }