示例#1
0
        public IRfcTable busquedaL(string vk, string vt, string sp, string pr, string p1, string p2, string fs, string fa, string k1, string k2)
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_030");//Módulo de función

                bapi.SetValue("VKORG", vk);
                bapi.SetValue("VTWEG", vt);
                bapi.SetValue("SPART", sp);
                bapi.SetValue("PERNR", pr);
                bapi.SetValue("KUNNR1", k1);
                bapi.SetValue("KUNNR2", k2);
                bapi.SetValue("FECHA_S", fs);
                bapi.SetValue("FECHA_A", fa);
                bapi.SetValue("PLTYP1", p1);
                bapi.SetValue("PLTYP2", p2);

                bapi.Invoke(oDestino);

                IRfcTable tabla = bapi.GetTable("IT_DATA");
                for (int i = 0; i < tabla.Count; i++)
                {
                    tabla.CurrentIndex = i;
                }

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
        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);
        }
示例#3
0
        public IRfcTable getClienteP(string vk, string vt, string sp, string ku, string em, string tp) //Trae el cliente consultado
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_005");//Módulo de función

                bapi.SetValue("VKORG", vk);
                bapi.SetValue("VTWEG", vt);
                bapi.SetValue("SPART", sp);
                bapi.SetValue("KUNNR", ku);
                //if (!tp.Equals("A"))
                if (tp.Trim().Equals("V") | tp.Trim().Equals("C")) //ADD RSG 23.06.2017
                {
                    bapi.SetValue("PERNR", em);
                }

                bapi.Invoke(oDestino);

                IRfcTable tabla = bapi.GetTable("IT_KNVP");
                for (int i = 0; i < tabla.Count; i++)
                {
                    tabla.CurrentIndex = i;
                }

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#4
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);
        }
示例#5
0
        public IRfcTable AutoMATNR(string ma, string sp) //Trae la lista de materiales para autocompletar
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_013");//Módulo de función

                bapi.SetValue("MATNR", ma);
                bapi.SetValue("SPART", sp);

                bapi.Invoke(oDestino);

                IRfcTable tabla = bapi.GetTable("IT_MAKT");
                for (int i = 0; i < tabla.Count; i++)
                {
                    tabla.CurrentIndex = i;
                }

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#6
0
        public IRfcTable AutoCHARG(string ma, string ch) //Trae la lista de clientes para autocompletar
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_046");//Módulo de función

                bapi.SetValue("MATNR", ma);
                bapi.SetValue("CHARG", ch);

                bapi.Invoke(oDestino);

                IRfcTable tabla = bapi.GetTable("it_MCHB");
                for (int i = 0; i < tabla.Count; i++)
                {
                    tabla.CurrentIndex = i;
                }

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#7
0
        public IRfcTable tablaEscalasSol(string folio, string pos)
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_044");//Módulo de función

                bapi.SetValue("FOLIO", folio);
                bapi.SetValue("POS", pos);
                //bapi.SetValue("USUARIO", usuario);

                bapi.Invoke(oDestino);

                IRfcTable tabla = bapi.GetTable("IT_ESCALAS");
                for (int i = 0; i < tabla.Count; i++)
                {
                    tabla.CurrentIndex = i;
                }

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#8
0
        public IRfcTable ListaVTWEG(string v, string p, string k) //Trae TODOS los canales de distribución
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_002");//Módulo de función

                if (!v.Equals(""))
                {
                    bapi.SetValue("VTWEG", v);
                }
                if (!p.Equals(""))
                {
                    bapi.SetValue("PERNR", p);
                }
                if (!k.Equals(""))
                {
                    bapi.SetValue("VKORG", k);
                }

                bapi.Invoke(oDestino);

                IRfcTable tabla = bapi.GetTable("IT_TVTW");
                for (int i = 0; i < tabla.Count; i++)
                {
                    tabla.CurrentIndex = i;
                }

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#9
0
        public static List <ActivityType> getAllActivityTypes(RfcDestination destination, ControllingArea iControllingArea)
        {
            List <ActivityType> ret = new List <ActivityType>();

            RfcRepository repo             = destination.Repository;
            IRfcFunction  activityTypeList = repo.CreateFunction("BAPI_ACTIVITYTYPE_GETLIST");

            activityTypeList.SetValue("CONTROLLINGAREA", iControllingArea.ControllingAreaCode);
            activityTypeList.SetValue("DATE", DateTime.Now);

            activityTypeList.Invoke(destination);

            IRfcTable activityTypes = activityTypeList.GetTable("ACTIVITYTYPE_LIST");

            for (int cuIndex = 0; cuIndex < activityTypes.RowCount; cuIndex++)
            {
                activityTypes.CurrentIndex = cuIndex;
                ActivityType activityT = new ActivityType();
                activityT.ActivityTypeCode    = activityTypes.GetString("ACTTYPE");
                activityT.ActivityTypeName    = activityTypes.GetString("NAME");
                activityT.ActivityDescription = activityTypes.GetString("DESCRIPT");
                activityT.ControllingArea     = iControllingArea;
                ret.Add(activityT);
            }
            return(ret);
        }
示例#10
0
        public IRfcTable tablaCabeceraL(string visto, string pernr)
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_018");//Módulo de función

                bapi.SetValue("VISTO", visto);
                //bapi.SetValue("USUARIO", usuario);
                bapi.SetValue("PERNR", pernr);

                bapi.Invoke(oDestino);

                IRfcTable tabla = bapi.GetTable("IT_CABECERA");
                for (int i = 0; i < tabla.Count; i++)
                {
                    tabla.CurrentIndex = i;
                }

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#11
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);
            }
        }
        //liquida con P_TOUR_ID, F_SLD_ID (se obtienen del gridview) y los otros dos datos se mandan por session de cockpit
        public void Liquidar()
        {
            string name_function = "Zfv_Liquida_Lista";
            var    fecha         = DateTime.Now.ToString("yyyyMMdd");

            try
            {
                IRfcFunction rfcFunction = rfcRepository.CreateFunction(name_function.ToUpper());
                if (datos_busqueda.Rows.Count > 0)
                {
                    rfcFunction.SetValue("P_TOUR_ID", datos_busqueda.Rows[0].Cells[1].Text);
                    rfcFunction.SetValue("F_SLD_ID", datos_busqueda.Rows[0].Cells[0].Text);
                    rfcFunction.SetValue("F_RUTA", S_ruta);
                    rfcFunction.SetValue("F_FECHA", fecha);
                    rfcFunction.SetValue("F_SOCIEDAD", S_sociedad);
                }
                rfcFunction.Invoke(rfcDestination);
                buttonError.InnerText = "La liquidación fue exitosa";
                buttonError.Visible   = true;
            }
            catch (Exception ex)
            {
                buttonError.InnerText = "No se pudo liquidar";
                buttonError.Visible   = true;
                System.Diagnostics.Debug.WriteLine("Error Liquidar() --> " + ex.Message + " -->");
            }
        }
示例#13
0
文件: SapQuery.cs 项目: JazzCF/BA_CF
        /* get Materialkurztext
         * strMatNr is SAp-Nr like 604934
         * return string with result
         */
        public string getMatKurzText(string strMatNr)
        {
            //Console.WriteLine("SapNr : {0}", strMatNr);
            // Metadaten beschaffen für RFC_READ_TABLE   - allgemeines RFC Baustein zum Lesen
            IRfcFunction rfcFunktion = m_rfcdestination.Repository.CreateFunction("RFC_READ_TABLE");

            rfcFunktion.SetValue("QUERY_TABLE", "MAKT");           //Tabelle, die gelesen wird
            rfcFunktion.SetValue("DELIMITER", "~");                //Trennzeichen
            IRfcTable tableField = rfcFunktion.GetTable("FIELDS"); // Definieren welche Spalten gelesen werden

            tableField.Append();
            tableField.SetValue("FIELDNAME", "MAKTX"); // Materialkurztext
            IRfcTable tableOptions = rfcFunktion.GetTable("OPTIONS");

            tableOptions.Append();
            string strMatNrToSap = "MATNR = " + "'" + strMatNr + "'" + " and SPRAS = 'D'";

            //Console.WriteLine("stringto SapNr {0}", strMatNrToSap);
            tableOptions.SetValue("TEXT", strMatNrToSap);
            rfcFunktion.Invoke(m_rfcdestination);
            // Daten verarbeiten
            IRfcTable dataTable = rfcFunktion.GetTable("DATA");//Datenspalte holen
            string    strErg    = "";

            // uber Zeilen gehen
            foreach (var dataRow in dataTable)
            {
                string data = dataRow.GetValue("WA").ToString();
                //Console.WriteLine(data);
                strErg = data.ToString();
            }
            //Console.WriteLine("string {0}", strErg.Length);
            return(strErg);
        }
示例#14
0
        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);
            }
        }
示例#15
0
 //crea el spool reportes
 public void get_Spool_Reportes()
 {
     try
     {
         DataSet      ds            = new DataSet();
         string       name_function = "Zfv_Spool_X_Usuario";
         IRfcFunction rfcFunction_Spool_Reportes = rfcRepository.CreateFunction(name_function.ToUpper());
         var          fecha = "";
         if (myDatepicker.Value.Trim() != "")
         {
             String   fecha_original = myDatepicker.Value.ToString();
             Char     delimitador    = '/';
             String[] substrings     = fecha_original.Split(delimitador);
             fecha = substrings[2] + substrings[1] + substrings[0];
         }
         else
         {
             fecha = DateTime.Now.ToString("yyyyMMdd");
         }
         rfcFunction_Spool_Reportes.SetValue("I_USUARIO", Session["usuario"].ToString()); //--1
         rfcFunction_Spool_Reportes.SetValue("I_FECHA", fecha);                           //--1
         rfcFunction_Spool_Reportes.Invoke(rfcDestination);
         ds.Tables.Add(convert.toGridView(rfcFunction_Spool_Reportes.GetTable("R_SPOOL"), GridView_Spool_Reportes));
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Error get_Spool_Reportes() --> " + ex.Message + " -->");
     }
 }
        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();
            }
        }
        public System.Data.DataTable GetBsItemsDetail()
        {
            // validation
            if (string.IsNullOrEmpty(this.CompanyCode))
            {
                throw new Exception("公司代码参数不能为空!");
            }
            if (string.IsNullOrEmpty(this.ReportYear))
            {
                throw new Exception("年度参数不能为空!");
            }
            if (string.IsNullOrEmpty(this.ReportPeriod))
            {
                throw new Exception("期间参数不能为空!");
            }

            RfcDestination sap      = DestinationProvider.GetSAPDestination();
            IRfcFunction   function = sap.Repository.CreateFunction("Z_BS_BALANCES");

            function.SetValue("COMPANYCODE", this.CompanyCode);
            function.SetValue("FISCALYEAR", this.ReportYear);
            function.SetValue("FISCALPERIOD", this.ReportPeriod);

            function.Invoke(sap);

            IRfcTable bsItems = function.GetTable("ACC_BALANCES");

            return(SAPUtils.ToDataTable(bsItems));
        }
示例#18
0
        public string estatusSol(string tipo, string folio) //Trae la desc o unidad de material
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_WFO_004");//Módulo de función

                bapi.SetValue("P_ZTIWF", "005");
                bapi.SetValue("P_ZKYWF", folio);

                bapi.Invoke(oDestino);

                string oper   = bapi.GetString("P_ZSWAR");
                string evto   = bapi.GetString("P_ZEVTI");
                string cadena = "";

                if (oper.Equals("P"))
                {
                    cadena = "Pendiente";
                }
                else if (oper.Equals("R"))
                {
                    cadena = "Rechazada";
                }
                else if (oper.Equals("A"))
                {
                    cadena = "Aprobada";
                }
                return(cadena);
            }
            else
            {
                return(null);
            }
        }
        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 IRfcTable consultaDetalleL(string folio, string pernr)
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_019");//Módulo de función

                bapi.SetValue("FOLIO", folio);
                bapi.SetValue("PERNR", pernr);

                bapi.Invoke(oDestino);

                IRfcTable tabla = bapi.GetTable("IT_DETALLE");
                for (int i = 0; i < tabla.Count; i++)
                {
                    tabla.CurrentIndex = i;
                }

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
        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();
            }
        }
示例#22
0
        public IRfcTable ListaVKORG(string v, string p) //Trae TODAS las Organizaciones de compra
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_001");//Módulo de función

                if (!v.Equals(""))
                {
                    bapi.SetValue("VKORG", v);
                }
                if (!p.Equals(""))
                {
                    bapi.SetValue("PERNR", p);
                }

                bapi.Invoke(oDestino);

                IRfcTable tabla = bapi.GetTable("IT_TVKO");
                for (int i = 0; i < tabla.Count; i++)
                {
                    tabla.CurrentIndex = i;
                }

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
        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();
            }
        }
示例#24
0
        public IRfcTable AutoKUNNR(string vk, string vt, string sp, string ku, string em) //Trae la lista de clientes para autocompletar
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_003");//Módulo de función

                bapi.SetValue("VKORG", vk);
                bapi.SetValue("VTWEG", vt);
                bapi.SetValue("SPART", sp);
                bapi.SetValue("KUNNR", ku);
                bapi.SetValue("PERNR", em);

                bapi.Invoke(oDestino);

                IRfcTable tabla = bapi.GetTable("IT_KNAVV");
                for (int i = 0; i < tabla.Count; i++)
                {
                    tabla.CurrentIndex = i;
                }

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// Remote Function Module YBAPI_UPD_INSTKEY1.
        /// Update eForm Id to Accounting Doc.
        /// </summary>
        /// <param name="Acckey_Tab">Key of Accounting Doc</param>
        /// <param name="Return0">Return Parameter</param>
        //[RfcMethod(AbapName = "YBAPI_UPD_INSTKEY1")]
        //[SoapDocumentMethodAttribute("http://tempuri.org/YBAPI_UPD_INSTKEY1",
        // RequestNamespace = "urn:sap-com:document:sap:rfc:functions",
        // RequestElementName = "YBAPI_UPD_INSTKEY1",
        // ResponseNamespace = "urn:sap-com:document:sap:rfc:functions",
        // ResponseElementName = "YBAPI_UPD_INSTKEY1.Response")]
        public virtual void Ybapi_Upd_Instkey1(

            //    [RfcParameter(AbapName = "ACCKEY_TAB", RfcType = RFCTYPE.RFCTYPE_ITAB, Optional = true, Direction = RFCINOUT.INOUT)]
            //[XmlArray("ACCKEY_TAB", IsNullable = false, Form = XmlSchemaForm.Unqualified)]
            //[XmlArrayItem("item", IsNullable = false, Form = XmlSchemaForm.Unqualified)]
            ref ZACCKEY2Table Acckey_Tab,
            //[RfcParameter(AbapName = "RETURN", RfcType = RFCTYPE.RFCTYPE_ITAB, Optional = true, Direction = RFCINOUT.INOUT)]
            //[XmlArray("RETURN", IsNullable = false, Form = XmlSchemaForm.Unqualified)]
            //[XmlArrayItem("item", IsNullable = false, Form = XmlSchemaForm.Unqualified)]
            ref BAPIRET2Table Return0)
        {
            //object[] results = null;
            //results = this.SAPInvoke("Ybapi_Upd_Instkey1", new object[] {
            //                Acckey_Tab,Return0 });
            //Acckey_Tab = (ZACCKEY2Table)results[0];
            //Return0 = (BAPIRET2Table)results[1];

            IRfcFunction function = destination.Repository.CreateFunction("BAPI_UPD_INSTKEY1");

            #region set parameter value

            function.SetValue("ACCKEY_TAB", Acckey_Tab.GetTable(destination.Repository));
            function.SetValue("RETURN", Return0.GetTable(destination.Repository));

            #endregion

            function.Invoke(destination);


            Acckey_Tab.SetValue(function.GetTable("ACCKEY_TAB")); //Acckey_Tab = (ZACCKEY2Table)results[0];
            Return0.SetValue(function.GetTable("RETURN"));        //Return0 = (BAPIRET2Table)results[1];
        }
示例#26
0
        public IRfcTable AutoMATKL(string mk, string sp) //Trae la lista de clientes para autocompletar
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_014");//Módulo de función

                bapi.SetValue("MATKL", mk);
                if (!sp.Equals(""))
                {
                    bapi.SetValue("SPART", sp);
                }

                bapi.Invoke(oDestino);

                IRfcTable tabla = bapi.GetTable("IT_T023T");
                for (int i = 0; i < tabla.Count; i++)
                {
                    tabla.CurrentIndex = i;
                }

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#27
0
        public IRfcTable consultaLODetail(string sp, string ma, string ta, bool ch)//Trae detalle KONH por lista de precio
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_024");//Módulo de función

                bapi.SetValue("SPART", sp);
                bapi.SetValue("MATNR", ma);
                bapi.SetValue("TABLA", ta);
                if (ch)
                {
                    bapi.SetValue("DEGRADADO", "X");
                }

                bapi.Invoke(oDestino);

                IRfcTable tabla = bapi.GetTable("IT_LP");

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#28
0
        public IRfcTable getCliente(string vk, string vt, string sp, string ku) //Trae el cliente consultado
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_005");//Módulo de función

                bapi.SetValue("VKORG", vk);
                bapi.SetValue("VTWEG", vt);
                bapi.SetValue("SPART", sp);
                bapi.SetValue("KUNNR", ku);

                bapi.Invoke(oDestino);

                IRfcTable tabla = bapi.GetTable("IT_KNAVV");
                for (int i = 0; i < tabla.Count; i++)
                {
                    tabla.CurrentIndex = i;
                }

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#29
0
        public IRfcTable ListaPLTYP(string pr, string sp, string ku) //Trae TODAS las listas de precios
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_007");//Módulo de función

                //bapi.SetValue("SPRAS", ");
                bapi.SetValue("PERNR", pr);
                bapi.SetValue("SPART", sp);
                bapi.SetValue("ZTIWF", "005");
                bapi.SetValue("TIPO", "01");
                if (!ku.Trim().Equals(""))
                {
                    bapi.SetValue("KUNNR", ku);
                }

                bapi.Invoke(oDestino);

                //IRfcTable tabla = bapi.GetTable("IT_KNVP");
                //string cadena = "";
                IRfcTable tabla = bapi.GetTable("IT_T189T");

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#30
0
        public IRfcTable getBitacora(string tipo, string folio) //Trae el cliente consultado
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                //IRfcFunction bapi = repo.CreateFunction("ZFWF_WFO_005");//Módulo de función
                IRfcFunction bapi = repo.CreateFunction("ZFWF_PFI_011");//Módulo de función

                bapi.SetValue("P_ZTIWF", "005");
                bapi.SetValue("P_ZKYWF", folio);

                bapi.Invoke(oDestino);

                IRfcTable tabla = bapi.GetTable("P_BITACORA");
                //IRfcTable tabla = bapi.GetTable("P_FLUJOBIT");
                for (int i = 0; i < tabla.Count; i++)
                {
                    tabla.CurrentIndex = i;
                }

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#31
0
        /// <summary>
        /// Pass input parameters to SAP remote function call
        /// </summary>
        /// <param name="function"></param>
        /// <param name="meta"></param>
        /// <param name="rfc"></param>
        private void PrepareInputParameters( SAPFunction function, RfcFunctionMetadata meta, IRfcFunction rfc)
        {
            Dictionary<String,IRfcTable> _table = new Dictionary<String,IRfcTable>();
            Dictionary<String,IRfcStructure> _structure = new Dictionary<String,IRfcStructure>();
            foreach (var iin in function.InputParameters)
            {
                String paramName = iin.Key;
                String paramValue = iin.Value;
                String secondLevelStructure = string.Empty;
                int sapFieldIndex = -1;
                int tableRowIndex = -1;

                string[] paramDetail = paramName.Split(':');
                if(paramDetail.Length == 1) {
                    sapFieldIndex = meta.TryNameToIndex(paramName);
                } else if (paramDetail.Length == 2) {
                    secondLevelStructure = paramDetail[0];
                    paramName = paramDetail[1];

                    if (secondLevelStructure.Contains('[') && secondLevelStructure.Contains(']'))
                    {
                        sapFieldIndex = meta.TryNameToIndex(secondLevelStructure.Split('[')[0]);
                        string arrayIndex = secondLevelStructure.Split('[')[1].Split(']')[0];
                        Int32.TryParse(arrayIndex, out tableRowIndex);
                    }
                    else
                    {
                        sapFieldIndex = meta.TryNameToIndex(secondLevelStructure);
                    }
                }

                if (sapFieldIndex != -1)
                {
                    RfcElementMetadata elementMeta = rfc.GetElementMetadata(sapFieldIndex);
                    RfcDataType type = elementMeta.DataType;
                    String dataType = type.ToString();
                    function.DataType.Add(secondLevelStructure + ":" + paramName, ConvertDataType(type));
                    if (dataType.Equals(SAPFunction.STRUCTURE))
                    {
                        IRfcStructure structure;
                        if (!_structure.TryGetValue(secondLevelStructure, out structure))
                        {
                            structure = rfc.GetStructure(secondLevelStructure);
                            _structure.Add(secondLevelStructure, structure);
                        }
                        structure.SetValue(paramName, paramValue);
                        function.Length.Add(paramName + ":" + secondLevelStructure, structure.GetElementMetadata(paramName).NucLength);
                    }
                    else if (dataType.Equals(SAPFunction.TABLE))
                    {
                        if (secondLevelStructure.Contains('[') && secondLevelStructure.Contains(']'))
                        {
                            IRfcTable table;
                            if (!_table.TryGetValue(secondLevelStructure.Split('[')[0], out table))
                            {
                                table = rfc.GetTable(secondLevelStructure.Split('[')[0]);
                                _table.Add(secondLevelStructure.Split('[')[0], table);
                            }

                            try
                            {
                                table.ElementAt(tableRowIndex);
                            }
                            catch (ArgumentOutOfRangeException)
                            {
                                table.Insert(1, tableRowIndex);
                            }
                            table.CurrentIndex = tableRowIndex;

                            //rfc.Invoke(this.Destination);

                            RfcElementMetadata em = table.GetElementMetadata(paramName);

                            string s = String.Format("{0, " + table.GetElementMetadata(paramName).NucLength + "}", paramValue);

                            table.SetValue(paramName, s.Trim());
                            function.Length.Add(paramName + ":" + secondLevelStructure, table.GetElementMetadata(paramName).NucLength);
                        }
                    }
                    else
                    {
                        rfc.SetValue(paramName, paramValue);
                        function.Length.Add(paramName, rfc.GetElementMetadata( paramName ).NucLength);
                    }
                }
            }
        }
        public FunctionResult ExecuteSelect(string functionName, List<NParameter> parameters, List<string> tableNames)
        {
            try
            {
                _function = _destination.Repository.CreateFunction(functionName);

                foreach (NParameter param in parameters)
                    _function.SetValue(param.Name, param.Value);

                _function.Invoke(_destination);

                List<object> tables = tableNames.Select(table => _function.GetTable(table)).Cast<object>().ToList();

                return new FunctionResult()
                {
                    IsSuccess = true,
                    Data = tables
                };
            }
            catch (Exception ex)
            {
                return new FunctionResult
                {
                    IsSuccess = false,
                    ErrorMessage = ex.ToString()
                };
            }
        }
示例#33
0
 public static void StfcConnection(RfcServerContext context, IRfcFunction function)
 {
     Console.WriteLine("Received function call{0} from system{1}.",
         function.Metadata.Name,
         context.SystemAttributes.SystemID);
     String reqtext = function.GetString("REQUTEXT");
     Console.WriteLine("REQUTEXT = {0}\n", reqtext);
     function.SetValue("ECHOTEXT", reqtext);
     function.SetValue("RESPTEXT", "Hello from NCo 3.0!");
 }