Example #1
0
        /// <summary>
        /// 取得供應商(藝術家)主檔
        /// </summary>
        /// <param name="P_DATE_from">異動日期起始,yyyyMMdd</param>
        /// <param name="P_DATE_TO">異動日期迄止,yyyyMMdd</param>
        /// <param name="P_NAME1">藝術家名</param>
        /// <returns></returns>
        public static List <ET_VENDOR> GetSap_Z_MM_ZHAW_CUBE2(string P_DATE_from, string P_DATE_TO, string P_NAME1)
        {
            IDestinationConfiguration ID = new MyBackendConfig();
            IRfcTable IRetTable          = null;

            bool             bRegistered   = false;
            List <ET_VENDOR> ET_VENDORList = new List <ET_VENDOR>();

            try
            {
                RfcDestination rfcDest = null;
                try
                {
                    rfcDest     = RfcDestinationManager.GetDestination("PRD");
                    bRegistered = true;
                }
                catch (Exception ex)
                {
                    if (ex.GetType().Name == "RfcInvalidStateException")
                    {
                    }
                }
                finally
                {
                    if (rfcDest == null && bRegistered == false)
                    {
                        bRegistered = true;
                        RfcDestinationManager.RegisterDestinationConfiguration(ID);
                        rfcDest = RfcDestinationManager.GetDestination("PRD");
                    }
                }
                RfcRepository rfcRepo = rfcDest.Repository;
                IRfcFunction  IReader = rfcRepo.CreateFunction("Z_MM_ZHAW_CUBE2");
                IReader.SetValue("P_DATE_from", P_DATE_from);
                IReader.SetValue("P_DATE_TO", P_DATE_TO);
                IReader.SetValue("P_NAME1", P_NAME1);
                //每幾筆資料切成一個檔案
                //IReader.SetValue("COUNT", "1000");
                //執行查詢
                IReader.Invoke(rfcDest);
                IRetTable = IReader.GetTable("ET_VENDOR");

                ET_VENDORList = IRetTable.AsEnumerable().Select(x =>
                                                                new ET_VENDOR()
                {
                    NAME1 = x.GetString("NAME1"),
                    LIFNR = x.GetString("LIFNR"),
                    SORTL = x.GetString("SORTL"),
                    LAND1 = x.GetString("LAND1"),
                    ERDAT = x.GetString("ERDAT"),
                    UDATE = x.GetString("UDATE") ?? ""
                }).ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (bRegistered)
                {
                    RfcDestinationManager.UnregisterDestinationConfiguration(ID);
                }
            }

            return(ET_VENDORList);
        }
Example #2
0
        /// <summary>
        /// 取得商品(作品)主檔
        /// </summary>
        /// <param name="P_DATE_from">異動日期起始,yyyyMMdd</param>
        /// <param name="P_DATE_TO">異動日期迄止,yyyyMMdd</param>
        /// <param name="P_DESC">作品名</param>
        /// <param name="P_YEAR">年代,傳入格式%yyyy%yyyy%,兩個年份間,及前後加百分比</param>
        /// <param name="P_NAME1">作者名名</param>
        /// <returns></returns>
        public static List <ET_MASTER> GetSap_Z_MM_ZHAW_CUBE1(string P_DATE_from, string P_DATE_TO, string P_DESC = "", string P_YEAR = "", string P_NAME1 = "")
        {
            IDestinationConfiguration ID = new MyBackendConfig();
            IRfcTable IRetTable          = null;

            bool             bRegistered   = false;
            List <ET_MASTER> ET_MASTERList = new List <ET_MASTER>();

            try
            {
                RfcDestination rfcDest = null;
                try
                {
                    rfcDest     = RfcDestinationManager.GetDestination("PRD");
                    bRegistered = true;
                }
                catch (Exception ex)
                {
                    if (ex.GetType().Name == "RfcInvalidStateException")
                    {
                    }
                }
                finally
                {
                    if (rfcDest == null && bRegistered == false)
                    {
                        bRegistered = true;
                        RfcDestinationManager.RegisterDestinationConfiguration(ID);
                        rfcDest = RfcDestinationManager.GetDestination("PRD");
                    }
                }
                RfcRepository rfcRepo = rfcDest.Repository;
                IRfcFunction  IReader = rfcRepo.CreateFunction("Z_MM_ZHAW_CUBE1");
                IReader.SetValue("P_DATE_from", P_DATE_from);
                IReader.SetValue("P_DATE_TO", P_DATE_TO);
                IReader.SetValue("P_DESC", P_DESC);
                IReader.SetValue("P_YEAR", P_YEAR);
                IReader.SetValue("P_NAME1", P_NAME1);
                //每幾筆資料切成一個檔案
                //IReader.SetValue("COUNT", "1000");
                //執行查詢
                IReader.Invoke(rfcDest);
                IRetTable     = IReader.GetTable("ET_MASTER");
                ET_MASTERList = IRetTable.AsEnumerable().Select(x =>
                                                                new ET_MASTER()
                {
                    MATNR        = x.GetString("MATNR") ?? "",
                    ZZCT         = x.GetString("ZZCT") ?? "",
                    NAME1        = x.GetString("NAME1") ?? "",
                    ZFPRESERVE_D = x.GetString("ZFPRESERVE_D") ?? "",
                    ZZSE         = x.GetString("ZZSE") ?? "",
                    LOCATION     = x.GetString("LOCATION") ?? "",
                    STATUS       = x.GetString("STATUS") ?? "",
                    STPRS        = x.GetString("STPRS") ?? "",
                    NETPR        = x.GetString("NETPR") ?? "",
                    WAERS        = x.GetString("WAERS") ?? "",
                    ERDAT        = x.GetString("ERDAT") ?? "",
                    UDATE        = x.GetString("UDATE") ?? ""
                }).ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (bRegistered)
                {
                    RfcDestinationManager.UnregisterDestinationConfiguration(ID);
                }
            }

            return(ET_MASTERList);
        }