public static void GetFieldList(String system, string prog, string dynum)
        {
            try
            {
                RfcDestination destination = SAPDestination.GetDesByName(system);
                IRfcFunction   function    = destination.Repository.CreateFunction("ZVI_RFC_READ_SCREEN");
                function.SetValue("I_PROG", prog);
                function.SetValue("I_DYNNR", dynum);
                function.Invoke(destination);

                IRfcTable     fields = function.GetTable("ET_FELD");
                IRfcStructure rs37a  = function.GetStructure("E_HEADER");

                Fields    = CScreenField.getScreenFieldAsDt(fields);
                UsedLine  = rs37a.GetInt("BZMX");
                TotalLine = rs37a.GetInt("NOLI");
                TotalCol  = rs37a.GetInt("NOCO");
                UsedCol   = rs37a.GetInt("BZBR");

                ScreenType = rs37a.GetString("TYPE");
                Title      = function.GetString("E_TITLE");
            }
            catch (RfcAbapException rfce)
            {
                throw new SAPException(rfce.Key + rfce.Message);
            }
            catch (Exception e)
            {
                throw new SAPException(e.Message);
            }
        }
Exemple #2
0
        /// <summary>
        ///根据函数名,返回函数的元数据,各个参数的名称,类型等。
        /// </summary>
        /// <param name="sysName"></param>
        /// <param name="funame"></param>
        /// <returns></returns>
        public static RfcFunctionMetadata GetRfcFunctionMetadata(string sysName, string funame)
        {
            funame = funame.ToUpper().Trim();
            if (string.IsNullOrEmpty(funame))
            {
                throw new SAPException("请输入函数!!");
            }
            if (!SAPFunction.CheckFunction(sysName, funame))
            {
                throw new SAPException("函数不存在!!");
            }
            RfcFunctionMetadata MetaData = null;

            try
            {
                RfcDestination destination = SAPDestination.GetDesByName(sysName);
                //destination.Repository.ClearAllMetadata();
                MetaData = destination.Repository.GetFunctionMetadata(funame);
            }
            catch (RfcAbapException rfce)
            {
                throw new SAPException(rfce.Key + rfce.Message);
            }
            catch (RfcAbapRuntimeException rfcrunteime)
            {
                throw new SAPException(rfcrunteime.Key + rfcrunteime.Message);
            }
            return(MetaData);
        }
 /// <summary>
 /// check if the function exist in sap
 /// </summary>
 /// <param name="sysName"></param>
 /// <param name="functionName"></param>
 /// <returns></returns>
 public static bool CheckFunction(string sysName, string functionName)
 {
     try
     {
         RfcDestination destination         = SAPDestination.GetDesByName(sysName);
         string         _funame             = functionName;
         IRfcFunction   RFC_FUNCTION_SEARCH = destination.Repository.CreateFunction("RFC_FUNCTION_SEARCH");
         RFC_FUNCTION_SEARCH.SetValue("FUNCNAME", _funame);
         RFC_FUNCTION_SEARCH.Invoke(destination);
         IRfcTable FUNCTIONS = RFC_FUNCTION_SEARCH.GetTable("FUNCTIONS");
         if (FUNCTIONS.RowCount == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (RfcAbapException rfce)
     {
         //return false;
         throw new SAPException(rfce.Key + rfce.Message);
     }
 }
        //public static rfcdestination getdestination(string sysname)
        //{
        //    return sapdestination.getdesbyname(sysname);
        //}

        /// <summary>
        /// 搜索SAP中所有的RFC函数,如果函数名为空,读取所有的函数列表
        /// 并直接在储到数据库中
        /// </summary>
        /// <param name="sysName"></param>
        /// <param name="functionName"></param>
        /// <returns></returns>
        public static bool GetRFCfunctionListAndSaveToDb(string sysName, string functionName)
        {
            try
            {
                RfcDestination destination         = SAPDestination.GetDesByName(sysName);
                string         _funame             = string.Format("*{0}*", functionName);
                IRfcFunction   RFC_FUNCTION_SEARCH = destination.Repository.CreateFunction("RFC_FUNCTION_SEARCH");
                RFC_FUNCTION_SEARCH.SetValue("FUNCNAME", _funame);
                RFC_FUNCTION_SEARCH.Invoke(destination);
                IRfcTable FUNCTIONS = RFC_FUNCTION_SEARCH.GetTable("FUNCTIONS");
                if (FUNCTIONS.RowCount > 0)
                {
                    //保存结果到数据库。

                    var _table = new SapTable(sysName, "RFC_FUNCTIONS", "RFCFUNC");
                    _table.DbConnectionString = ConfigFileTool.SAPGlobalSettings.GetDefaultDbConnection();
                    _table.NewTable           = true;
                    _table.SaveDataTable(SAPFunction.RfcTableToDataTable(FUNCTIONS));
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (RfcAbapException rfce)
            {
                throw new SAPException(rfce.Key + rfce.Message);
            }
            catch (Exception e)
            {
                throw new SAPException(e.Message);
            }
        }
 /// <summary>
 /// 封装RFC函数DDIF_FIELDINFO_GET,传入表名,返回具体信息。
 /// </summary>
 /// <param name="sysName"></param>
 /// <param name="TableName"></param>
 /// <returns></returns>
 public static DataTable DDIF_FIELDINFO_GET(String sysName, String TableName)
 {
     try
     {
         RfcDestination destination         = SAPDestination.GetDesByName(sysName);
         IRfcFunction   RFC_FUNCTION_SEARCH = destination.Repository.CreateFunction("DDIF_FIELDINFO_GET");
         RFC_FUNCTION_SEARCH.SetValue("TABNAME", TableName);
         RFC_FUNCTION_SEARCH.Invoke(destination);
         IRfcTable DFIES_TAB = RFC_FUNCTION_SEARCH.GetTable("DFIES_TAB");
         DataTable dt        = RfcTableToDataTable(DFIES_TAB);
         return(dt);
     }
     catch (RfcAbapException abapException)
     {
         throw new SAPException(abapException.Key + abapException.Message);
     }
     catch (RfcAbapBaseException abapbaseException)
     {
         throw new SAPException(abapbaseException.PlainText + abapbaseException.Message);
     }
     catch (Exception ex)
     {
         throw new SAPException(ex.Message);
     }
 }
        public void GetFunctionDef(string pSystem, string pFunction)
        {
            destination = SAPDestination.GetDesByName(pSystem);

            IRfcFunction _functionInterface = destination.Repository.CreateFunction("RFC_GET_FUNCTION_INTERFACE");

            _functionInterface.SetValue("FUNCNAME", pFunction);
            try
            {
                _functionInterface.Invoke(destination);

                Params = Get_Params_list(_functionInterface);
            }
            catch (RfcAbapException abapEx)
            {
                throw new SAPException(abapEx.Key + abapEx.Message);
            }
            catch (RfcBaseException rfcbase)
            {
                throw new SAPException(rfcbase.Message);
            }
            catch (Exception ex)
            {
                throw new SAPException(ex.Message);
            }
        }
        //获取与服务器的连接信息
        public static string GetSever(string sysName)
        {
            string         output      = "";
            RfcDestination destination = SAPDestination.GetDesByName(sysName);

            output = JsonConvert.SerializeObject(destination);
            return(output);
        }
Exemple #8
0
 public Query(string sysName)
 {
     this._Name                = "";
     this._UserGroup           = "";
     this._Variant             = "";
     this._Fields              = new QueryFieldCollection();
     this._SelectionParameters = new QuerySelectionParameterCollection();
     this._des = SAPDestination.GetDesByName(sysName);
 }
Exemple #9
0
 public Transaction(string sysName)
 {
     this._BatchSteps         = new BatchStepCollection();
     this._TCode              = "";
     this._Type               = TransactionType.Multiple;
     this._Returns            = new BatchReturnCollection();
     this._CustomFunctionName = "";
     this._des     = SAPDestination.GetDesByName(sysName);
     this._sysName = sysName.ToUpper().Trim();
 }
Exemple #10
0
 public ABAPCode(string sysName)
 {
     this._sysName   = sysName;
     this._des       = SAPDestination.GetDesByName(sysName);
     this._code      = new List <String>();
     this._result    = new List <String>();
     this._LastError = "";
     if (_des == null)
     {
         throw new SAPException(Messages.Connectionisnotvalid);
     }
 }
Exemple #11
0
        public static List <CParams> getFunctionDef(string pSystem, string pFunction)
        {
            var _is_rfc = string.Empty;

            RfcDestination destination = SAPDestination.GetDesByName(pSystem);

            IRfcFunction _functionInterface = destination.Repository.CreateFunction("RFC_GET_FUNCTION_INTERFACE");

            _functionInterface.SetValue("FUNCNAME", pFunction);

            try
            {
                _functionInterface.Invoke(destination);

                int x = _functionInterface.Metadata.TryNameToIndex("REMOTE_CALL");
                if (x == -1)
                {
                    _is_rfc = CheckFunctionMode(pSystem, pFunction);
                }
                else
                {
                    //有些SAP的版本不支持这个传出参数。
                    _is_rfc = _functionInterface.GetString("REMOTE_CALL");
                }


                if (_is_rfc == "R")
                {
                    Is_rfc = true;
                }
                else
                {
                    Is_rfc = false;
                }
                return(get_Params_list(_functionInterface));
            }
            catch (RfcAbapException abapEx)
            {
                throw new SAPException(abapEx.Key + abapEx.Message);
            }
            catch (RfcBaseException rfcbase)
            {
                throw new SAPException(rfcbase.Message);
            }
            catch (Exception ex)
            {
                throw new SAPException(ex.Message);
            }
        }
Exemple #12
0
        /// <summary>
        /// 返回表或结构的定义细节。
        /// </summary>
        /// <param name="p_sysName">SAP系统</param>
        /// <param name="p_TableName">表或结构</param>
        /// <returns>结构定义</returns>
        private static DataTable _GetSAPTableDef(String p_sysName, String p_TableName)
        {
            //有时读取的参数是表类型,无法使用函数DDIF_FIELDINFO_GET直接读取到表的定义。
            //首先到表DD40L里查出表类型对应的结构类型。
            var criteria          = String.Format("TYPENAME = '{0}'", p_TableName);
            var readTableFunction = ConfigFileTool.SAPGlobalSettings.GetReadTableFunction();
            var dd40l             = new SAPINT.Utils.ReadTable(p_sysName);

            dd40l.TableName = "DD40L";
            dd40l.RowCount  = 1;
            dd40l.SetCustomFunctionName(readTableFunction);
            dd40l.AddCriteria(criteria);
            dd40l.Run();

            var dd40lt        = dd40l.Result;
            var structureName = string.Empty;

            if (dd40lt.Rows.Count == 1)
            {
                structureName = dd40lt.Rows[0]["ROWTYPE"].ToString();
            }
            if (!string.IsNullOrEmpty(structureName))
            {
                p_TableName = structureName;
            }

            try
            {
                RfcDestination destination         = SAPDestination.GetDesByName(p_sysName);
                IRfcFunction   RFC_FUNCTION_SEARCH = destination.Repository.CreateFunction("DDIF_FIELDINFO_GET");
                RFC_FUNCTION_SEARCH.SetValue("TABNAME", p_TableName);
                RFC_FUNCTION_SEARCH.Invoke(destination);
                IRfcTable DFIES_TAB = RFC_FUNCTION_SEARCH.GetTable("DFIES_TAB");
                DataTable dt        = _Convert_rfctable_to_dt(DFIES_TAB);
                return(dt);
            }
            catch (RfcAbapException abapException)
            {
                throw new SAPException(p_TableName + abapException.Key + abapException.Message);
            }
            catch (RfcAbapBaseException abapbaseException)
            {
                throw new SAPException(abapbaseException.PlainText + abapbaseException.Message);
            }
            catch (Exception ex)
            {
                throw new SAPException(ex.Message);
            }
        }
        internal void FillMessageText(string sysName)
        {
            ReadTable      table = new ReadTable(sysName);
            RfcDestination des   = SAPDestination.GetDesByName(sysName);

            table.AddField("TEXT");
            table.AddCriteria("SPRSL = '" + Converts.languageIsotoSap(des.Language) + "' ");
            table.AddCriteria("AND ARBGB = '" + this.MessageID + "' ");
            table.AddCriteria("AND MSGNR = '" + this.MessageNumber + "' ");
            table.TableName = "T100";
            table.RowCount  = 10;
            table.Run();
            DataTable result = table.Result;

            if (result.Rows.Count == 0)
            {
                //this.Message = "Message could not be found";// Messages.Messagecouldnotbefound;
                this.Message = Messages.Messagecouldnotbefound;
            }
            else
            {
                this.Message = result.Rows[0]["TEXT"].ToString().Trim();
                int length = 0;
                length = this.Message.IndexOf("&");
                if (length >= 0)
                {
                    this.Message = this.Message.Substring(0, length).Trim() + " " + this.MessageVariable1 + " " + this.Message.Substring(length + 1).Trim();
                }
                length = this.Message.IndexOf("&");
                if (length >= 0)
                {
                    this.Message = this.Message.Substring(0, length).Trim() + " " + this.MessageVariable2 + " " + this.Message.Substring(length + 1).Trim();
                }
                length = this.Message.IndexOf("&");
                if (length >= 0)
                {
                    this.Message = this.Message.Substring(0, length).Trim() + " " + this.MessageVariable3 + " " + this.Message.Substring(length + 1).Trim();
                }
                length = this.Message.IndexOf("&");
                if (length >= 0)
                {
                    this.Message = this.Message.Substring(0, length).Trim() + " " + this.MessageVariable4 + " " + this.Message.Substring(length + 1).Trim();
                }
                this.Message = this.Message.Trim();
            }
        }
Exemple #14
0
 //public ReadTable()
 //{
 //    this.fields = new ArrayList();
 //    this.options = new ArrayList();
 //    this._PrimaryKeys = new ReadTableFieldCollection();
 //    this._TableName = "";
 //    this._Fields = new ReadTableFieldCollection();
 //    this._WhereClause = "";
 //    this._Delimiter = "";
 //    this._FunctionName = "";
 //    this.BackgroundRequestID = "";
 //    this.BufferLocation = "";
 //    this._LastPrimaryKey = "";
 //}
 public ReadTable(string sysName)
 {
     this.fields              = new ArrayList();
     this.options             = new ArrayList();
     this._PrimaryKeys        = new ReadTableFieldCollection();
     this._TableName          = "";
     this._Fields             = new ReadTableFieldCollection();
     this._WhereClause        = "";
     this._Delimiter          = "";
     this._FunctionName       = "";
     this.BackgroundRequestID = "";
     this.BufferLocation      = "";
     this._LastPrimaryKey     = "";
     this._des = SAPDestination.GetDesByName(sysName);
     //if (Connection.Codepage.Equals("8000"))
     //{
     //    this._Delimiter = "|";
     //}
     //Connection.Log("ReadTable() Connection.Codepage = " + Connection.Codepage);
 }
 //测试使用CustomDestination,运行时修改用户与密码
 public static string login(string usname, string password, string client, string lang)
 {
     try
     {
         //RfcCustomDestination des = SAPDestination.GetDesByName("DM0_800").CreateCustomDestination();
         RfcCustomDestination des = SAPDestination.GetDesByName(ConfigFileTool.SAPGlobalSettings.GetDefaultSapCient()).CreateCustomDestination();
         // SAPBackupConfig config = new SAPBackupConfig();
         //RfcConfigParameters paras =  config.GetParameters("DM0_800");
         des.User     = usname;
         des.Password = password;
         des.Client   = client;
         des.Language = lang;
         IRfcFunction ping = des.Repository.CreateFunction("RFC_PING");
         ping.Invoke(des);
         return("Success");
     }
     catch (RfcAbapException rfce)
     {
         // return "Failed";
         throw new SAPException(rfce.Key + rfce.Message);
     }
 }
Exemple #16
0
        public List <String> GetSourceCode(String program)
        {
            if (String.IsNullOrEmpty(program))
            {
                throw new SAPException(String.Format("{0} 不能为空", program));
            }
            try
            {
                var          destination = SAPDestination.GetDesByName(_sysName);
                IRfcFunction function    = destination.Repository.CreateFunction("ZVI_RFC_READ_PROGRAM");
                function.SetValue("I_PROG", program);
                //function.SetValue("I_OBJECT", objectType);
                function.Invoke(destination);
                IRfcTable programlist = function.GetTable("ET_TRDIR");
                if (programlist.RowCount != 1)
                {
                    // throw new SAPException("无法找到程序");
                }

                IRfcTable     source = function.GetTable("ET_PROGRAM");
                List <String> code   = new List <string>();
                for (int i = 0; i < source.RowCount; i++)
                {
                    source.CurrentIndex = i;

                    code.Add(source.GetString("ZEILE"));
                }

                return(code);
            }
            catch (RfcAbapException abapException)
            {
                throw new SAPException(abapException.Key + abapException.Message);
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// search rfc function in sap system.
        /// </summary>
        /// <param name="sysName"></param>
        /// <param name="functionName"></param>
        /// <param name="functionGroup"></param>
        /// <returns></returns>
        public static DataTable SearchRfcFunctions(string sysName, string functionName, string functionGroup)
        {
            try
            {
                RfcDestination destination = SAPDestination.GetDesByName(sysName);
                //string _funame = string.Format("*{0}*", functionName);
                string       _funame             = functionName;
                IRfcFunction RFC_FUNCTION_SEARCH = destination.Repository.CreateFunction("RFC_FUNCTION_SEARCH");
                RFC_FUNCTION_SEARCH.SetValue("FUNCNAME", _funame);
                RFC_FUNCTION_SEARCH.SetValue("GROUPNAME", functionGroup);
                RFC_FUNCTION_SEARCH.Invoke(destination);
                IRfcTable FUNCTIONS = RFC_FUNCTION_SEARCH.GetTable("FUNCTIONS");

                return(RfcTableToDataTable(FUNCTIONS));
            }
            catch (RfcAbapException rfce)
            {
                throw new SAPException(rfce.Key + rfce.Message);
            }
            catch (Exception e)
            {
                throw new SAPException(e.Message);
            }
        }
Exemple #18
0
        /// <summary>
        /// 根据IDOC的IDOC类型,到SAP系统里查找它对应的类型定义
        /// </summary>
        private void GetIdocTypeDefinition()
        {
            if (idoc == null)
            {
                throw new SAPException("IDOC是空值。");
            }
            if (idoc != null)
            {
                if (String.IsNullOrWhiteSpace(this.idocType))
                {
                    throw new SAPException("空白的IDOC类型");
                }
                RfcDestination destination = SAPDestination.GetDesByName(sysName);

                IRfcFunction function = destination.Repository.CreateFunction("IDOCTYPE_READ_COMPLETE");
                function.SetValue("PI_IDOCTYP", this.idocType);
                function.SetValue("PI_CIMTYP", this.cimType);
                function.Invoke(destination);
                IRfcTable rfctable_PT_FIELDS = function.GetTable("PT_FIELDS");

                EDI_IAPI12 _EDI_IAPI12;
                for (int i = 0; i < rfctable_PT_FIELDS.RowCount; i++)
                {
                    _EDI_IAPI12            = new EDI_IAPI12();
                    _EDI_IAPI12.SEGMENTTYP = rfctable_PT_FIELDS[i].GetString("SEGMENTTYP"); // 段类型(30 字符格式)
                    _EDI_IAPI12.FIELDNAME  = rfctable_PT_FIELDS[i].GetString("FIELDNAME");  // 字段名
                    _EDI_IAPI12.INTLEN     = rfctable_PT_FIELDS[i].GetInt("INTLEN");        // 以字节计的内部长度
                    _EDI_IAPI12.EXTLEN     = rfctable_PT_FIELDS[i].GetInt("EXTLEN");        // 输出长度
                    _EDI_IAPI12.FIELD_POS  = rfctable_PT_FIELDS[i].GetInt("FIELD_POS");     // 字段的位置号码
                    _EDI_IAPI12.BYTE_FIRST = rfctable_PT_FIELDS[i].GetInt("BYTE_FIRST");    // 第一个字节的位置
                    _EDI_IAPI12.BYTE_LAST  = rfctable_PT_FIELDS[i].GetInt("BYTE_LAST");     // 最后一个字节的位置
                    _EDI_IAPI12.ROLLNAME   = rfctable_PT_FIELDS[i].GetString("ROLLNAME");   // 数据元素 (语义域)
                    _EDI_IAPI12.DOMNAME    = rfctable_PT_FIELDS[i].GetString("DOMNAME");    // 定义域名
                    _EDI_IAPI12.DATATYPE   = rfctable_PT_FIELDS[i].GetString("DATATYPE");   // ABAP/4 字典: 屏幕绘制器的屏幕数据类型
                    _EDI_IAPI12.DESCRP     = rfctable_PT_FIELDS[i].GetString("DESCRP");     // 对象的简短说明
                    _EDI_IAPI12.ISOCODE    = rfctable_PT_FIELDS[i].GetString("ISOCODE");    // IDoc 开发:字段中的 ISO 代码标识
                    _EDI_IAPI12.VALUETAB   = rfctable_PT_FIELDS[i].GetString("VALUETAB");   // IDoc 段字段的值表
                    _FIELDS.Add(_EDI_IAPI12);
                }

                IRfcTable rfctable_PT_FVALUES = function.GetTable("PT_FVALUES");

                EDI_IAPI14 _EDI_IAPI14;
                for (int i = 0; i < rfctable_PT_FVALUES.RowCount; i++)
                {
                    _EDI_IAPI14            = new EDI_IAPI14();
                    _EDI_IAPI14.STRNAME    = rfctable_PT_FVALUES[i].GetString("STRNAME");    // 内部结构的名称
                    _EDI_IAPI14.FIELDNAME  = rfctable_PT_FVALUES[i].GetString("FIELDNAME");  // 字段名
                    _EDI_IAPI14.FLDVALUE_L = rfctable_PT_FVALUES[i].GetString("FLDVALUE_L"); // 下限值 / 单一值
                    _EDI_IAPI14.FLDVALUE_H = rfctable_PT_FVALUES[i].GetString("FLDVALUE_H"); // 上限值
                    _EDI_IAPI14.DESCRP     = rfctable_PT_FVALUES[i].GetString("DESCRP");     // 说明简要文字
                    _FVALUES.Add(_EDI_IAPI14);
                }

                IRfcTable rfctable_PT_MESSAGES = function.GetTable("PT_MESSAGES");

                EDI_IAPI17 _EDI_IAPI17;
                for (int i = 0; i < rfctable_PT_MESSAGES.RowCount; i++)
                {
                    _EDI_IAPI17          = new EDI_IAPI17();
                    _EDI_IAPI17.MESTYP   = rfctable_PT_MESSAGES[i].GetString("MESTYP");   // 消息类型
                    _EDI_IAPI17.DESCRP   = rfctable_PT_MESSAGES[i].GetString("DESCRP");   // 对象的简短说明
                    _EDI_IAPI17.IDOCTYP  = rfctable_PT_MESSAGES[i].GetString("IDOCTYP");  // 基本类型
                    _EDI_IAPI17.CIMTYP   = rfctable_PT_MESSAGES[i].GetString("CIMTYP");   // 扩展类型
                    _EDI_IAPI17.RELEASED = rfctable_PT_MESSAGES[i].GetString("RELEASED"); // 消息类型分配有效的版本
                    _MESSAGES.Add(_EDI_IAPI17);
                }

                IRfcTable rfctable_PT_SEGMENTS = function.GetTable("PT_SEGMENTS");

                EDI_IAPI11 _EDI_IAPI11;
                for (int i = 0; i < rfctable_PT_SEGMENTS.RowCount; i++)
                {
                    _EDI_IAPI11            = new EDI_IAPI11();
                    _EDI_IAPI11.NR         = rfctable_PT_SEGMENTS[i].GetInt("NR");            // IDoc 类型中段的序列号
                    _EDI_IAPI11.SEGMENTTYP = rfctable_PT_SEGMENTS[i].GetString("SEGMENTTYP"); // 段类型(30 字符格式)
                    _EDI_IAPI11.SEGMENTDEF = rfctable_PT_SEGMENTS[i].GetString("SEGMENTDEF"); // IDoc 开发:段定义
                    _EDI_IAPI11.QUALIFIER  = rfctable_PT_SEGMENTS[i].GetString("QUALIFIER");  // 标记:IDoc 中限定的段
                    _EDI_IAPI11.SEGLEN     = rfctable_PT_SEGMENTS[i].GetInt("SEGLEN");        // 一个字段的长度(位置的数目)
                    _EDI_IAPI11.PARSEG     = rfctable_PT_SEGMENTS[i].GetString("PARSEG");     // 段类型(30 字符格式)
                    _EDI_IAPI11.PARPNO     = rfctable_PT_SEGMENTS[i].GetInt("PARPNO");        // 父代段的序列号
                    _EDI_IAPI11.PARFLG     = rfctable_PT_SEGMENTS[i].GetString("PARFLG");     // 父段标记:段是段组的开始
                    _EDI_IAPI11.MUSTFL     = rfctable_PT_SEGMENTS[i].GetString("MUSTFL");     // 标记:强制条目
                    _EDI_IAPI11.OCCMIN     = rfctable_PT_SEGMENTS[i].GetInt("OCCMIN");        // 序列中段的最小数目
                    _EDI_IAPI11.OCCMAX     = rfctable_PT_SEGMENTS[i].GetDouble("OCCMAX");     // 序列中最大段数目
                    _EDI_IAPI11.HLEVEL     = rfctable_PT_SEGMENTS[i].GetInt("HLEVEL");        // IDoc 类型段的层次水平
                    _EDI_IAPI11.DESCRP     = rfctable_PT_SEGMENTS[i].GetString("DESCRP");     // 对象的简短说明
                    _EDI_IAPI11.GRP_MUSTFL = rfctable_PT_SEGMENTS[i].GetString("GRP_MUSTFL"); // 组标记:强制
                    _EDI_IAPI11.GRP_OCCMIN = rfctable_PT_SEGMENTS[i].GetInt("GRP_OCCMIN");    // 序列中最小组号
                    _EDI_IAPI11.GRP_OCCMAX = rfctable_PT_SEGMENTS[i].GetDouble("GRP_OCCMAX"); // 序列中最大组号
                    _EDI_IAPI11.REFSEGTYP  = rfctable_PT_SEGMENTS[i].GetString("REFSEGTYP");  // 段类型(30 字符格式)
                    _SEGMENTS.Add(_EDI_IAPI11);
                }
            }
        }
        /// <summary>
        /// 填充所有的参数调用SAP RFC函数后,填充所有的参数
        /// </summary>
        /// <param name="funame">函数名</param>
        /// <param name="list">输入参数列表</param>
        /// <param name="olist">输出参数列表</param>
        /// <returns></returns>
        private static bool InvokeFunctionFromJson(string sysName, string funame, RfcInputListJson list, out RfcOutputListJson olist)
        {
            try
            {
                if (funame == "" || null == list)
                {
                    olist = null;
                    return(false);
                }
                if (!SAPFunction.CheckFunction(sysName, funame))
                {
                    olist = null;
                    return(false);
                }
                RfcDestination      destination = SAPDestination.GetDesByName(sysName);
                RfcFunctionMetadata MetaData    = destination.Repository.GetFunctionMetadata(funame);
                IRfcFunction        function    = MetaData.CreateFunction();
                //初步序列化后的参数还需要进一步进行格式化,把结构体与表格都转化成SAP格式。
                list.All.Clear();
                list.All.AddRange(list.Import);
                list.All.AddRange(list.Change);
                list.All.AddRange(list.Tables);
                foreach (var item in list.All)
                {
                    if (item.Value == null)
                    {
                        continue;
                    }
                    RfcParameterMetadata p = MetaData[item.Name];
                    if (p == null)
                    {
                        continue;
                    }
                    //尝试把OBJECT反解析成对应的类型
                    if (p.DataType == RfcDataType.STRUCTURE)
                    {
                        Console.WriteLine(item.Value.GetType().ToString());
                        if (item.Value.GetType().ToString() != "Newtonsoft.Json.Linq.JArray" && item.Value.GetType().ToString() != "System.Array")
                        {
                            continue;
                        }
                        if (item.Value.GetType().ToString() != "System.Array")
                        {
                            // continue;
                        }
                        IRfcStructure str = function.GetStructure(item.Name, true);
                        var           arr = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(item.Value.ToString());
                        if (arr.Count == 1)
                        {
                            //结构使用第一行
                            var o = arr[0];
                            for (int s = 0; s < str.Metadata.FieldCount; s++)
                            {
                                RfcFieldMetadata field = str.Metadata[s];
                                str.SetValue(field.Name, o[field.Name]);
                            }
                        }
                        item.Value = str;
                    }
                    else if (p.DataType == RfcDataType.TABLE)
                    {
                        if (string.IsNullOrEmpty(item.Value.ToString()))
                        {
                            continue;
                        }
                        IRfcTable tbl = function.GetTable(item.Name, true);
                        var       arr = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(item.Value.ToString());
                        for (int x = 0; x < arr.Count; x++)
                        {
                            IRfcStructure str = tbl.Metadata.LineType.CreateStructure();
                            for (int s = 0; s < tbl.Metadata.LineType.FieldCount; s++)
                            {
                                RfcFieldMetadata field = tbl.Metadata.LineType[s];
                                str.SetValue(field.Name, arr[x][field.Name]);
                            }
                            tbl.Append(str);
                        }
                        item.Value = tbl;
                    }
                }
                //填充所有的参数
                for (int i = 0; i < MetaData.ParameterCount; i++)
                {
                    RfcParameterMetadata pMetadata = MetaData[i];
                    if (list.All.Exists(x => x.Name == pMetadata.Name))
                    {
                        var value = list.All.Find(x => x.Name == pMetadata.Name).Value;
                        if (value != null)
                        {
                            function.SetValue(pMetadata.Name, value);
                        }
                    }
                }
                //远程调用函数
                try
                {
                    function.Invoke(destination);
                }
                catch (RfcAbapException ee)
                {
                    throw new Exception(ee.Key + ee.Message);
                }
                //保留调用结果。
                RfcOutputListJson outlist = new RfcOutputListJson();
                //循环读取结果。把所以的结果都保存到List<object>中。
                for (int i = 0; i < MetaData.ParameterCount; i++)
                {
                    RfcParameterMetadata pMetadata = MetaData[i];
                    //
                    if (pMetadata.Direction == RfcDirection.IMPORT)
                    {
                        continue;
                    }
                    RfcKeyValueJson d = new RfcKeyValueJson();
                    d.Name = pMetadata.Name;
                    if (pMetadata.DataType == RfcDataType.STRUCTURE)
                    {
                        //注意,在这里就算是结构体,也把放到List中,这样可以序列化成数组格式。
                        List <object> tb_list            = new List <object>();
                        IRfcStructure row                = function.GetStructure(pMetadata.Name);
                        Dictionary <string, object> rowd = new Dictionary <string, object>();
                        for (int x = 0; x < row.Metadata.FieldCount; x++)
                        {
                            rowd.Add(row[x].Metadata.Name, row[x].GetValue());
                        }
                        tb_list.Add(rowd);
                        d.Value = tb_list;
                    }
                    else if (pMetadata.DataType == RfcDataType.TABLE)
                    {
                        List <object> tb_list   = new List <object>();
                        IRfcTable     table     = function.GetTable(pMetadata.Name);
                        var           readItems = table.RowCount;
                        if (readItems > 0)
                        {
                            try
                            {
                                //保存结果到数据库。
                                RfcTableMetadata tableMeta = pMetadata.ValueMetadataAsTableMetadata;
                                var _table = new SapTable(sysName, funame + "_" + pMetadata.Name, tableMeta.LineType.Name);
                                _table.DbConnectionString = ConfigFileTool.SAPGlobalSettings.GetDefaultDbConnection();
                                _table.NewTable           = true;
                                _table.SaveDataTable(SAPFunction.RfcTableToDataTable(table));
                                // RfcTableToDb dbhelper = new RfcTableToDb(funame, d.Name, tble);
                                //  dbhelper.saveTable();
                            }
                            catch (Exception ee)
                            {
                                throw new Exception(ee.Message);
                            }
                            // ThreadStart threadStart = new ThreadStart(dbhelper.saveTable);
                            //  Thread thread = new Thread(threadStart);
                            //  thread.Start();
                            //DbHelper.saveRfcTable(funame,ref tble);
                        }
                        //控制100条,数据过多会序列华出错。以后再做改善,
                        if (readItems > 10)
                        {
                            readItems = 10;
                        }
                        for (int rowc = 0; rowc < readItems; rowc++)
                        {
                            IRfcStructure row = table[rowc];
                            Dictionary <string, object> rowd = new Dictionary <string, object>();
                            for (int x = 0; x < row.Metadata.FieldCount; x++)
                            {
                                rowd.Add(row[x].Metadata.Name, row[x].GetValue());
                            }
                            tb_list.Add(rowd);
                        }
                        d.Value = tb_list;
                    }
                    else
                    {
                        d.Value = function.GetValue(pMetadata.Name);
                    }
                    //存放于不同的集合也是为了序列化方便。
                    switch (pMetadata.Direction)
                    {
                    case RfcDirection.CHANGING:
                        outlist.Change.Add(d);
                        break;

                    case RfcDirection.EXPORT:
                        outlist.Export.Add(d);
                        break;

                    case RfcDirection.IMPORT:
                        outlist.Import.Add(d);
                        break;

                    case RfcDirection.TABLES:
                        outlist.Tables.Add(d);
                        break;
                    }
                }
                olist = outlist;
                return(true);
            }
            catch (Exception e)
            {
                throw new SAPException(e.Message);
            }
        }
        /// <summary>
        /// 动态调用RFC函数
        /// </summary>
        /// <param name="sysName"></param>
        /// <param name="funame"></param>
        /// <param name="input"></param>
        /// <param name="output"></param>
        /// <returns></returns>
        public static bool InvokeFunction(string sysName, string funame, MetaValueList input, out MetaValueList output)
        {
            try
            {
                RfcFunctionMetadata MetaData = SAPFunctionMeta.GetRfcFunctionMetadata(sysName, funame);
                IRfcFunction        function = MetaData.CreateFunction();
                //初步序列化后的参数还需要进一步进行格式化,把结构体与表格都转化成SAP格式。
                if (input != null)
                {
                    //填充所有的参数
                    List <String> KeyIndex = new List <string>();
                    KeyIndex.AddRange(input.FieldValueList.Keys);
                    KeyIndex.AddRange(input.StructureValueList.Keys);
                    KeyIndex.AddRange(input.TableValueList.Keys);
                    KeyIndex.ForEach(x => x.ToUpper().Trim());
                    for (int i = 0; i < MetaData.ParameterCount; i++)
                    {
                        RfcParameterMetadata pMetadata = MetaData[i];
                        if (pMetadata.Direction == RfcDirection.EXPORT)
                        {
                            continue;
                        }
                        if (!KeyIndex.Contains(pMetadata.Name))
                        {
                            continue;
                        }

                        // Dictionary<String, Object> ParameterList = new Dictionary<string, object>();
                        if (pMetadata.DataType == RfcDataType.STRUCTURE)
                        {
                            if (input.StructureValueList.ContainsKey(pMetadata.Name))
                            {
                                Dictionary <String, String> structure;
                                input.StructureValueList.TryGetValue(pMetadata.Name, out structure);
                                IRfcStructure str = function.GetStructure(pMetadata.Name, true);
                                if (structure != null)
                                {
                                    for (int s = 0; s < str.Metadata.FieldCount; s++)
                                    {
                                        RfcFieldMetadata field = str.Metadata[s];
                                        if (structure.Keys.Contains(field.Name))
                                        {
                                            Object o = Converts.ObjectToRfcValue(structure[field.Name], field.DataType);
                                            str.SetValue(field.Name, o);
                                        }
                                    }
                                }
                            }
                        }
                        else if (pMetadata.DataType == RfcDataType.TABLE)
                        {
                            List <Dictionary <String, String> > tablelist;
                            input.TableValueList.TryGetValue(pMetadata.Name, out tablelist);
                            if (tablelist != null)
                            {
                                IRfcTable table = function.GetTable(pMetadata.Name);
                                for (int j = 0; j < tablelist.Count; j++)
                                {
                                    table.Append();
                                    for (int k = 0; k < table.Metadata.LineType.FieldCount; k++)
                                    {
                                        RfcFieldMetadata field = table.Metadata.LineType[k];
                                        if (tablelist[j].Keys.Contains(field.Name))
                                        {
                                            Object o = Converts.ObjectToRfcValue(tablelist[j][field.Name], field.DataType);
                                            table.SetValue(field.Name, o);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            String value = "";
                            input.FieldValueList.TryGetValue(pMetadata.Name, out value);
                            Object o = Converts.ObjectToRfcValue(value, pMetadata.DataType);
                            function.SetValue(pMetadata.Name, o);
                        }
                    }
                }
                MetaValueList outputlist = new MetaValueList();

                try
                {
                    RfcDestination destination = SAPDestination.GetDesByName(sysName);

                    function.Invoke(destination);
                }
                catch (RfcAbapException ee)
                {
                    throw new SAPException(ee.Key + ee.Message + ee.PlainText);
                }
                catch (RfcAbapRuntimeException runtimeEx)
                {
                    throw new SAPException(runtimeEx.Key + runtimeEx.Message + runtimeEx.PlainText);
                }


                for (int i = 0; i < MetaData.ParameterCount; i++)
                {
                    RfcParameterMetadata pMetadata = MetaData[i];
                    if (pMetadata.Direction == RfcDirection.IMPORT)
                    {
                        continue;
                    }
                    // outputlist.FieldTypeList.Add(pMetadata.Name, pMetadata.DataType.ToString());
                    if (pMetadata.DataType == RfcDataType.STRUCTURE)
                    {
                        Dictionary <String, String> stru = null;
                        IRfcStructure structure          = function.GetStructure(pMetadata.Name, false);
                        if (structure != null)
                        {
                            stru = new Dictionary <string, string>();
                            for (int s = 0; s < structure.Metadata.FieldCount; s++)
                            {
                                RfcFieldMetadata field  = structure.Metadata[s];
                                Object           result = null;

                                if (field.DataType == RfcDataType.BYTE)
                                {
                                    result = structure.GetString(field.Name);
                                }
                                else
                                {
                                    result = structure.GetValue(field.Name);
                                }

                                result = Converts.RfcToDoNetValue(result, field.DataType).ToString();
                                stru.Add(field.Name, result.ToString());
                            }
                            if (stru != null)
                            {
                                outputlist.StructureValueList.Add(pMetadata.Name, stru);
                            }
                        }
                    }
                    else if (pMetadata.DataType == RfcDataType.TABLE)
                    {
                        List <Dictionary <String, String> > outTableList = null;
                        IRfcTable outTable = function.GetTable(pMetadata.Name, false);
                        if (outTable != null)
                        {
                            outTableList = new List <Dictionary <string, string> >();
                            for (int s = 0; s < outTable.RowCount; s++)
                            {
                                IRfcStructure rfcTableLine      = outTable[s];
                                Dictionary <String, String> row = new Dictionary <string, string>();
                                for (int z = 0; z < rfcTableLine.Metadata.FieldCount; z++)
                                {
                                    RfcFieldMetadata field  = rfcTableLine[z].Metadata;
                                    Object           result = null;

                                    if (field.DataType == RfcDataType.BYTE)
                                    {
                                        result = rfcTableLine.GetString(field.Name);
                                    }
                                    else
                                    {
                                        result = rfcTableLine.GetValue(field.Name);
                                    }
                                    result = Converts.RfcToDoNetValue(result, field.DataType).ToString();
                                    row.Add(field.Name, result.ToString());
                                }
                                outTableList.Add(row);
                            }
                        }
                        outputlist.TableValueList.Add(pMetadata.Name, outTableList);
                    }
                    else
                    {
                        Object result = function.GetValue(pMetadata.Name);
                        result = Converts.RfcToDoNetValue(result, pMetadata.DataType);
                        outputlist.FieldValueList.Add(pMetadata.Name, result.ToString());
                    }
                }
                output = outputlist;
                return(true);
            }
            catch (Exception e)
            {
                output = null;
                throw new SAPException(e.Message);
            }
        }
Exemple #21
0
        public List <CD010SINF> SearchProgram(String searchTerm, String classType, String devClass)
        {
            //if (String.IsNullOrEmpty(searchTerm))
            //{
            //    throw new SAPException(String.Format("{0} 不能为空",searchTerm));
            //}
            //SourceCode = new List<string>();
            //ProgramList = new List<string>();

            try
            {
                var          destination = SAPDestination.GetDesByName(_sysName);
                IRfcFunction function    = destination.Repository.CreateFunction("ZVI_RFC_READ_PROGRAM");
                function.SetValue("I_PROG", searchTerm);
                function.SetValue("I_CLASS", classType);
                function.SetValue("I_DEVCLASS", devClass);
                function.Invoke(destination);

                List <CD010SINF> _D010SINF_LIST = new List <CD010SINF>();

                IRfcTable rfctable_D010SINF = function.GetTable("ET_D010SINF");

                // C${rfctable.Name} _C${rfctable.Name};
                for (int i = 0; i < rfctable_D010SINF.RowCount; i++)
                {
                    var _D010SINF = new CD010SINF();
                    _D010SINF.prog   = rfctable_D010SINF[i].GetString("PROG");  // 程序
                    _D010SINF.clas   = rfctable_D010SINF[i].GetString("CLAS");  // 类别
                    _D010SINF.subc   = rfctable_D010SINF[i].GetString("SUBC");  // 程序类型
                    _D010SINF.appl   = rfctable_D010SINF[i].GetString("APPL");  // 应用
                    _D010SINF.cdat   = rfctable_D010SINF[i].GetString("CDAT");  // 创建日期
                    _D010SINF.vern   = rfctable_D010SINF[i].GetString("VERN");  //
                    _D010SINF.rmand  = rfctable_D010SINF[i].GetString("RMAND"); //
                    _D010SINF.rload  = rfctable_D010SINF[i].GetString("RLOAD"); //
                    _D010SINF.unam   = rfctable_D010SINF[i].GetString("UNAM");  //
                    _D010SINF.udat   = rfctable_D010SINF[i].GetString("UDAT");  // 更改日期
                    _D010SINF.utime  = rfctable_D010SINF[i].GetString("UTIME"); //
                    _D010SINF.datalg = rfctable_D010SINF[i].GetInt("DATALG");   // 长度
                    _D010SINF.varcl  = rfctable_D010SINF[i].GetString("VARCL"); //
                    _D010SINF_LIST.Add(_D010SINF);
                }
                //for (int i = 0; i < source.RowCount; i++)
                //{
                //    source.CurrentIndex = i;
                //    SourceCode.Add(source.GetString("ZEILE"));
                //}

                //for (int i = 0; i < programlist.RowCount; i++)
                //{
                //    programlist.CurrentIndex = i;
                //    ProgramList.Add(programlist.GetString("OBJ_NAME"));
                //}
                return(_D010SINF_LIST);
            }
            catch (RfcAbapException abapException)
            {
                throw new SAPException(abapException.Key + abapException.Message);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public static RfcOutputListJson GetFunMetaList(string sysName, string funame)
        {
            RfcOutputListJson paralist = new RfcOutputListJson();

            try
            {
                if (string.IsNullOrEmpty(funame))
                {
                    throw new SAPException("请输入函数!!");
                }
                if (!SAPFunction.CheckFunction(sysName, funame))
                {
                    throw new SAPException("函数不存在!!");
                }
                funame = funame.ToUpper();
                RfcDestination destination = SAPDestination.GetDesByName(sysName);
                destination.Repository.ClearAllMetadata();
                RfcFunctionMetadata MetaData = destination.Repository.GetFunctionMetadata(funame);
                IRfcFunction        function = null;
                function = MetaData.CreateFunction();
                //根据参数的方向,分为四种(CHANGING,EXPORT,IMPORT,TABLES);
                for (int i = 0; i < MetaData.ParameterCount; i++)
                {
                    RfcParameterMetadata pMetadata = MetaData[i];
                    paralist.All.Add(pMetadata);
                    switch (pMetadata.Direction)
                    {
                    case RfcDirection.CHANGING:
                        paralist.Change.Add(pMetadata);
                        break;

                    case RfcDirection.EXPORT:
                        paralist.Export.Add(pMetadata);
                        break;

                    case RfcDirection.IMPORT:
                        paralist.Import.Add(pMetadata);
                        break;

                    case RfcDirection.TABLES:
                        paralist.Tables.Add(pMetadata);
                        break;
                    }
                    //参数也可能是结构体,表,ABAP对象
                    //一定要分开TRY,因为有些是没有的
                    if (pMetadata.DataType == RfcDataType.STRUCTURE)
                    {
                        try
                        {
                            //结构体的行项目结构
                            List <object>        elelist   = new List <object>();
                            RfcStructureMetadata strucmeta = pMetadata.ValueMetadataAsStructureMetadata;
                            for (int f = 0; f < strucmeta.FieldCount; f++)
                            {
                                RfcFieldMetadata fieldm = strucmeta[f];
                                elelist.Add(fieldm);
                            }
                            paralist.Objects.Add(pMetadata.Name, elelist);
                        }
                        catch (Exception)
                        {
                            //  throw new SAPException(ee.Message);
                        }
                    }
                    if (pMetadata.DataType == RfcDataType.TABLE)
                    {
                        //表结构的行项目结构
                        List <object>    tbllist = new List <object>();
                        RfcTableMetadata tablem  = pMetadata.ValueMetadataAsTableMetadata;
                        for (int t = 0; t < tablem.LineType.FieldCount; t++)
                        {
                            RfcFieldMetadata fieldm = tablem.LineType[t];
                            tbllist.Add(fieldm);
                        }
                        paralist.Objects.Add(pMetadata.Name, tbllist);
                    }
                    if (pMetadata.DataType == RfcDataType.CLASS)
                    {
                        //abap object 属性
                        List <object>         attlist  = new List <object>();
                        RfcAbapObjectMetadata abapitem = pMetadata.ValueMetadataAsAbapObjectMetadata;
                        for (int o = 0; o < abapitem.AttributeCount; o++)
                        {
                            RfcAttributeMetadata abapobject = abapitem[o];
                            attlist.Add(abapobject);
                        }
                        paralist.Objects.Add(pMetadata.Name, attlist);
                    }
                }
                return(paralist);
            }
            catch (Exception ee)
            {
                throw new SAPException(ee.Message);
            }
        }
Exemple #23
0
        public List <CTRDIR> SearchProgram(String searchTerm, String objecType, String devClass, bool reportOnly = true)
        {
            //if (String.IsNullOrEmpty(searchTerm))
            //{
            //    throw new SAPException(String.Format("{0} 不能为空",searchTerm));
            //}
            //SourceCode = new List<string>();
            //ProgramList = new List<string>();

            try
            {
                var          destination = SAPDestination.GetDesByName(_sysName);
                IRfcFunction function    = destination.Repository.CreateFunction("ZVI_RFC_READ_PROGRAM");
                function.SetValue("I_PROG", searchTerm);
                function.SetValue("I_OBJECT", objecType);
                function.SetValue("I_DEVCLASS", devClass);
                if (true == reportOnly)
                {
                    function.SetValue("I_NOT_LIMIT", 'X');
                }
                else
                {
                    function.SetValue("I_NOT_LIMIT", ' ');
                }
                function.Invoke(destination);
                // IRfcTable source = function.GetTable("ET_PROGRAM");
                // IRfcTable programlist = function.GetTable("ET_TADIR");


                // IRfcTable rfctable_TADIR = function.GetTable("ET_TADIR");
                // var dt = SAPINT.Function.SAPFunction.RfcTableToDataTable(rfctable_TADIR);
                List <CTRDIR> _TRDIR_LIST    = new List <CTRDIR>();
                IRfcTable     rfctable_TRDIR = function.GetTable("ET_TRDIR");

                // CTRDIR _CTRDIR;
                for (int i = 0; i < rfctable_TRDIR.RowCount; i++)
                {
                    var _TRDIR = new CTRDIR();
                    _TRDIR.name    = rfctable_TRDIR[i].GetString("NAME");    // Program
                    _TRDIR.sqlx    = rfctable_TRDIR[i].GetString("SQLX");    //
                    _TRDIR.edtx    = rfctable_TRDIR[i].GetString("EDTX");    //
                    _TRDIR.varcl   = rfctable_TRDIR[i].GetString("VARCL");   //
                    _TRDIR.dbapl   = rfctable_TRDIR[i].GetString("DBAPL");   //
                    _TRDIR.dbna    = rfctable_TRDIR[i].GetString("DBNA");    //
                    _TRDIR.clas    = rfctable_TRDIR[i].GetString("CLAS");    // Class
                    _TRDIR.type    = rfctable_TRDIR[i].GetString("TYPE");    // Selection screen version
                    _TRDIR.occurs  = rfctable_TRDIR[i].GetString("OCCURS");  //
                    _TRDIR.subc    = rfctable_TRDIR[i].GetString("SUBC");    // Prog. type
                    _TRDIR.appl    = rfctable_TRDIR[i].GetString("APPL");    // Appl.
                    _TRDIR.secu    = rfctable_TRDIR[i].GetString("SECU");    //
                    _TRDIR.cnam    = rfctable_TRDIR[i].GetString("CNAM");    // Created By
                    _TRDIR.cdat    = rfctable_TRDIR[i].GetString("CDAT");    // Created on
                    _TRDIR.unam    = rfctable_TRDIR[i].GetString("UNAM");    //
                    _TRDIR.udat    = rfctable_TRDIR[i].GetString("UDAT");    // Changed on
                    _TRDIR.vern    = rfctable_TRDIR[i].GetString("VERN");    //
                    _TRDIR.levl    = rfctable_TRDIR[i].GetString("LEVL");    //
                    _TRDIR.rstat   = rfctable_TRDIR[i].GetString("RSTAT");   // Program status
                    _TRDIR.rmand   = rfctable_TRDIR[i].GetString("RMAND");   //
                    _TRDIR.rload   = rfctable_TRDIR[i].GetString("RLOAD");   //
                    _TRDIR.fixpt   = rfctable_TRDIR[i].GetString("FIXPT");   //
                    _TRDIR.sset    = rfctable_TRDIR[i].GetString("SSET");    //
                    _TRDIR.sdate   = rfctable_TRDIR[i].GetString("SDATE");   //
                    _TRDIR.stime   = rfctable_TRDIR[i].GetString("STIME");   //
                    _TRDIR.idate   = rfctable_TRDIR[i].GetString("IDATE");   //
                    _TRDIR.itime   = rfctable_TRDIR[i].GetString("ITIME");   //
                    _TRDIR.ldbname = rfctable_TRDIR[i].GetString("LDBNAME"); // LDB name
                    _TRDIR.uccheck = rfctable_TRDIR[i].GetString("UCCHECK"); // Unicode checks
                    _TRDIR_LIST.Add(_TRDIR);
                }
                List <CD010SINF> _D010SINF_LIST = new List <CD010SINF>();

                IRfcTable rfctable_D010SINF = function.GetTable("ET_D010SINF");

                // C${rfctable.Name} _C${rfctable.Name};
                for (int i = 0; i < rfctable_D010SINF.RowCount; i++)
                {
                    var _D010SINF = new CD010SINF();
                    _D010SINF.prog   = rfctable_D010SINF[i].GetString("PROG");  // 程序
                    _D010SINF.clas   = rfctable_D010SINF[i].GetString("CLAS");  // 类别
                    _D010SINF.subc   = rfctable_D010SINF[i].GetString("SUBC");  // 程序类型
                    _D010SINF.appl   = rfctable_D010SINF[i].GetString("APPL");  // 应用
                    _D010SINF.cdat   = rfctable_D010SINF[i].GetString("CDAT");  // 创建日期
                    _D010SINF.vern   = rfctable_D010SINF[i].GetString("VERN");  //
                    _D010SINF.rmand  = rfctable_D010SINF[i].GetString("RMAND"); //
                    _D010SINF.rload  = rfctable_D010SINF[i].GetString("RLOAD"); //
                    _D010SINF.unam   = rfctable_D010SINF[i].GetString("UNAM");  //
                    _D010SINF.udat   = rfctable_D010SINF[i].GetString("UDAT");  // 更改日期
                    _D010SINF.utime  = rfctable_D010SINF[i].GetString("UTIME"); //
                    _D010SINF.datalg = rfctable_D010SINF[i].GetInt("DATALG");   // 长度
                    _D010SINF.varcl  = rfctable_D010SINF[i].GetString("VARCL"); //
                    _D010SINF_LIST.Add(_D010SINF);
                }
                //for (int i = 0; i < source.RowCount; i++)
                //{
                //    source.CurrentIndex = i;
                //    SourceCode.Add(source.GetString("ZEILE"));
                //}

                //for (int i = 0; i < programlist.RowCount; i++)
                //{
                //    programlist.CurrentIndex = i;
                //    ProgramList.Add(programlist.GetString("OBJ_NAME"));
                //}
                return(_TRDIR_LIST);
            }
            catch (RfcAbapException abapException)
            {
                throw new SAPException(abapException.Key + abapException.Message);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #24
0
 // Methods
 public QueryHelper(string sysName)
 {
     this._des = SAPDestination.GetDesByName(sysName);
 }