コード例 #1
0
        static SapConn()
        {
            XmlDocument doc     = new XmlDocument();
            string      XmlName = "DllConfig.xml";

            doc.Load(XmlName);
            rfcCfg.Add(RfcConfigParameters.Name,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("CONN")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.AppServerHost,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("ASHOST")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.Client,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("CLIENT")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.User,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("USER")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.Password,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("PASSWD")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.SystemNumber,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("SYSNR")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.Language,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("LANG")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.PoolSize,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("POOL_SIZE")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.IdleTimeout,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("TIMEOUT")).GetAttribute("Name").ToString());
            rfcCfg.Add(RfcConfigParameters.LogonGroup,
                       ((XmlElement)doc.SelectSingleNode("AutoCreate").SelectSingleNode("ClientSettings").SelectSingleNode("GROUP")).GetAttribute("Name").ToString());
            destination = RfcDestinationManager.GetDestination(rfcCfg);
        }
コード例 #2
0
        public static string RFCxSociedad(string xname, string appsh, string xsapr, string sysn, string xuser, string pasw, string cliente, string sociedad)
        {
            RfcConfigParameters parms = new RfcConfigParameters();

            parms.Add(RfcConfigParameters.Name, xname);
            parms.Add(RfcConfigParameters.AppServerHost, appsh);
            parms.Add(RfcConfigParameters.SAPRouter, xsapr.ToString().Trim());
            parms.Add(RfcConfigParameters.SystemNumber, sysn.ToString().Trim());
            parms.Add(RfcConfigParameters.User, xuser.ToString().Trim());
            parms.Add(RfcConfigParameters.Password, pasw.ToString().Trim());
            parms.Add(RfcConfigParameters.Client, cliente.ToString().Trim());
            parms.Add(RfcConfigParameters.Language, "ES");
            parms.Add(RfcConfigParameters.PoolSize, "5");
            parms.Add(RfcConfigParameters.PeakConnectionsLimit, "10");
            parms.Add(RfcConfigParameters.PoolIdleTimeout, "600");

            RfcDestination rfcDest = null;

            rfcDest = RfcDestinationManager.GetDestination(parms);
            RfcRepository repo     = rfcDest.Repository; //Crea repositorio para la función
            IRfcFunction  conexion = repo.CreateFunction("Z_URFC");

            conexion.SetValue("SOCIEDAD", sociedad);
            conexion.Invoke(rfcDest);                  //Se ejecuta la consulta
            //string xresul = conexion.GetString("RFC");
            return(conexion.GetString("RFC"));
        }
コード例 #3
0
ファイル: SAPRFC.cs プロジェクト: chittasn/SpoWebApi
        /// <summary>
        ///  To get the list of Products
        /// </summary>
        ///
        public List <SIISAPProdDTO> GetProducts()
        {
            List <SIISAPProdDTO> objProdutsList = new List <SIISAPProdDTO>();
            var rfcDestination = RfcDestinationManager.GetDestination("SIISAP");

            try
            {
                if (rfcDestination != null)
                {
                    var getARNRfc = rfcDestination.Repository.CreateFunction("ZEHS_MSDS_PRTL_F4_PROD");
                    RfcSessionManager.BeginContext(rfcDestination);
                    getARNRfc.Invoke(rfcDestination);
                    var GetProductsTable = getARNRfc.GetTable("PRODS");



                    foreach (var row in GetProductsTable)
                    {
                        objProdutsList.Add(new SIISAPProdDTO {
                            Product = row[0].ToString().Substring(row[0].ToString().IndexOf("=") + 1)
                        });
                        var listinfo = objProdutsList;
                    }
                    RfcSessionManager.EndContext(rfcDestination);
                    rfcDestination = null;
                }
            }
            catch (Exception ex)
            {
                FilePath = ConfigurationManager.AppSettings["siteUrl"];
                WriteLog(FilePath, ex.Message);
            }

            return(objProdutsList);
        }
コード例 #4
0
ファイル: BATCH.cs プロジェクト: radtek/QM
        public RfcDestination GetDestination()
        {
            //RfcDestination dest = RfcDestinationManager.GetDestination("PRD");
            RfcDestination dest = RfcDestinationManager.GetDestination("QAS");

            return(dest);
        }
コード例 #5
0
        private void loginbtn_Click(object sender, EventArgs e)
        {
            try
            {
                Connection.rfcDestination = RfcDestinationManager.GetDestination("costCenter");
                connectionlbl.Text        = "connecting ...";
                connectionlbl.BackColor   = Color.Transparent;
                this.Refresh();

                Connection.rfcDestination.Ping();
                connectionlbl.Text = "connected";
                this.Hide();
                new Overview().ShowDialog();
                this.Close();
            }
            catch (SAP.Middleware.Connector.RfcLogonException ex)
            {
                Infolabel.Text = ex.Message;
                Console.WriteLine(ex.Message);
                connectionlbl.Text      = "failed";
                connectionlbl.BackColor = Color.Red;
            }
            catch (Exception e1)
            {
                Console.WriteLine(e1.Message);
                connectionlbl.Text      = "failed";
                connectionlbl.BackColor = Color.Red;
            }
        }
コード例 #6
0
        public void RegisterDestination()  //注册客户端
        {
            try
            {
                if (_rfcDestination == null)
                {
                    //rfc配置
                    //RfcConfigParameters argsP = new RfcConfigParameters();
                    //argsP.Add(RfcConfigParameters.Name, ConfigurationManager.AppSettings["Name"].ToString());
                    //argsP.Add(RfcConfigParameters.AppServerHost, ConfigurationManager.AppSettings["AppServerHost"].ToString());
                    //argsP.Add(RfcConfigParameters.SystemNumber, ConfigurationManager.AppSettings["SystemNumber"].ToString());
                    //argsP.Add(RfcConfigParameters.User, ConfigurationManager.AppSettings["User"].ToString());
                    //argsP.Add(RfcConfigParameters.Password, ConfigurationManager.AppSettings["Password"].ToString());
                    //argsP.Add(RfcConfigParameters.Client, ConfigurationManager.AppSettings["Client"].ToString());
                    //argsP.Add(RfcConfigParameters.Language, ConfigurationManager.AppSettings["Language"].ToString());
                    //argsP.Add(RfcConfigParameters.PoolSize, ConfigurationManager.AppSettings["PoolSize"].ToString());
                    ////argsP.Add(RfcConfigParameters.LogonGroup, ConfigurationManager.AppSettings["GROUP"].ToString());
                    //argsP.Add(RfcConfigParameters.MaxPoolSize, ConfigurationManager.AppSettings["MaxPoolSize"].ToString());
                    //argsP.Add(RfcConfigParameters.IdleTimeout, ConfigurationManager.AppSettings["IdleTimeout"].ToString());

                    //_rfcDestination = RfcDestinationManager.GetDestination(argsP);
                    // 直接读取app.config中的节点中的数据
                    _rfcDestination = RfcDestinationManager.GetDestination(ConfigurationManager.AppSettings["Name"].ToString());
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("获取RfcDestination出错" + ex.Message);
            }
        }
コード例 #7
0
        public void tablePlants()
        {
            connect();
            RfcDestination rfcDest = RfcDestinationManager.GetDestination(parms);
            RfcRepository  rfcRep  = rfcDest.Repository;
            IRfcFunction   IReader = rfcRep.CreateFunction("ZSSCN_DYNAMIC_SELECT");

            IReader.SetValue("IV_SELECT", "USERID PLANT");
            IReader.SetValue("IV_FROM", "/SSCN/PLANT");
            IReader.SetValue("IV_WHERE", "USERID = 'SIGGA127'");
            IReader.Invoke(rfcDest);
            string optionData = (string)IReader.GetValue("EV_RESULT_SET");

            Directory.CreateDirectory("Relatorio");
            filePathTxt = filePathTxt + @"\pathPlant.txt";
            System.IO.File.WriteAllText(filePathTxt, optionData);
            List <IndividualCapacity_SapTable> jsonList = JsonConvert.DeserializeObject <List <IndividualCapacity_SapTable> >(optionData);

            if (jsonList.Count() > 0)
            {
                //file
                CreateExcel = new IndividualCapacity_PlantExcel();
                CreateExcel.CreateWorkbook(filePathXlsx = filePathXlsx + @"\DadosPlant.xlsx");
                //Adicionar Celulas
                jsonList
                .Select((mandante, x) => new { mandante, position = x })
                .ToList()
                .ForEach(item => CreateExcel.AddCell(item.position, item.mandante));
                //Salvando dados no excel
                CreateExcel.Save();
            }
        }
コード例 #8
0
        public void tableLList(string lista)
        {
            RfcDestination rfcDest = RfcDestinationManager.GetDestination(parms);
            RfcRepository  rfcRep  = rfcDest.Repository;
            IRfcFunction   IReader = rfcRep.CreateFunction("ZSSCN_DYNAMIC_SELECT");

            IReader.SetValue("IV_SELECT", "*"); // pegar todas as tabelas
            IReader.SetValue("IV_FROM", "/SSCN/LLIST");
            IReader.SetValue("IV_WHERE", "NOME_LISTA = 'CENTRO_TRAB' AND CENTRO IN (" + lista + ") AND EXTRA_FLD3 = 'X' AND IDIOMA = 'EN'");
            IReader.SetValue("IV_ORDER", "COD_ITEM DESCRICAO");
            IReader.Invoke(rfcDest);
            string optionData = (string)IReader.GetValue("EV_RESULT_SET");

            Directory.CreateDirectory("Relatorio");
            string path = Path.GetFullPath("Relatorio/pathLList.txt");

            System.IO.File.WriteAllText(path, optionData);
            List <Schedule_SapTable> jsonList = JsonConvert.DeserializeObject <List <Schedule_SapTable> >(optionData);

            if (jsonList.Count() > 0)
            {
                //file
                CreateExcel2 = new Schedule_LListExcel();
                CreateExcel2.CreateWorkbook("Relatorio/DadosLList.xlsx");
                //Adicionar Celulas
                jsonList
                .Select((mandante, x) => new { mandante, position = x })
                .ToList()
                .ForEach(item => CreateExcel2.AddCell(item.position, item.mandante));
                //Salvando dados no excel
                CreateExcel2.Save();
            }
        }
コード例 #9
0
        public void tableAssetGroupAmPerson(string pernr)
        {
            connect();
            RfcDestination rfcDest = RfcDestinationManager.GetDestination(parms);
            RfcRepository  rfcRep  = rfcDest.Repository;
            IRfcFunction   IReader = rfcRep.CreateFunction("ZSSCN_DYNAMIC_SELECT");

            IReader.SetValue("IV_SELECT", "A~PERNR A~AM_KEY_TYPE A~AM_KEY B~EQKTX C~PLTXT A~AM_KN A~EXP_EQUI");
            IReader.SetValue("IV_FROM", "/SSCN/AM_PERSON AS A LEFT JOIN /SSCN/LEQP_T AS B ON ( A~AM_KEY = B~EQUNR AND B~SPRAS = 'EN' ) LEFT JOIN /SSCN/LFUN_LOC_T AS C ON(A~AM_KEY = C~TPLNR AND C~SPRAS = 'EN')");
            IReader.SetValue("IV_WHERE", "A~AM_TYPE = '3' AND A~PERNR = '100029'");
            IReader.SetValue("IV_ORDER", "A~AM_KEY_TYPE A~AM_KEY");
            IReader.Invoke(rfcDest);
            string optionData = (string)IReader.GetValue("EV_RESULT_SET");

            Directory.CreateDirectory("Relatorio");
            filePathTxt = filePathTxt + @"\pathAGLPerson.txt";
            System.IO.File.WriteAllText(filePathTxt, optionData);
            List <AbilityMatrix_SapTable> jsonList = JsonConvert.DeserializeObject <List <AbilityMatrix_SapTable> >(optionData);

            if (jsonList.Count() > 0)
            {
                //file
                CreateExcel2 = new AbilityMatrix_AssetGroup_AmPersonExcel();
                CreateExcel2.CreateWorkbook(filePathXlsx = filePathXlsx + @"\DadosAgAmPerson.xlsx");
                //Adicionar Celulas
                jsonList
                .Select((mandante, x) => new { mandante, position = x })
                .ToList()
                .ForEach(item => CreateExcel1.AddCell(item.position, item.mandante));
                //Salvando dados no excel
                CreateExcel2.Save();
            }
        }
コード例 #10
0
        public void tableParam()
        {
            connect();
            RfcDestination rfcDest = RfcDestinationManager.GetDestination(parms);
            RfcRepository  rfcRep  = rfcDest.Repository;
            IRfcFunction   IReader = rfcRep.CreateFunction("ZSSCN_DYNAMIC_SELECT");

            IReader.SetValue("IV_SELECT", "FIRST_DAY_WEEK SCHED_VALID_TIME");
            IReader.SetValue("IV_FROM", "/SSCN/PARAM");
            IReader.Invoke(rfcDest);
            string optionData = (string)IReader.GetValue("EV_RESULT_SET");

            Directory.CreateDirectory("Relatorio");
            string path = Path.GetFullPath("Relatorio/pathParam.txt");

            System.IO.File.WriteAllText(path, optionData);
            List <Schedule_SapTable> jsonList = JsonConvert.DeserializeObject <List <Schedule_SapTable> >(optionData);

            if (jsonList.Count() > 0)
            {
                //file
                CreateExcel7 = new Schedule_ParamExcel();
                CreateExcel7.CreateWorkbook("Relatorio/DadosParam.xlsx");
                //Adicionar Celulas
                jsonList
                .Select((mandante, x) => new { mandante, position = x })
                .ToList()
                .ForEach(item => CreateExcel7.AddCell(item.position, item.mandante));
                //Salvando dados no excel
                CreateExcel7.Save();
            }
        }
コード例 #11
0
        public void tableLperWkc()
        {
            connect();
            RfcDestination rfcDest = RfcDestinationManager.GetDestination(parms);
            RfcRepository  rfcRep  = rfcDest.Repository;
            IRfcFunction   IReader = rfcRep.CreateFunction("ZSSCN_DYNAMIC_SELECT");

            IReader.SetValue("IV_SELECT", "PERNR ENDDA");
            IReader.SetValue("IV_FROM", "/SSCN/LPER_WKC");
            IReader.SetValue("IV_WHERE", "ARBPL = 'PSQA-AUT' AND WERKS = '1000'");
            IReader.Invoke(rfcDest);
            string optionData = (string)IReader.GetValue("EV_RESULT_SET");

            Directory.CreateDirectory("Relatorio");
            string path = Path.GetFullPath("Relatorio/pathLperWkc.txt");

            System.IO.File.WriteAllText(path, optionData);
            List <Schedule_SapTable> jsonList = JsonConvert.DeserializeObject <List <Schedule_SapTable> >(optionData);

            if (jsonList.Count() > 0)
            {
                //file
                CreateExcel8 = new Schedule_LperWkcExcel();
                CreateExcel8.CreateWorkbook("Relatorio/DadosLperWkc.xlsx");
                //Adicionar Celulas
                jsonList
                .Select((mandante, x) => new { mandante, position = x })
                .ToList()
                .ForEach(item => CreateExcel8.AddCell(item.position, item.mandante));
                //Salvando dados no excel
                CreateExcel8.Save();
            }
        }
コード例 #12
0
        public void tableLoper(string nome)
        {
            connect();
            RfcDestination rfcDest = RfcDestinationManager.GetDestination(parms);
            RfcRepository  rfcRep  = rfcDest.Repository;
            IRfcFunction   IReader = rfcRep.CreateFunction("ZSSCN_DYNAMIC_SELECT");

            IReader.SetValue("IV_SELECT", "ORDERID ACTIVITY SUB_ACTIVITY CONTROL_KEY WORK_CNTR PLANT DESCRIPTION SYSTCOND FUNCLOC EQUIPMENT EARL_SCH_START_D EARL_SCH_START_T");
            IReader.SetValue("IV_FROM", "/SSCN/LOPER");
            IReader.SetValue("IV_WHERE", "WORK_CNTR = '" + nome + "'");
            IReader.Invoke(rfcDest);
            string optionData = (string)IReader.GetValue("EV_RESULT_SET");

            Directory.CreateDirectory("Relatorio");
            string path = Path.GetFullPath("Relatorio/pathLoper.txt");

            System.IO.File.WriteAllText(path, optionData);
            List <Schedule_SapTable> jsonList = JsonConvert.DeserializeObject <List <Schedule_SapTable> >(optionData);

            if (jsonList.Count() > 0)
            {
                //file
                CreateExcel6 = new Schedule_LoperExcel();
                CreateExcel6.CreateWorkbook("Relatorio/DadosLoper.xlsx");
                //Adicionar Celulas
                jsonList
                .Select((mandante, x) => new { mandante, position = x })
                .ToList()
                .ForEach(item => CreateExcel6.AddCell(item.position, item.mandante));
                //Salvando dados no excel
                CreateExcel6.Save();
            }
        }
コード例 #13
0
        public void tableBLPlan(string name)
        {
            connect();
            RfcDestination rfcDest = RfcDestinationManager.GetDestination(parms);
            RfcRepository  rfcRep  = rfcDest.Repository;
            IRfcFunction   IReader = rfcRep.CreateFunction("ZSSCN_DYNAMIC_SELECT");

            IReader.SetValue("IV_SELECT", "PLANNING_ID DESCRICAO DATA_INICIAL DATA_FINAL VALIDADE_DE VALIDADE_ATE");
            IReader.SetValue("IV_FROM", "/SSCN/BL_PLAN");
            IReader.SetValue("IV_WHERE", "DESCRICAO = '" + name + "'");
            IReader.Invoke(rfcDest);
            string optionData = (string)IReader.GetValue("EV_RESULT_SET");

            Directory.CreateDirectory("Relatorio");
            string path = Path.GetFullPath("Relatorio/pathBLPlan.txt");

            System.IO.File.WriteAllText(path, optionData);
            List <Schedule_SapTable> jsonList = JsonConvert.DeserializeObject <List <Schedule_SapTable> >(optionData);

            if (jsonList.Count() > 0)
            {
                //file
                CreateExcel3 = new Schedule_BLPlanExcel();
                CreateExcel3.CreateWorkbook("Relatorio/DadosBLPlan.xlsx");
                //Adicionar Celulas
                jsonList
                .Select((mandante, x) => new { mandante, position = x })
                .ToList()
                .ForEach(item => CreateExcel3.AddCell(item.position, item.mandante));
                //Salvando dados no excel
                CreateExcel3.Save();
            }
        }
コード例 #14
0
        public List <string> Get_Z_RFC_GD_DELIVERY(string I_VBELN)
        {
            List <string> LsMsg = new List <string>();

            try
            {
                RfcDestination destination = RfcDestinationManager.GetDestination(this.GetCfgParameters());
                IRfcFunction   rfcFunction = destination.Repository.CreateFunction("Z_RFC_GD_DELIVERY");
                rfcFunction.SetValue("I_VBELN", I_VBELN);
                rfcFunction.Invoke(destination);

                IRfcStructure E_RETURN  = rfcFunction.GetStructure("E_RETURN");
                string        SAP_TYPE  = E_RETURN.GetValue("TYPE").ToString(); //是否成功 S 表示成功
                string        SAP_E_ID  = E_RETURN.GetValue("ID").ToString();
                string        SAP_E_NUM = E_RETURN.GetValue("NUMBER").ToString();
                string        SAP_MSG   = E_RETURN.GetValue("MESSAGE").ToString();
                LsMsg.Add(SAP_TYPE);
                LsMsg.Add(SAP_E_ID);
                LsMsg.Add(SAP_E_NUM);
                LsMsg.Add(SAP_MSG);
            }
            catch (Exception ex)
            {
                LsMsg.Add("ERR:" + ex.Message);
            }

            return(LsMsg);
        }
コード例 #15
0
        public static Destination GetDestination(RfcConfigParameters configParameters)
        {
            string serverKey = ServerConfiguration.AddServerDestination(configParameters);

            lock (serverConfigurationRegistrationLock) {
                if (!serverConfigurationRegistered)
                {
                    RfcDestinationManager.RegisterDestinationConfiguration(new ServerConfiguration());
                    serverConfigurationRegistered = true;
                }
            }

            if (ServerConfiguration.HasServerKey(serverKey))
            {
                Destination destination = new Destination()
                {
                    InUse          = true,
                    InUseSince     = DateTime.Now,
                    ServerKey      = serverKey,
                    Suffix         = String.Empty,
                    RfcDestination = RfcDestinationManager.GetDestination(serverKey)
                };

                return(destination);
            }

            return(null);
        }
コード例 #16
0
        public void RegisterDestination(string destinationName)
        {
            bool destinationIsInialised = ((_rfcDestination != null) && string.Equals(_rfcDestination.Name, destinationName));

            // Only register if not already initialised
            try
            {
                // ? destinantion already configured and initialised
                if (!destinationIsInialised)
                {
                    RfcDestinationManager.RegisterDestinationConfiguration(new SAPIDocDestinationConfiguration(destinationName));//1

                    _rfcDestination = RfcDestinationManager.GetDestination(destinationName);
                }
            }
            // ignore as destination already configured
            catch (RfcInvalidStateException rfcEx)
            {
                // cascade up callstack
                throw rfcEx;
            }


            //System.Diagnostics.Trace.WriteLine(
            //    String.Format("Destination Confgured to:{0}", _rfcDestination.Monitor.OriginDestinationID));
        }
コード例 #17
0
        public IRfcTable Rfc_Del_Dal(RFC_DEL_Model delModel, out RFC_IN_Message rfcMessage)
        {
            rfcMessage = new RFC_IN_Message();
            try
            {
                _configurationId = new RFC_SetUp();
                RfcDestinationManager.RegisterDestinationConfiguration(_configurationId);
                _dest       = RfcDestinationManager.GetDestination("SAPMS");
                _repository = _dest.Repository;
                IRfcFunction rfc   = _repository.CreateFunction(delModel.FunctionModule); //调用函数名
                IRfcTable    table = rfc.GetTable(delModel.E_SAP_DEL);                    //RFC表数据
                rfc.SetValue("I_MESKEY", delModel.I_MESKEY);                              //KEY随机号 不能重复
                rfc.SetValue("I_DATE", delModel.I_DATE);                                  //日期
                rfc.SetValue("I_TIME", delModel.I_TIME);                                  //时间
                rfc.SetValue("I_USER", delModel.I_USER);                                  //登录名
                rfc.SetValue("I_VBELN", delModel.I_VBELN);
                rfc.Invoke(_dest);

                rfcMessage.E_RETURN_CODE = rfc.GetString("E_RETURN_CODE").ToString();
                //rfcMessage.E_RETURN_MESSAGE = rfc.GetString("E_RETURN_MESSAGE").ToString();
                rfcMessage.E_COUNT = rfc.GetInt("E_COUNT").ToString();
                rfcMessage.E_SUM   = rfc.GetInt("E_SUM").ToString();
                return(table);
            }
            catch (Exception exception)
            {
                rfcMessage.E_RETURN_MESSAGE = "接口DEL 错误:" + exception.ToString();
                return(null);
            }
            finally
            {
                RfcDestinationManager.UnregisterDestinationConfiguration(_configurationId);
            }
        }
コード例 #18
0
        public DataSet EP_MATERIALES(string destinationname, string codigo_material)
        {
            DataSet material = new DataSet();

            try
            {
                if (RfcDestination == null)
                {
                    RfcDestination = RfcDestinationManager.GetDestination(destinationname);
                }



                //CODIGO MERO BUENO
                RfcRepository rfcRepository = RfcDestination.Repository;
                IRfcFunction  rfcfunction   = rfcRepository.CreateFunction("ZRFC_MATERIAL");
                rfcfunction.SetValue("I_MATERIAL", codigo_material);
                rfcfunction.Invoke(RfcDestination);
                material.Tables.Add(ConvertToDotNetTable(rfcfunction.GetTable("EP_MATERIALES")));
                string descripcion = rfcfunction.GetString("EP_DESCRIPCION");
                string EP_ERROR    = rfcfunction.GetString("EP_ERROR");
                string EP_MENSAJE  = rfcfunction.GetString("EP_MENSAJE");
                //FIN CODIGO MERO BUENO
            }
            catch (Exception ex)
            {
                throw new Exception("ERROR " + ex.Message);
            }
            return(material);
        }
コード例 #19
0
        public void tableLPer_Wkc(string plant, string workcenter)
        {
            connect();
            RfcDestination rfcDest = RfcDestinationManager.GetDestination(parms);
            RfcRepository  rfcRep  = rfcDest.Repository;
            IRfcFunction   IReader = rfcRep.CreateFunction("ZSSCN_DYNAMIC_SELECT");

            IReader.SetValue("IV_SELECT", "A~PERNR A~ENAME");
            IReader.SetValue("IV_FROM", "/SSCN/LPERSON AS A INNER JOIN /SSCN/LPER_WKC AS B ON ( A~PERNR = B~PERNR )");
            IReader.SetValue("IV_WHERE", "B~WERKS = '" + plant + "' AND B~ARBPL = '" + workcenter + "'");
            IReader.Invoke(rfcDest);
            string optionData = (string)IReader.GetValue("EV_RESULT_SET");

            Directory.CreateDirectory("Relatorio");
            filePathTxt = filePathTxt + @"\pathLPerWkc.txt";
            System.IO.File.WriteAllText(filePathTxt, optionData);
            List <IndividualCapacity_SapTable> jsonList = JsonConvert.DeserializeObject <List <IndividualCapacity_SapTable> >(optionData);

            if (jsonList.Count() > 0)
            {
                //file
                CreateExcel3 = new IndividualCapacity_LperWkcExcel();
                CreateExcel3.CreateWorkbook(filePathXlsx = filePathXlsx + @"\DadosLPerWkc.xlsx");
                //Adicionar Celulas
                jsonList
                .Select((mandante, x) => new { mandante, position = x })
                .ToList()
                .ForEach(item => CreateExcel3.AddCell(item.position, item.mandante));
                //Salvando dados no excel
                CreateExcel3.Save();
            }
        }
コード例 #20
0
        public DataSet RetrieveSociety(string sociedad, string destinationName)
        {
            DataSet dsSociedad = new DataSet();

            try
            {
                if (RfcDestination == null)
                {
                    RfcDestination = RfcDestinationManager.GetDestination(destinationName);
                }
                RfcRepository rfcRepository = RfcDestination.Repository;
                IRfcFunction  rfcFunction   = rfcRepository.CreateFunction("ZRFC_SOCIEDAD_CENTRO_ALMACEN");
                rfcFunction.SetValue("BUKRS", sociedad);

                rfcFunction.Invoke(RfcDestination);
                IRfcStructure sociedadesData = rfcFunction.GetStructure("BUTXT");
                RfcDestination.Repository.GetTableMetadata("ZRFC_SOCIEDAD_CENTRO_ALMACEN").CreateTable();
                IRfcTable SociedadesSummary = sociedadesData.GetTable("ET_SOCIEDADES");
                dsSociedad.Tables.Add(ConvertToDotNetTable(SociedadesSummary));
                ShowFunction(rfcFunction);
            }
            catch (Exception ex)
            {
                throw new Exception("RetrieveSociety Error: " + ex.Message);
            }
            return(dsSociedad);
        }
コード例 #21
0
        public void tableLList(string plant)
        {
            connect();
            RfcDestination rfcDest = RfcDestinationManager.GetDestination(parms);
            RfcRepository  rfcRep  = rfcDest.Repository;
            IRfcFunction   IReader = rfcRep.CreateFunction("ZSSCN_DYNAMIC_SELECT");

            IReader.SetValue("IV_SELECT", "COD_ITEM DESCRICAO");
            IReader.SetValue("IV_FROM", "/SSCN/LLIST");
            IReader.SetValue("IV_WHERE", "NOME_LISTA = 'CENTRO_TRAB' AND CENTRO = '" + plant + "' AND EXTRA_FLD3 = 'X' AND IDIOMA = 'EN'");
            IReader.SetValue("IV_ORDER", "COD_ITEM DESCRICAO");
            IReader.Invoke(rfcDest);
            string optionData = (string)IReader.GetValue("EV_RESULT_SET");

            Directory.CreateDirectory("Relatorio");
            filePathTxt = filePathTxt + @"\pathLList.txt";
            System.IO.File.WriteAllText(filePathTxt, optionData);
            List <IndividualCapacity_SapTable> jsonList = JsonConvert.DeserializeObject <List <IndividualCapacity_SapTable> >(optionData);

            if (jsonList.Count() > 0)
            {
                //file
                CreateExcel1 = new IndividualCapacity_LListExcel();
                CreateExcel1.CreateWorkbook(filePathXlsx = filePathXlsx + @"\DadosLList.xlsx");
                //Adicionar Celulas
                jsonList
                .Select((mandante, x) => new { mandante, position = x })
                .ToList()
                .ForEach(item => CreateExcel1.AddCell(item.position, item.mandante));
                //Salvando dados no excel
                CreateExcel1.Save();
            }
        }
コード例 #22
0
        static EmployeeEntityService()
        {
            SAPSystemConnectMy sapCfg = new SAPSystemConnectMy();

            RfcDestinationManager.RegisterDestinationConfiguration(sapCfg);
            rfcDest = RfcDestinationManager.GetDestination("K47");
        }
コード例 #23
0
        public bool conectar()
        {
            RfcConfigParameters oParametros = new RfcConfigParameters();

            oParametros.Add(RfcConfigParameters.Name, sapName);
            oParametros.Add(RfcConfigParameters.User, sapUser);
            oParametros.Add(RfcConfigParameters.Password, sapPass);
            oParametros.Add(RfcConfigParameters.Client, sapClient);
            //oParametros.Add(RfcConfigParameters.Language, "EN");
            oParametros.Add(RfcConfigParameters.Language, "ES");
            oParametros.Add(RfcConfigParameters.AppServerHost, sapServer);
            oParametros.Add(RfcConfigParameters.SystemNumber, sapNumber);
            if (!sapRouter.Equals("") && !sapRouter.Equals(null))
            {
                oParametros.Add(RfcConfigParameters.SAPRouter, sapRouter);
            }
            if (!sapID.Equals("") && !sapID.Equals(null))
            {
                oParametros.Add(RfcConfigParameters.SystemID, sapID);
            }
            oParametros.Add(RfcConfigParameters.PoolSize, "5");

            oDestino = RfcDestinationManager.GetDestination(oParametros);

            try
            {
                oDestino.Ping();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }
            return(true);
        }
コード例 #24
0
ファイル: Rfc_Frota.cs プロジェクト: wellgsousa/fontes
 public Rfc_Frota()
 {
     try
     {
         SAPConnect objcon = new SAPConnect();
         RfcDestinationManager.RegisterDestinationConfiguration(objcon);
         dest = RfcDestinationManager.GetDestination("Frota");
         repo = dest.Repository;
         RfcDestinationManager.UnregisterDestinationConfiguration(objcon);
     }
     catch (RfcCommunicationException e)
     {
         throw e;
     }
     catch (RfcLogonException e)
     {
         throw e;
     }
     catch (RfcAbapRuntimeException e)
     {
         throw e;
     }
     catch (RfcAbapBaseException e)
     {
         throw e;
     }
 }
コード例 #25
0
        public responce_ZMOV_10000 sapRun(request_ZMOV_10000 import)
        {
            RfcDestination configSap        = RfcDestinationManager.GetDestination("SCLEM");
            RfcRepository  SapRfcRepository = configSap.Repository;
            IRfcFunction   rfcFunction      = SapRfcRepository.CreateFunction("ZMOV_10000");

            rfcFunction.SetValue("CHARG", import.CHARG);
            rfcFunction.SetValue("MATNR", import.MATNR);
            rfcFunction.Invoke(configSap);
            string aa = rfcFunction.ToString();
            responce_ZMOV_10000 res = new responce_ZMOV_10000();
            IRfcTable           rfcTable_CHAR_OF_BATCH = rfcFunction.GetTable("CHAR_OF_BATCH");

            res.CHAR_OF_BATCH = new ZMOV_10000_CHAR_OF_BATCH[rfcTable_CHAR_OF_BATCH.RowCount];
            int i_CHAR_OF_BATCH = 0;

            foreach (IRfcStructure row in rfcTable_CHAR_OF_BATCH)
            {
                ZMOV_10000_CHAR_OF_BATCH datoTabla = new ZMOV_10000_CHAR_OF_BATCH();
                datoTabla.ATNAM                    = row.GetString("ATNAM");
                datoTabla.ATWTB                    = row.GetString("ATWTB");
                datoTabla.XDELETE                  = row.GetString("XDELETE");
                datoTabla.CHAR_NOT_VALID           = row.GetString("CHAR_NOT_VALID");
                datoTabla.ATINN                    = row.GetInt("ATINN");
                datoTabla.ATWTB_LONG               = row.GetString("ATWTB_LONG");
                res.CHAR_OF_BATCH[i_CHAR_OF_BATCH] = datoTabla; ++i_CHAR_OF_BATCH;
            }

            return(res);
        }
コード例 #26
0
 /// <summary>
 /// 初始化SAP连接
 /// </summary>
 /// <returns></returns>
 private static void InitialRfcDestination()
 {
     if (destination == null)
     {
         destination = RfcDestinationManager.GetDestination(GetRfcConfigParameters());
     }
 }
コード例 #27
0
        public InvoiceValueModel GetInvoiceValue(RfcDestination rfcDest)
        {
            InvoiceValueModel invoiceValueModel = new InvoiceValueModel();
            RfcDestination    SAPRfcDestination = RfcDestinationManager.GetDestination("accelyides");

            RfcRepository rfcrep = SAPRfcDestination.Repository;
            IRfcFunction  BapiGetCompanyDetail = null;


            BapiGetCompanyDetail = rfcrep.CreateFunction("BAPI_INCOMINGINVOICE_GETDETAIL");
            BapiGetCompanyDetail.SetValue("INVOICEDOCNUMBER", "1000000020");
            BapiGetCompanyDetail.SetValue("FISCALYEAR", "2013");
            BapiGetCompanyDetail.Invoke(rfcDest);
            IRfcTable tblReturn = BapiGetCompanyDetail.GetTable("ITEMDATA");
            DataTable TBL       = tblReturn.ToDataTable("TBL");

            for (int i = 0; i < TBL.Rows.Count; i++)
            {
                InvoiceValueModel invoiceValueModel1 = new InvoiceValueModel();

                invoiceValueModel1.REF_DOC = TBL.Rows[i]["REF_DOC"].ToString();
                // invoiceValueModel.lstInvoiceValue.Add(invoiceValueModel1);
            }

            IRfcStructure IRS_OS_HEADER = BapiGetCompanyDetail.GetStructure("HEADERDATA");

            invoiceValueModel.Value = IRS_OS_HEADER.GetValue("USERNAME").ToString();
            //Console.WriteLine(invoiceValueModel.Value);
            //Console.ReadKey();
            RfcSessionManager.EndContext(rfcDest);

            return(invoiceValueModel);
        }
コード例 #28
0
        /// <summary>
        /// 测试连接SAP
        /// </summary>
        /// <returns></returns>
        public bool ConnSap(out string message)
        {
            bool result = false;

            try
            {
                IDestinationConfiguration ID = new RFC_SetUp();
                RfcDestinationManager.RegisterDestinationConfiguration(ID);
                RfcDestination destination = RfcDestinationManager.GetDestination("SAPMS");
                RfcRepository  repository  = destination.Repository;
                IRfcFunction   rfcFunction = repository.CreateFunction("Z_TEST_CONNECTION");
                rfcFunction.Invoke(destination);
                message = rfcFunction.GetValue("E_RETURN_MESSAGE").ToString();
                result  = !(rfcFunction.GetValue("E_RETURN_CODE").ToString() == "E");
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            finally
            {
                RfcDestinationManager.UnregisterDestinationConfiguration(ID);
            }
            return(result);
        }
コード例 #29
0
        public void InitSAP()
        {
            try
            {
                IDestinationConfiguration destinationConfig = null;

                destinationConfig = new SAPDestinationConfig();
                destinationConfig.GetParameters(_destinationName);

                bool destinationFound = false;

                try
                {
                    destinationFound = (RfcDestinationManager.GetDestination(_destinationName) != null);
                }
                catch
                {
                    destinationFound = false;
                }

                if (!destinationFound)
                {
                    RfcDestinationManager.RegisterDestinationConfiguration(destinationConfig);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Errore di inizializzazione RfcDestination", e);
            }
        }
コード例 #30
0
ファイル: SapHelper.cs プロジェクト: tomsong2016/WMSInterface
 public static string SendToSAP500(string requestXML)
 {
     try
     {
         string strRes = "";//res.ZfmServiceResponse.EvResponse;
         RfcConfigParameters rfcPar = new RfcConfigParameters();
         rfcPar.Add(RfcConfigParameters.Name, "MSQ");
         rfcPar.Add(RfcConfigParameters.AppServerHost, "192.168.4.39");
         rfcPar.Add(RfcConfigParameters.Client, "500");
         rfcPar.Add(RfcConfigParameters.User, "INTUSER");
         rfcPar.Add(RfcConfigParameters.Password, "90-=op[]");
         rfcPar.Add(RfcConfigParameters.SystemNumber, "00");
         rfcPar.Add(RfcConfigParameters.Language, "ZH");
         RfcDestination dest   = RfcDestinationManager.GetDestination(rfcPar);
         RfcRepository  rfcrep = dest.Repository;
         IRfcFunction   myfun  = null;
         myfun = rfcrep.CreateFunction("ZFM_SERVICE_DRP");
         myfun.SetValue("IV_REQUEST", requestXML);//SAP里面的传入参数
         myfun.Invoke(dest);
         // IRfcTable lrfTable = myfun.GetTable("");
         strRes = myfun.GetString("EV_RESPONSE");
         return(strRes);
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }