示例#1
0
        /// <summary>
        /// 有些SAP的函数RFC_GET_FUNCTION_INTERFACE不
        /// 支持返回REMOTE_CALL函数。
        /// 通过直接读取数据库表判断函数是否是RFC函数。
        /// </summary>
        /// <param name="pSystem"></param>
        /// <param name="pFunction"></param>
        /// <returns></returns>
        public static string CheckFunctionMode(string pSystem, String pFunction)
        {
            var _is_rfc = string.Empty;

            var _tfdir = new SAPINT.Utils.ReadTable(pSystem);

            _tfdir.TableName = "TFDIR";
            _tfdir.AddCriteria("FUNCNAME = '" + pFunction + "'");
            _tfdir.RowCount = 1;
            _tfdir.Run();
            var _tfdirResult = _tfdir.Result;

            if (_tfdirResult != null)
            {
                if (_tfdirResult.Rows.Count > 0)
                {
                    _is_rfc = _tfdirResult.Rows[0]["FMODE"].ToString();
                }
            }
            return(_is_rfc);
        }
示例#2
0
        /// <summary>
        /// 根据IDOC编号把IDOC复制到本地。
        /// </summary>
        /// <param name="idocNumber">IDOC编号</param>
        /// <param name="SystemName">远程SAP系统名称</param>
        public void CopyIdocFromSAP(String idocNumber, String SystemName)
        {
            try
            {
                SAPINT.Utils.ReadTable idocReadItem = null;
                SAPINT.Utils.ReadTable idocReadHeader = null;
                SAPINT.Utils.ReadTable idocReadStatus = null;

                //DataTable dtIdocItem = new DataTable();
                //DataTable dtIdocHeder = new DataTable();
                //DataTable dtIdocStatus = new DataTable();

                idocNumber = idocNumber.TrimStart('0');
                String criteria = idocNumber.PadLeft(16, '0');
                criteria = String.Format("DOCNUM = '{0}'", criteria);

                String readTableFunction = ConfigFileTool.SAPGlobalSettings.GetReadTableFunction();

                idocReadItem = new SAPINT.Utils.ReadTable(SystemName);
                idocReadItem.TableName = "EDID4";
                idocReadItem.SetCustomFunctionName(readTableFunction);
                idocReadItem.AddCriteria(criteria);
                idocReadItem.Run();

                idocItem = idocReadItem.Result;

                if (idocItem.Rows.Count == 0)
                {
                    idocReadItem = new SAPINT.Utils.ReadTable(SystemName);
                    idocReadItem.TableName = "EDID2";
                    idocReadItem.SetCustomFunctionName(readTableFunction);
                    idocReadItem.AddCriteria(criteria);
                    idocReadItem.Run();
                    idocItem = idocReadItem.Result;

                }
                if (idocItem.Rows.Count == 0)
                {
                    idocReadItem = new SAPINT.Utils.ReadTable(SystemName);
                    idocReadItem.TableName = "EDIDD_OLD";
                    idocReadItem.SetCustomFunctionName(readTableFunction);
                    idocReadItem.AddCriteria(criteria);
                    idocReadItem.Run();
                    idocItem = idocReadItem.Result;
                }
                if (idocItem.Rows.Count == 0)
                {
                    throw new Exception(String.Format("无法找到IDOC{0}明细", idocNumber));
                }
                //读取IDOC头
                idocReadHeader = new SAPINT.Utils.ReadTable(SystemName);
                idocReadHeader.TableName = "EDIDC";
                idocReadHeader.SetCustomFunctionName(readTableFunction);
                idocReadHeader.AddCriteria(criteria);
                idocReadHeader.Run();
                idocHeader = idocReadHeader.Result;

                //if (idocHeader.Rows.Count != 1)
                //{
                //    throw new Exception(String.Format("无法找到IDOC{0}抬头定义", idocNumber));
                //}

                //读取IDOC状态
                idocReadStatus = new SAPINT.Utils.ReadTable(SystemName);
                idocReadStatus.TableName = "EDIDS";
                idocReadStatus.SetCustomFunctionName(readTableFunction);
                idocReadStatus.AddCriteria(criteria);
                idocReadStatus.Run();
                idocStatus = idocReadStatus.Result;



                SapTable idocTable = null;
                if (idocHeader.Rows.Count > 0)
                {
                    idocTable = new SapTable(SystemName, "EDIDC");
                    idocTable.DbConnectionString = this.ConnectionName;
                    idocTable.AppendToDb = AppendTodb;
                    idocTable.SaveDataTable(idocHeader);
                }


                if (idocItem.Rows.Count > 0)
                {
                    idocTable = new SapTable(SystemName, "EDID4", "EDID4");
                    idocTable.DbConnectionString = this.ConnectionName;
                    idocTable.AppendToDb = AppendTodb;
                    idocTable.SaveDataTable(idocItem);
                }


                if (idocStatus.Rows.Count > 0)
                {
                    idocTable = new SapTable(SystemName, "EDIDS");
                    idocTable.DbConnectionString = this.ConnectionName;
                    idocTable.AppendToDb = AppendTodb;
                    idocTable.SaveDataTable(idocStatus);

                }

            }
            catch (Exception)
            {

                throw;
            }

        }
        /// <summary>
        /// 有些SAP的函数RFC_GET_FUNCTION_INTERFACE不
        /// 支持返回REMOTE_CALL函数。
        /// 通过直接读取数据库表判断函数是否是RFC函数。
        /// </summary>
        /// <param name="pSystem"></param>
        /// <param name="pFunction"></param>
        /// <returns></returns>
        public static string CheckFunctionMode(string pSystem, String pFunction)
        {
            var _is_rfc = string.Empty;

            var _tfdir = new SAPINT.Utils.ReadTable(pSystem);
            _tfdir.TableName = "TFDIR";
            _tfdir.AddCriteria("FUNCNAME = '" + pFunction + "'");
            _tfdir.RowCount = 1;
            _tfdir.Run();
            var _tfdirResult = _tfdir.Result;
            if (_tfdirResult != null)
            {
                if (_tfdirResult.Rows.Count > 0)
                {
                    _is_rfc = _tfdirResult.Rows[0]["FMODE"].ToString();
                }
            }
            return _is_rfc;
        }
示例#4
0
        /// <summary>
        /// 根据IDOC编号把IDOC复制到本地。
        /// </summary>
        /// <param name="idocNumber">IDOC编号</param>
        /// <param name="SystemName">远程SAP系统名称</param>
        public void CopyIdocFromSAP(String idocNumber, String SystemName)
        {
            try
            {
                SAPINT.Utils.ReadTable idocReadItem = null;
                SAPINT.Utils.ReadTable idocReadHeader = null;
                SAPINT.Utils.ReadTable idocReadStatus = null;

                //DataTable dtIdocItem = new DataTable();
                //DataTable dtIdocHeder = new DataTable();
                //DataTable dtIdocStatus = new DataTable();

                idocNumber = idocNumber.TrimStart('0');
                String criteria = idocNumber.PadLeft(16, '0');
                criteria = String.Format("DOCNUM = '{0}'", criteria);

                String readTableFunction = ConfigFileTool.SAPGlobalSettings.GetReadTableFunction();

                idocReadItem = new SAPINT.Utils.ReadTable(SystemName);
                idocReadItem.TableName = "EDID4";
                idocReadItem.SetCustomFunctionName(readTableFunction);
                idocReadItem.AddCriteria(criteria);
                idocReadItem.Run();

                idocItem = idocReadItem.Result;

                if (idocItem.Rows.Count == 0)
                {
                    idocReadItem = new SAPINT.Utils.ReadTable(SystemName);
                    idocReadItem.TableName = "EDID2";
                    idocReadItem.SetCustomFunctionName(readTableFunction);
                    idocReadItem.AddCriteria(criteria);
                    idocReadItem.Run();
                    idocItem = idocReadItem.Result;

                }
                if (idocItem.Rows.Count == 0)
                {
                    idocReadItem = new SAPINT.Utils.ReadTable(SystemName);
                    idocReadItem.TableName = "EDIDD_OLD";
                    idocReadItem.SetCustomFunctionName(readTableFunction);
                    idocReadItem.AddCriteria(criteria);
                    idocReadItem.Run();
                    idocItem = idocReadItem.Result;
                }
                if (idocItem.Rows.Count == 0)
                {
                    throw new Exception(String.Format("无法找到IDOC{0}明细", idocNumber));
                }
                //读取IDOC头
                idocReadHeader = new SAPINT.Utils.ReadTable(SystemName);
                idocReadHeader.TableName = "EDIDC";
                idocReadHeader.SetCustomFunctionName(readTableFunction);
                idocReadHeader.AddCriteria(criteria);
                idocReadHeader.Run();
                idocHeader = idocReadHeader.Result;

                //if (idocHeader.Rows.Count != 1)
                //{
                //    throw new Exception(String.Format("无法找到IDOC{0}抬头定义", idocNumber));
                //}

                //读取IDOC状态
                idocReadStatus = new SAPINT.Utils.ReadTable(SystemName);
                idocReadStatus.TableName = "EDIDS";
                idocReadStatus.SetCustomFunctionName(readTableFunction);
                idocReadStatus.AddCriteria(criteria);
                idocReadStatus.Run();
                idocStatus = idocReadStatus.Result;

                SapTable idocTable = null;
                if (idocHeader.Rows.Count > 0)
                {
                    idocTable = new SapTable(SystemName, "EDIDC");
                    idocTable.DbConnectionString = this.ConnectionName;
                    idocTable.AppendToDb = AppendTodb;
                    idocTable.SaveDataTable(idocHeader);
                }

                if (idocItem.Rows.Count > 0)
                {
                    idocTable = new SapTable(SystemName, "EDID4", "EDID4");
                    idocTable.DbConnectionString = this.ConnectionName;
                    idocTable.AppendToDb = AppendTodb;
                    idocTable.SaveDataTable(idocItem);
                }

                if (idocStatus.Rows.Count > 0)
                {
                    idocTable = new SapTable(SystemName, "EDIDS");
                    idocTable.DbConnectionString = this.ConnectionName;
                    idocTable.AppendToDb = AppendTodb;
                    idocTable.SaveDataTable(idocStatus);

                }

            }
            catch (Exception)
            {

                throw;
            }
        }