예제 #1
0
        //Obtengo rutas por usuario y se las asigno a routes
        protected void obtieneRutas(List <Objeto2> grid_view)
        {
            string  name_function = "ZMAESTRO_RUTAS";
            DataSet ds            = new DataSet();
            var     fecha         = DateTime.Now.ToString("yyyyMMdd");

            try
            {
                IRfcFunction rfcFunction_Company = rfcRepository.CreateFunction(name_function.ToUpper());


                foreach (Objeto2 obj in grid_view)
                {
                    // Mando tabla agencia
                    IRfcTable i_agencia = rfcFunction_Company.GetTable("I_Agencia");
                    i_agencia.Append();
                    i_agencia.SetValue("MANDT", "600");
                    i_agencia.SetValue("AGENCIA", cmbAgency.SelectedItem.Value);
                    IRfcTable i_cet = rfcFunction_Company.GetTable("I_cet");
                    i_cet.Append();
                    i_cet.SetValue("CET", obj.codigo.ToString());
                }
                rfcFunction_Company.Invoke(rfcDestination);
                ds.Tables.Add(convertir.toGridView(rfcFunction_Company.GetTable("R_RUTA"), routes));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("<-- obtieneRutas Error: " + ex.Message + " -->");
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            rfc_Connector cfg = null;

            cfg = new rfc_Connector();

            IRfcFunction getDataSAP = GlobalData.rfcRepository.CreateFunction("ZPM_ORDER_01_CONFIRM");

            IRfcTable IT_DATA = getDataSAP.GetTable("LT_ORDER_CONF");

            IT_DATA.Clear();
            IT_DATA.Append();
            IT_DATA.SetValue("AUFNR", aufnr.Text);
            IT_DATA.SetValue("VORNR", vornr.Text);
            if (ck1.Checked == true)
            {
                IT_DATA.SetValue("AUERU", "X");
            }

            try
            {
                getDataSAP.Invoke(GlobalData.rfcDestination);
                RfcSessionManager.EndContext(GlobalData.rfcDestination);

                //var exObject = getDataSAP.GetObject("MESSAGE");
                MessageBox.Show("Order Confirmed");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #3
0
파일: Program.cs 프로젝트: arcaleg/SAP_AM
        private void DoOpSingleRoleCompositeRole(String composite, String[] singleRoles)
        {
            try
            {
                RfcRepository repo = destination.Repository;
                String        ops  = "";
                if (this.Operation == Operations.DelRoleToComposite)
                {
                    ops = "PRGN_RFC_DEL_AGRS_IN_COLL_AGR";
                }
                if (this.Operation == Operations.AddRoleToComposite)
                {
                    ops = "PRGN_RFC_ADD_AGRS_TO_COLL_AGR";
                }

                IRfcFunction func = repo.CreateFunction(ops);
                func.SetValue("ACTIVITY_GROUP", composite);
                IRfcTable tSingleRoles = func.GetTable("ACTIVITY_GROUPS");
                foreach (String single in singleRoles)
                {
                    tSingleRoles.Append();
                    tSingleRoles.SetValue("AGR_NAME", single);
                    tSingleRoles.SetValue("TEXT", "");
                }
                func.Invoke(destination);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message + " " + ex.StackTrace);
                OnError(new LogEventArgs(ex.Message));
            }
        }
예제 #4
0
파일: Program.cs 프로젝트: arcaleg/SAP_AM
 private void RenameRoles(List <Tuple <String, String, String, String, String, String, String> > t_agr_agrs)
 {
     try
     {
         foreach (Tuple <String, String, String, String, String, String, String> item in t_agr_agrs)
         {
             RfcRepository repo = destination.Repository;
             IRfcFunction  func = repo.CreateFunction("PRGN_RFC_CHANGE_TEXTS");
             func.SetValue("ACTIVITY_GROUP", item.Item1);
             IRfcTable tSingleRoles = func.GetTable("TEXTS");
             tSingleRoles.Append();
             tSingleRoles.SetValue("AGR_NAME", item.Item1);
             tSingleRoles.SetValue("LINE", 0);
             tSingleRoles.SetValue("TEXT", item.Item2);
             OnLog(new LogEventArgs(String.Format("Rinomina del ruolo \"{0}\" in corso", item.Item2)));
             func.Invoke(destination);
             OnLog(new LogEventArgs("OK"));
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine(ex.Message + " " + ex.StackTrace);
         OnError(new LogEventArgs(ex.Message));
     }
 }
        // Obteniendo rutas
        protected void obtengoRutas()
        {
            DataSet ds            = new DataSet();
            string  name_function = "ZMAESTRO_RUTAS";

            try
            {
                IRfcFunction rfcFunction_Company = rfcRepository.CreateFunction(name_function.ToUpper());
                // Mando tabla agencia
                IRfcTable i_agencia = rfcFunction_Company.GetTable("I_Agencia");
                i_agencia.Append();
                i_agencia.SetValue("MANDT", "600");
                i_agencia.SetValue("AGENCIA", cmbAgency.SelectedItem.Value);
                i_agencia.SetValue("NOMBRE_AGENCIA", cmbAgency.SelectedItem.Text);
                i_agencia.SetValue("PAIS", "GT");
                i_agencia.SetValue("SOCIEDAD", "");
                // Mando tabla cets
                IRfcTable i_cet = rfcFunction_Company.GetTable("I_cet");
                i_cet.Append();
                i_cet.SetValue("CET", cmbCet.SelectedItem.Value);
                i_cet.SetValue("NOMBRE_CET", cmbCet.SelectedItem.Text);
                i_cet.SetValue("AGENCIA", cmbAgency.SelectedItem.Value);
                i_cet.SetValue("PAIS", "GT");
                i_cet.SetValue("SOCIEDAD", "");
                rfcFunction_Company.Invoke(rfcDestination);
                ds.Tables.Add(convert.toDropdownList(rfcFunction_Company.GetTable("R_RUTA"), cmbRuta, "RUTA", "RUTA"));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error obtengoRutas() --> " + ex.Message);
            }
        }
예제 #6
0
        //Acá recorro routes y hago match, luego las seteo a All_Data(Esta Visible)
        public void show_all1()
        {
            obtieneRutas(cets);
            DataSet ds            = new DataSet();
            string  name_function = "Zdsd_Funciones_Asp_Net";
            var     fecha         = DateTime.Now.ToString("yyyyMMdd");

            //System.Diagnostics.Debug.WriteLine("tiempo" + fecha);
            try
            {
                IRfcFunction rfcFunction_Company = rfcRepository.CreateFunction(name_function.ToUpper());
                rfcFunction_Company.SetValue("I_Proceso", "REFRESH");
                IRfcTable i_tbl_refresh = rfcFunction_Company.GetTable("I_Tbl_Refresh");
                for (int i = 0; i < routes.Rows.Count; i++)
                {
                    i_tbl_refresh.Append();
                    i_tbl_refresh.SetValue("SALA_VENTA", routes.Rows[i].Cells[1].Text);
                    i_tbl_refresh.SetValue("CET", routes.Rows[i].Cells[2].Text);
                    i_tbl_refresh.SetValue("RUTA", routes.Rows[i].Cells[3].Text);
                    i_tbl_refresh.SetValue("FECHA_LIQUIDA", fecha);
                }
                rfcFunction_Company.Invoke(rfcDestination);
                ds.Tables.Add(convertir.toGridView(rfcFunction_Company.GetTable("O_Tbl_Refresh"), All_Data1));
                Semaforo();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("<-- show_all Error: " + ex.Message + " -->");
            }
        }
예제 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="logMessage"></param>
        /// <param name="w"></param>
        ///



        public DataTable ReadTableDW(string table, char delimiter, string fields, string filters, RfcDestination rfcDest, DataTable DT, string filters2, string filters3)
        {
            string[] field_names = fields.Split(",".ToCharArray());
            RfcDestinationManager.RegisterDestinationConfiguration(this.SAPConfig);
            // RfcDestination rfcDest = RfcDestinationManager.GetDestination(this.ConfigurationName);
            // RfcDestination destination = RfcDestinationManager.GetDestination(dest);
            IRfcFunction readTable = rfcDest.Repository.CreateFunction("BBP_RFC_READ_TABLE");

            // we want to query table KNA1
            readTable.SetValue("QUERY_TABLE", table);
            // fields will be separated by semicolon
            readTable.SetValue("DELIMITER", delimiter);
            // Parameter table FIELDS contains the columns you want to receive
            // here we query 2 fields, KUNNR and NAME1
            IRfcTable fieldsTable = readTable.GetTable("FIELDS");

            if (field_names.Length > 0)
            {
                fieldsTable.Append(field_names.Length);
                int i = 0;
                foreach (string n in field_names)
                {
                    fieldsTable.CurrentIndex = i++;
                    fieldsTable.SetValue(0, n);
                }
            }
            // the table OPTIONS contains the WHERE condition(s) of your query
            // here a single condition, KUNNR is to be 0012345600
            // several conditions have to be concatenated in ABAP syntax, for instance with AND or OR
            IRfcTable optsTable = readTable.GetTable("OPTIONS");

            optsTable.Append();
            optsTable.SetValue("TEXT", filters);
            if (filters2 != string.Empty)
            {
                optsTable.Append();
                optsTable.SetValue("TEXT", filters2);
            }
            if (filters3 != string.Empty)
            {
                optsTable.Append();
                optsTable.SetValue("TEXT", filters3);
            }

            readTable.Invoke(rfcDest);
            rfcDest = null;

            IRfcTable dataTable = readTable.GetTable("DATA");

            string[] columns;
            foreach (var dataRow in dataTable)
            {
                string data = (string)dataRow.GetValue("WA");
                columns = data.Split(delimiter);
                DT.LoadDataRow(columns.ToArray(), true);
            }

            return(DT);
        }
예제 #8
0
        public Dictionary <String, Object> GetSAPIVAMat(Int64 MaterialId)
        {
            Dictionary <String, Object> response = null;

            try
            {
                var config          = System.Configuration.ConfigurationManager.GetSection(ConfigurationName.Trim()) as NameValueCollection;
                var resultSeparator = config["ResultSeparator"].ToCharArray()[0];
                RfcDestinationManager.RegisterDestinationConfiguration(this.SAPConfig);
                RfcDestination rfcDest = RfcDestinationManager.GetDestination(this.ConfigurationName);
                RfcRepository  rfcRep  = null;
                rfcRep = rfcDest.Repository;
                IRfcFunction qry = rfcRep.CreateFunction("RFC_READ_TABLE");
                qry.SetValue("QUERY_TABLE", "MLAN");
                qry.SetValue("DELIMITER", resultSeparator);
                IRfcTable FIELDS = qry.GetTable("FIELDS");
                FIELDS.Append();
                FIELDS.SetValue("FIELDNAME", "TAXM1");
                IRfcTable OPTIONS = qry.GetTable("OPTIONS");
                OPTIONS.Append();
                OPTIONS.SetValue("TEXT", "MATNR EQ '" + CompleteCodes(MaterialId.ToString(), 18) + "' AND");
                OPTIONS.Append();
                OPTIONS.SetValue("TEXT", "ALAND EQ 'CO'");
                IRfcTable DATA = qry.GetTable("DATA");
                qry.Invoke(rfcDest);
                response = new Dictionary <string, object>();
                if (DATA.ToList().Count > 0)
                {
                    var result = DATA.ToList().First()["WA"];
                    var value  = result.GetValue();
                    response.Add("Response", true);
                    response.Add("SAPIVAMat", value.ToString());
                }
                else
                {
                    response.Add("Response", false);
                }
            }

            catch (RfcLogonException le)
            {
                return(new Dictionary <string, object>()
                {
                    { "Response", false }, { "Message", le.Message }
                });
            }
            catch (Exception ex)
            {
                return(new Dictionary <string, object>()
                {
                    { "Response", false }, { "Message", ex.Message + " : " + ex.StackTrace }
                });
            }
            finally
            {
                RfcDestinationManager.UnregisterDestinationConfiguration(this.SAPConfig);
            }
            return(response);
        }
예제 #9
0
        public DataTable  GetCargoLogisticoSAP(Int64 ObraId)
        {
            //var TD_TZONT = P.ReadTableDW("TZONT", '~', "LAND1,ZONE1,VTEXT", "LAND1 IN ('CO')", rfcDest, DefineDT.TZONT_DataBasic(), string.Empty, string.Empty);
            Dictionary <String, Object> response = null;
            DataTable DT = new DataTable();

            try
            {
                var config          = System.Configuration.ConfigurationManager.GetSection(ConfigurationName.Trim()) as NameValueCollection;
                var resultSeparator = config["ResultSeparator"].ToCharArray()[0];
                RfcDestinationManager.RegisterDestinationConfiguration(this.SAPConfig);
                RfcDestination rfcDest = RfcDestinationManager.GetDestination(this.ConfigurationName);
                RfcRepository  rfcRep  = null;
                rfcRep = rfcDest.Repository;
                IRfcFunction qry = rfcRep.CreateFunction("RFC_READ_TABLE");
                qry.SetValue("QUERY_TABLE", "KNVV");
                qry.SetValue("DELIMITER", resultSeparator);
                IRfcTable FIELDS = qry.GetTable("FIELDS");
                FIELDS.Append();
                FIELDS.SetValue("FIELDNAME", "ZZFUELSURC");
                FIELDS.Append();
                FIELDS.SetValue("FIELDNAME", "ZZDAMX33");
                IRfcTable OPTIONS = qry.GetTable("OPTIONS");
                OPTIONS.Append();
                OPTIONS.SetValue("TEXT", "KUNNR EQ '" + CompleteCodes(ObraId.ToString(), 10) + "' AND SPART EQ '03'");
                IRfcTable DATA = qry.GetTable("DATA");
                qry.Invoke(rfcDest);
                //DataTable DT = new DataTable();
                DT.Columns.Add("CargoCombustible");
                DT.Columns.Add("ZonaSuburbana");
                IRfcTable dataTable = qry.GetTable("DATA");
                string[]  columns;
                foreach (var dataRow in dataTable)
                {
                    string data = (string)dataRow.GetValue("WA");
                    columns = data.Split('|');
                    DT.LoadDataRow(columns.ToArray(), true);
                }
                return(DT);
            }

            catch (RfcLogonException le)
            {
                return(DT);
            }
            catch (Exception ex)
            {
                return(DT);
            }
            finally
            {
                RfcDestinationManager.UnregisterDestinationConfiguration(this.SAPConfig);
            }
            return(DT);
        }
예제 #10
0
        public string InsertaSolicitud(Cabecera c, List <Detalle> ds)
        {
            string folio = "";

            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_008");//Módulo de función

                IRfcStructure header = bapi.GetStructure("HEADER");
                header.SetValue("ID_SOLICITUD", c.folio);
                //header.SetValue("TIPO", c.tipo);
                header.SetValue("FECHA", c.fecha);
                header.SetValue("HORA", c.hora);
                header.SetValue("USUARIO", c.usuario);
                header.SetValue("PERNR", c.pernr);
                header.SetValue("ESTATUS", c.estatus);
                //header.SetValue("VISTO", c.visto);
                header.SetValue("COMMENTS", c.comentario);

                IRfcTable detail = bapi.GetTable("IT_DETALLE");
                foreach (Detalle d in ds)
                {
                    detail.Append();
                    detail.SetValue("ID_SOLICITUD", d.folio);
                    detail.SetValue("POS", d.pos);
                    detail.SetValue("VKORG", d.vkorg);
                    detail.SetValue("VTWEG", d.vtweg);
                    detail.SetValue("SPART", d.spart);
                    detail.SetValue("KUNNR", d.kunnr);
                    detail.SetValue("LP_ANT", d.pltyp);
                    detail.SetValue("LP_NVO", d.pltyp_n);
                    //detail.SetValue("MATNR", d.matnr);
                    //detail.SetValue("MATKL", d.matkl);
                    //detail.SetValue("EBELN", d.ebeln);
                    //detail.SetValue("PR_ANT", d.pr_ant);
                    //detail.SetValue("PR_NVO", d.pr_nvo);
                    //detail.SetValue("PORCENTAJE", d.porcentaje);
                    detail.SetValue("ESTATUS", d.estatus);
                    detail.SetValue("FECHA", d.date);
                }

                bapi.Invoke(oDestino);

                ////folio = bapi.GetString("FOLIO");
                IRfcTable folios = bapi.GetTable("IT_FOLIO");
                for (int i = 0; i < folios.Count; i++)
                {
                    folios.CurrentIndex = i;
                    folio += folios.GetString("ID_SOLICITUD") + ", ";
                }
            }
            return(folio);
        }
예제 #11
0
파일: Program.cs 프로젝트: arcaleg/SAP_AM
        public void UserAssignment(List <Tuple <String, String, String, String, String, String, String> > t_agr_agrs)
        {
            try
            {
                IEnumerable <Tuple <String, String, String, String, String, String, String> > cRoles =
                    t_agr_agrs.Distinct(new LambdaComparer <Tuple <String, String, String, String, String, String, String> >((i, k) => i.Item1 == k.Item1));
                foreach (Tuple <String, String, String, String, String, String, String> agr in cRoles)
                {
                    var singleRoles = t_agr_agrs.Where(a => a.Item1 == agr.Item1).ToList();
                    try
                    {
                        RfcRepository repo = destination.Repository;
                        String        ops  = "";
                        //if (this.Operation == Operations.RemoveRole)
                        //    ops = "BAPI_USER_ACTGROUPS_DELETE";
                        //if (this.Operation == Operations.AssignRole)
                        ops = "BAPI_USER_ACTGROUPS_ASSIGN";

                        OnLog(new LogEventArgs("Operazione su utente: " + agr.Item1));
                        IRfcFunction func = repo.CreateFunction(ops);
                        func.SetValue("USERNAME", agr.Item1);
                        IRfcTable roles = func.GetTable("ACTIVITYGROUPS");
                        foreach (var singleRole in singleRoles)
                        {
                            roles.Append();
                            if (this.Operation == Operations.AssignRole)
                            {
                                roles.SetValue("AGR_NAME", singleRole.Item2);
                                if (singleRole.Item3 != null)
                                {
                                    roles.SetValue("FROM_DAT", DateTime.ParseExact(singleRole.Item3, "dd.MM.yyyy", CultureInfo.InvariantCulture));
                                }
                                if (singleRole.Item4 != null)
                                {
                                    roles.SetValue("TO_DAT", DateTime.ParseExact(singleRole.Item4, "dd.MM.yyyy", CultureInfo.InvariantCulture));
                                }
                            }
                        }
                        func.Invoke(destination);
                    }
                    catch (Exception exc)
                    {
                        OnLog(new LogEventArgs(exc.Message));
                    }
                }
                OnLog(new LogEventArgs("Complete"));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message + " " + ex.StackTrace);
                OnError(new LogEventArgs(ex.Message));
            }
        }
예제 #12
0
        public bool getMatNr(string strAufNr, RfcDestination destination, ref string strMatNr, ref string strGesMenge, ref string strGesFailMenge)
        {
            // Metadaten beschaffen für RFC_READ_TABLE   - allgemeines RFC Baustein zum Lesen
            IRfcFunction rfcFunktion = destination.Repository.CreateFunction("RFC_READ_TABLE");

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

            tableField.Append();
            tableField.SetValue("FIELDNAME", "STLBEZ"); //MaterialNr im FA
            tableField.Append();
            tableField.SetValue("FIELDNAME", "GAMNG");  //Gesamtmaenge im FA
            tableField.Append();
            tableField.SetValue("FIELDNAME", "GASMG");  // Gesamte Fail Maenge im FA
            IRfcTable tableOptions = rfcFunktion.GetTable("OPTIONS");

            tableOptions.Append();
            // Auftragsnummer Format anpassen
            if (strAufNr.Length < 12)
            {
                String strTemp = strAufNr.PadLeft(12, '0');
                strAufNr = strTemp;
            }
            strAufNr = "AUFNR = '" + strAufNr + "'"; // String zusammenbauen zum 000060098052
            tableOptions.SetValue("TEXT", strAufNr); // Daten zum Auftragsnummer 60098052 (auf Format achten!)
            rfcFunktion.Invoke(destination);

            // 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();
            }
            // string spalten
            string[] erg = strErg.Split('~');
            strMatNr = erg[0];
            // strMatNr = strMatNr.TrimStart('0');

            string start1 = erg[1];

            strGesMenge = start1.Substring(0, start1.IndexOf('.'));
            string start2 = erg[2];

            strGesFailMenge = start2.Substring(0, start2.IndexOf('.'));
            return(true);
        }
        private static void get_tableMetadata(DataTable tab, ref IRfcTable tMetadata)
        {
            for (int i = 0; i < tab.Rows.Count; i++)
            {
                tMetadata.Append();
                tMetadata.SetValue("FIELDNAME", tab.Rows[i]["ColumnName"]);
                tMetadata.SetValue("FIELDDESCR", tab.Rows[i]["ColumnName"]);

                Type dtype = (Type)tab.Rows[i]["DataType"];
                tMetadata.SetValue("TYPE", dtype.Name);

                tMetadata.SetValue("LENGTH", tab.Rows[i]["NumericPrecision"]);
                tMetadata.SetValue("DECIMALS", tab.Rows[i]["NumericScale"]);
            }
        }
예제 #14
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);
        }
        // Cargo los cets y los mando a obtener todos los datos
        protected void cargarCets(String codigo)
        {
            string  name_function        = "Zconsulta_Maestro_Detalle";
            string  descripcion_it_datos = "DESCRIPCION";
            string  codigo_it_datos      = "CODIGO";
            DataSet ds = new DataSet();

            try
            {
                IRfcFunction rfcFunction_Company = rfcRepository.CreateFunction(name_function.ToUpper());
                rfcFunction_Company.SetValue("I_Parametro", "RECET");
                IRfcTable tablaEnv = rfcFunction_Company.GetTable("TG_OFICINAS");
                tablaEnv.Append();
                tablaEnv.SetValue("VKBUR", codigo);
                rfcFunction_Company.Invoke(rfcDestination);
                ds.Tables.Add(convert.toDataTable(rfcFunction_Company.GetTable("It_Datos")));



                DataTable dt   = ds.Tables[0];
                int       cont = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    ListItem item = cmbCetsPermitidos.Items.FindByValue(dr[1].ToString());
                    cmbCet.Items.Insert(cont, new ListItem(item.Text, item.Value));
                    cont++;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error cargarCets() --> " + ex.Message);
            }
        }
예제 #16
0
        private IRfcFunction GetInitializedFunction(RfcDestination rfcDestination, IEnumerable <string> selectionOptions = null)
        {
            IRfcFunction rfcFunction = GetFunction(rfcDestination);

            rfcFunction.SetValue("query_table", _tableName);
            rfcFunction.SetValue("delimiter", _separator[0]);
            rfcFunction.SetValue("rowcount", _rowCount);

            IRfcTable rfcOptions = rfcFunction.GetTable("Options");

            if (selectionOptions != null)
            {
                foreach (string option in selectionOptions)
                {
                    rfcOptions.Append();
                    rfcOptions.SetValue("TEXT", option);
                }
            }

            IRfcTable rfcFields = rfcFunction.GetTable("fields");

            foreach (string column in _fields)
            {
                rfcFields.Append();
                rfcFields.SetValue("fieldname", column);
            }

            return(rfcFunction);
        }
예제 #17
0
 //Borra los spool que esten con el checkbox seleccionado
 protected void Delete_Spool()
 {
     try
     {
         string       name_function = "Zfv_Borra_Spool";
         IRfcFunction rfcFunction_Spool_Reportes = rfcRepository.CreateFunction(name_function.ToUpper());
         IRfcTable    i_tbl_delete = rfcFunction_Spool_Reportes.GetTable("I_JOBS");
         foreach (GridViewRow row in GridView_Spool_Reportes.Rows)
         {
             if (row.RowType == DataControlRowType.DataRow)
             {
                 string   No_Job = row.Cells[1].Text;
                 CheckBox chkRow = (row.Cells[0].FindControl("CheckBox1") as CheckBox);
                 if (chkRow.Checked)
                 {
                     i_tbl_delete.Append();
                     i_tbl_delete.SetValue("NO_JOB", No_Job);
                     //System.Diagnostics.Debug.WriteLine(No_Job);
                 }
             }
         }
         rfcFunction_Spool_Reportes.Invoke(rfcDestination);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Error Delete_Spool() --> " + ex.Message + " -->");
     }
 }
예제 #18
0
        public int?SaveBillingBlock(string user, string billingNumber)
        {
            List <ContractBlock> listContract = new List <ContractBlock>();


            const string FUNCTIONAL_BAPI = "ZBAPI_SALESORDER_CHANGE";

            using (var dao = new BillingDbContext())
            {
                var sql1 = from o in dao.InvoiceProformaHeaders.Where(o => o.BillingNo == billingNumber).OrderByDescending(o => o.Version).Include(o => o.Billings)

                           select o;
                var count = sql1.ToList().Count;
                if (count > 1)
                {
                    InvoiceProformaHeader oldHeaderVersion = sql1.ToArray()[0];

                    var dest = GetRfcDestination();
                    if (dest != null)
                    {
                        var repo = dest.Repository;



                        var func = repo.CreateFunction(FUNCTIONAL_BAPI);

                        IRfcTable I_REJECT1 = func.GetTable("I_REJECT1");
                        foreach (var bi in oldHeaderVersion.Billings)
                        {
                            I_REJECT1.Append();

                            I_REJECT1.SetValue("MANDT", "999");
                            I_REJECT1.SetValue("VBELN", bi.AUBEL);
                            I_REJECT1.SetValue("POSNR", bi.AUPOS);
                            I_REJECT1.SetValue("ABGRU", bi.VBAK_ABGRU_T);
                        }

                        func.Invoke(dest);
                    }
                }
            }



            return(1);
        }
예제 #19
0
        public string ConfirmTO(DataVM entity, string confirm)
        {
            try
            {
                RfcConfigParameters rfcParam      = Connector3SapRfcConnGroup(_SAPConnectionString);
                RfcDestination      rfcDest       = RfcDestinationManager.GetDestination(rfcParam);
                RfcRepository       rfcRepository = rfcDest.Repository;
                IRfcFunction        rfcFunction   = rfcRepository.CreateFunction("L_TO_CONFIRM");
                rfcFunction.SetValue("I_LGNUM", "049");
                rfcFunction.SetValue("I_TANUM", entity.TO);
                rfcFunction.SetValue("I_QNAME", "RFCSHARE02");
                rfcFunction.SetValue("I_ENAME", "RFCSHARE02");
                rfcFunction.SetValue("I_COMMIT_WORK", "X");
                rfcFunction.SetValue("I_QUKNZ", confirm);

                IRfcTable table = rfcFunction.GetTable("T_LTAP_CONF");

                table.Insert();
                table.SetValue("TANUM", Convert.ToInt32(entity.TO));
                table.SetValue("TAPOS", entity.TO_ORDER);
                table.SetValue("ALTME", entity.UNIT);//unit of material code
                table.SetValue("NISTA", entity.QTY);
                //table.SetValue("NDIFA", "");//blank
                //table.SetValue("NLPLA", "");//blank

                rfcFunction.Invoke(rfcDest);
                return("Ok");
            }
            catch (RfcCommunicationException ex)
            {
                return("Error: " + ex.Message.ToString());
            }
            catch (RfcAbapException ex)
            {
                return("Error: " + ex.Message.ToString());
            }
            catch (RfcLogonException ex)
            {
                return("Error: " + ex.Message.ToString());
            }
            catch (Exception ex)
            {
                return("Error: " + ex.Message.ToString());
            }
        }
예제 #20
0
        private void BuildEdiDc40FromXml(Stream xmlStream, IRfcTable tableIdocControlRec40, IRfcStructure structureIdocControlRec40)
        {
            bool   endOfEDI_DC40Segment = false;
            string nodeName             = string.Empty;

            XmlTextReader     xmlNodeReader = new XmlTextReader(xmlStream);
            XmlReaderSettings settings      = new XmlReaderSettings();

            settings.IgnoreWhitespace = true;

            XmlReader xmlReader = XmlReader.Create(xmlNodeReader, settings);

            xmlReader.Read();

            while (xmlReader.Read() && !endOfEDI_DC40Segment)
            {
                // Move to fist element
                xmlReader.MoveToElement();

                //Create the DC40 Control Record

                // current node EDI_DC40
                if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.LocalName == "EDI_DC40")
                {
                    int indexIdocControlRec40 = 0;

                    // loop round the EDI_DC40 Table
                    while (xmlReader.Read())
                    {
                        if (xmlReader.NodeType == XmlNodeType.Element)
                        {
                            nodeName = xmlReader.LocalName;

                            // xml node name matches rfcStructure field name
                            if (indexIdocControlRec40 < structureIdocControlRec40.Metadata.FieldCount)
                            {
                                // goto to the text element
                                xmlReader.Read();

                                // empty element so node will by an EndType
                                if (xmlReader.NodeType == XmlNodeType.Text)
                                {
                                    tableIdocControlRec40.SetValue(nodeName, xmlReader.Value);
                                }

                                indexIdocControlRec40 += 1;
                            }
                            else
                            {
                                endOfEDI_DC40Segment = true;
                                break;
                            }
                        }
                    }
                } //outer while
            }
        }
예제 #21
0
        public bool EnviarDatosCobranza(DataTable dt)
        {
            RfcConfigParameters rfc = new RfcConfigParameters();

            rfc.Add(RfcConfigParameters.Name, ConfigurationManager.AppSettings["Name"]);
            rfc.Add(RfcConfigParameters.AppServerHost, ConfigurationManager.AppSettings["AppServerHost"]);
            rfc.Add(RfcConfigParameters.Client, ConfigurationManager.AppSettings["Client"]);
            rfc.Add(RfcConfigParameters.User, ConfigurationManager.AppSettings["User"]);
            rfc.Add(RfcConfigParameters.Password, ConfigurationManager.AppSettings["Password"]);
            rfc.Add(RfcConfigParameters.SystemNumber, "00");
            rfc.Add(RfcConfigParameters.Language, "ES");
            rfc.Add(RfcConfigParameters.PoolSize, "5");
            rfc.Add(RfcConfigParameters.MaxPoolSize, "100");
            rfc.Add(RfcConfigParameters.IdleTimeout, "900");
            RfcDestination rfcDest = null;

            try
            {
                rfcDest = RfcDestinationManager.GetDestination(rfc);
            }
            catch (Exception e)
            {
                e.ToString();
            }

            IRfcFunction         function = rfcDest.Repository.CreateFunction("ZSD_REXSAP_010"); // A la espera del nombre de la funcio
            IRfcTable            doc      = function.GetTable("TI_DOCREXSAP");                   //A la espera del nombre de la tabla
            RfcStructureMetadata metadata = doc.Metadata.LineType;

            List <string> nombresColumna = new List <string>();


            for (int i = 0; i < metadata.FieldCount; i++)
            {
                nombresColumna.Add(doc.GetElementMetadata(i).Name);
            }
            foreach (DataRow row in dt.Rows)
            {
                doc.Append();

                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    if (ExisteNombreColumna(nombresColumna, dt.Columns[i].ColumnName))
                    {
                        doc.SetValue(dt.Columns[i].ColumnName, row[dt.Columns[i].ColumnName]);
                    }
                }
            }


            try {
                function.Invoke(rfcDest);
                return(true);
            } catch (Exception e) {
                return(false);
            }
        }
예제 #22
0
        public void show_Errors()
        {
            input_agencia.Value = Session["detalle_sala_venta"].ToString();
            input_cet.Value     = Session["detalle_cet"].ToString();
            input_ruta.Value    = Session["detalle_ruta"].ToString();

            DataSet ds            = new DataSet();
            string  name_function = "Zdsd_Funciones_Asp_Net";
            var     fecha         = DateTime.Now.ToString("yyyyMMdd");

            //System.Diagnostics.Debug.WriteLine("tiempo" + fecha);
            try
            {
                IRfcFunction rfcFunction_Company = rfcRepository.CreateFunction(name_function.ToUpper());
                rfcFunction_Company.SetValue("I_Proceso", "ERROR");
                IRfcTable i_tbl_refresh = rfcFunction_Company.GetTable("I_Tbl_Refresh");

                i_tbl_refresh.Append();
                i_tbl_refresh.SetValue("SALA_VENTA", Session["detalle_sala_venta"]);
                i_tbl_refresh.SetValue("CET", Session["detalle_cet"]);
                i_tbl_refresh.SetValue("RUTA", Session["detalle_ruta"]);
                i_tbl_refresh.SetValue("FECHA_LIQUIDA", fecha);

                rfcFunction_Company.Invoke(rfcDestination);
                ds.Tables.Add(convertir.toGridView(rfcFunction_Company.GetTable("O_Tbl_Lerror"), errors));

                foreach (GridViewRow links in errors.Rows)
                {
                    if (links.Cells[0].Text == "S")
                    {
                        links.Cells[0].Text = "Subida";
                    }
                    else if (links.Cells[0].Text == "B")
                    {
                        links.Cells[0].Text = "Bajada";
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("<-- show_Errors Error: " + ex.Message + " -->");
            }
        }
예제 #23
0
 public static void get_relacionados_saptab(List <Relacionados> relacionados, ref IRfcTable p_relacionados)
 {
     if (relacionados.Count > 0)
     {
         for (int i = 0; i < relacionados.Count; i++)
         {
             p_relacionados.Append();
             p_relacionados.SetValue("BUKRS", relacionados[i].BUKRS);
             p_relacionados.SetValue("RIDDOCUMENTO", relacionados[i].RIDDOCUMENTO);
             p_relacionados.SetValue("UUID", relacionados[i].UUID);
             p_relacionados.SetValue("FILENAME", relacionados[i].FILENAME);
             p_relacionados.SetValue("RIMPPAGADO", relacionados[i].RIMPPAGADO);
             p_relacionados.SetValue("RFOLIO", relacionados[i].RFOLIO);
             p_relacionados.SetValue("RSERIEDR", relacionados[i].RSERIEDR);
             p_relacionados.SetValue("RMONEDADR", relacionados[i].RMONEDADR);
             p_relacionados.SetValue("RMETODODEPAGODR", relacionados[i].RMETODODEPAGODR);
             p_relacionados.SetValue("GJAHR", relacionados[i].GJAHR);
         }
     }
 }
예제 #24
0
        private void button2_Click(object sender, EventArgs e)
        {
            rfc_Connector cfg = null;

            cfg = new rfc_Connector();

            IRfcFunction getDataSAP = GlobalData.rfcRepository.CreateFunction("ZFRFC001");
            //getDataSAP.SetValue("P_KUNNR", "ALL");

            IRfcTable IT_DATA = getDataSAP.GetTable("LTLTZTB001");

            IT_DATA.Clear();
            IT_DATA.Append();
            IT_DATA.SetValue("MANDT", "400");
            IT_DATA.SetValue("MATNR", matnr.Text);
            IT_DATA.SetValue("MAKTX", maktx.Text);

            //IT_DATA.Append();
            //IT_DATA.SetValue("MANDT", "400");
            //IT_DATA.SetValue("MATNR", "MATERIAL02");
            //IT_DATA.SetValue("MAKTX", "COBA MATERIAL TEST");

            try
            {
                getDataSAP.Invoke(GlobalData.rfcDestination);
                RfcSessionManager.EndContext(GlobalData.rfcDestination);

                var           exObject    = getDataSAP.GetObject("OUTPUT");
                IRfcStructure exStructure = getDataSAP.GetStructure("LS_ZTB001");
            }
            catch (Exception ex)
            {
                message  = "SAP ZFDLKNA1 ";
                message += ex.Message;

                //RfcSessionManager.EndContext(GlobalData.rfcDestination);
                //Thread.Sleep(1000);
            }

            readdata();
        }
예제 #25
0
        //sube la data a sap
        protected void upload()
        {
            DataSet ds            = new DataSet();
            string  name_function = "Zdsd_Funciones_Asp_Net";
            var     fecha         = DateTime.Now.ToString("yyyyMMdd");

            try
            {
                IRfcFunction rfcFunction_Company = rfcRepository.CreateFunction(name_function.ToUpper());
                rfcFunction_Company.SetValue("I_Proceso", "SUBIDA");
                IRfcTable i_tbl_refresh = rfcFunction_Company.GetTable("I_Tbl_Refresh");
                foreach (GridViewRow row in All_Data.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        //mete la data en una tabla de sap
                        CheckBox chkRow = (row.Cells[0].FindControl("CheckBox1") as CheckBox);
                        if (chkRow.Checked)
                        {
                            Session["Sal_Venta"] = row.Cells[2].Text;
                            Session["Cet"]       = row.Cells[4].Text;
                            Session["ruta"]      = row.Cells[5].Text;

                            i_tbl_refresh.Append();
                            i_tbl_refresh.SetValue("SALA_VENTA", row.Cells[2].Text);
                            i_tbl_refresh.SetValue("CET", row.Cells[4].Text);
                            i_tbl_refresh.SetValue("RUTA", row.Cells[5].Text);
                            i_tbl_refresh.SetValue("FECHA_LIQUIDA", fecha);
                        }
                    }
                }
                rfcFunction_Company.Invoke(rfcDestination);
                //ds.Tables.Add(ConvertToDonNet(rfcFunction_Company.GetTable("O_Tbl_Refresh"), GridView1));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("<-- Upload Error: " + ex.Message + " -->");
            }
        }
예제 #26
0
        public void send2SAP(String jobNumber, DataTable attributes, DataTable bomItems)
        {
            PDMConnection.ECCDestinationConfig config = new PDMConnection.ECCDestinationConfig();

            if (!isDestinationInitialized())
            {
                RfcDestinationManager.RegisterDestinationConfiguration(config);
                setDestinationInitialized(true);
            }

            RfcDestination destination = RfcDestinationManager.GetDestination(getSystem());
            RfcRepository  repository  = destination.Repository;

            IRfcFunction testfn = repository.CreateFunction("ZBAPI_PDM2SAP");

            testfn.SetValue("PSPNR", jobNumber);
            IRfcTable items = testfn.GetTable("ITEMS");
            String    attrs = "";

            foreach (DataRow rows in bomItems.Rows)
            {
                foreach (DataRow attribute in attributes.Rows)
                {
                    attrs = attribute["ATTRI"].ToString();
                    if (!(rows[attrs] is DBNull))
                    {
                        items.Append();
                        String parent = rows["PARENT_ID"].ToString();
                        items.SetValue("PARENT_ID", parent);
                        items.SetValue("ITEM_ID", rows["BL_ITEM_FND0OBJECTID"]);
                        items.SetValue("BOM_ID", rows["BL_CLONE_STABLE_OCCURRENCE_ID"]);
                        items.SetValue("ATTRIBUTE", attrs);
                        items.SetValue("VALUE", rows[attrs]);
                    }
                }
            }
            testfn.Invoke(destination);
        }
예제 #27
0
        /// <summary>
        ///  set command parameter values to sap irfc table from the dao
        /// </summary>
        /// <param name="parameterList">SAPParameterList</param>
        /// <returns></returns>
        private void SetCommandParameterTable(SAPParameterList parameterList)
        {
            foreach (SAPParameter parameter in parameterList.Parameters)
            {
                IRfcTable irfcTable = rfcFunction.GetTable(parameter.Name);
                irfcTable.Insert();

                SAPParameterList tableParameterList = (SAPParameterList)parameter.Value;
                foreach (SAPParameter tableParameter in tableParameterList.Parameters)
                {
                    irfcTable.SetValue(tableParameter.Name, tableParameter.Value);
                }
            }
        }
예제 #28
0
        protected void download(object sender, EventArgs e)
        {
            string name_function = "Zdsd_Funciones_Asp_Net";
            //string fecha = myDatepicker.Value;
            var fecha = DateTime.Now.ToString("yyyyMMdd");

            //System.Diagnostics.Debug.WriteLine("Se hizo click en el botón: " + fecha);
            //System.Diagnostics.Debug.WriteLine("Se hizo click en el botón CAMBIADA: " + fecha_original_datePicker);
            try
            {
                Char     delimitador = '/';
                String   fecha_original_datePicker          = myDatepicker.Value.ToString();
                String[] substrings_datePickerCondicionPago = fecha_original_datePicker.Split(delimitador);
                fecha_original_datePicker = substrings_datePickerCondicionPago[2] + substrings_datePickerCondicionPago[1] + substrings_datePickerCondicionPago[0];

                IRfcFunction rfcFunction_Company = rfcRepository.CreateFunction(name_function.ToUpper());
                rfcFunction_Company.SetValue("I_Proceso", "BAJADA");
                IRfcTable i_tbl_refresh = rfcFunction_Company.GetTable("I_Tbl_Refresh");
                i_tbl_refresh.Append();
                i_tbl_refresh.SetValue("SALA_VENTA", Session["bajada_Sal_Venta"]);
                i_tbl_refresh.SetValue("CET", Session["bajada_Cet"]);
                i_tbl_refresh.SetValue("RUTA", Session["bajada_ruta"]);
                i_tbl_refresh.SetValue("FECHA_LIQUIDA", fecha_original_datePicker);

                rfcFunction_Company.Invoke(rfcDestination);
                //ds.Tables.Add(ConvertToDonNet(rfcFunction_Company.GetTable("O_Tbl_Refresh"), GridView1));
                //System.Diagnostics.Debug.WriteLine(Session["bajada_Sal_Venta"]);
                //System.Diagnostics.Debug.WriteLine(Session["bajada_Cet"]);
                //System.Diagnostics.Debug.WriteLine(Session["bajada_ruta"]);

                Response.Redirect("Cockpit.aspx", false);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("download Error: " + ex.Message + " -->");
            }
        }
예제 #29
0
        public void WriteToSAP()
        {
            //function parameters
            param.Clear();

            // SAP function
            funct = sap.getFunction(sap.rfcDest, "ZF_INTERFAZ_IVEND_SAP2", param);

            // detail structure
            IRfcTable tDetail = funct.GetTable("T_DETALLES");

            tDetail.Insert();  // This adds a new row to the table:
            tDetail.CurrentIndex = tDetail.Count - 1;

            // assign value to table
            tDetail.SetValue("SOCIEDAD", 2000);
            tDetail.SetValue("TIENDA", "tienda");
            tDetail.SetValue("FECHA", DateTime.Today);

            // call function to insert the record
            funct.Invoke(sap.rfcDest);
            // This table returns information about the transaction on
            IRfcTable tReturn = funct.GetTable("T_RETURN");
        }
예제 #30
0
        public DataTable DownloadBoom(string plant, string parentMaterial)
        {
            try
            {
                RfcConfigParameters rfcParam = Connector3SapRfcConnGroup(_SAPConnectionString);
                RfcDestination      rfcDest  = RfcDestinationManager.GetDestination(rfcParam);
                RfcRepository       rfcRep   = rfcDest.Repository;
                IRfcFunction        rfcFun   = rfcRep.CreateFunction("ZRFC_CS_BOM_EXPL_0003");//SAP RFC
                rfcFun.SetValue("WERKS", "FI20");
                rfcFun.SetValue("DATUV", DateTime.Now.ToString("yyyyMMdd"));
                rfcFun.SetValue("MEHRS", "X");
                rfcFun.SetValue("MDMPS", "");

                // Get table PLANT
                IRfcTable rtSourceOuput = null;
                IRfcTable rtSource1     = rfcFun.GetTable("MATNR_IN");
                rtSource1.Append();

                rtSource1.SetValue("MATNR", "16KIGLW1A13");

                rfcFun.Invoke(rfcDest);
                rtSourceOuput = rfcFun.GetTable("BOM_INFO");

                DataTable dtBoom = ConvertToDoNetTable(rtSourceOuput);
                return(dtBoom);
            }
            catch (RfcCommunicationException ex)
            {
                WriteLogs.Write("DownloadBoom", ex);
                return(null);
            }
            catch (RfcAbapException ex)
            {
                WriteLogs.Write("DownloadBoom", ex);
                return(null);
            }
            catch (RfcLogonException ex)
            {
                WriteLogs.Write("DownloadBoom", ex);
                return(null);
            }
            catch (Exception ex)
            {
                WriteLogs.Write("DownloadBoom", ex);
                return(null);
            }
        }