示例#1
0
        /// <summary>
        /// 根据IDOC编号从SAP系统里读取一个idoc
        /// </summary>
        /// <param name="idocNumber"></param>
        /// <returns></returns>
        public Idoc GetIodcFromSapDataBase(String idocNumber)
        {
            SAPINT.Utils.ReadTable idocReadItem   = null;
            SAPINT.Utils.ReadTable idocReadHeader = null;
            DataTable dtIdocItem  = new DataTable();
            DataTable dtIdocHeder = 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 Utils.ReadTable(SystemName);
            idocReadItem.TableName = "EDID4";
            idocReadItem.SetCustomFunctionName(readTableFunction);
            idocReadItem.AddCriteria(criteria);
            idocReadItem.Run();
            dtIdocItem = idocReadItem.Result;

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

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

            Idoc idoc = ProcessSingleIdocFromDataTable(dtIdocHeder, dtIdocItem);

            return(idoc);
        }
示例#2
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);
        }
示例#3
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;
        }
示例#5
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;
            }
        }