Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
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 + " -->");
            }
        }
Пример #6
0
        public void ToRfcTable(ref IRfcTable resultTable)
        {
            resultTable.Clear();

            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                resultTable.Append();

                string dSIGN = dataTable.Rows[i][sSIGN].ToString();
                if (dSIGN == string.Empty)
                {
                    dSIGN = SIGN.I.ToString();
                }
                resultTable[i].SetValue(sSIGN, dSIGN);

                string dOPTION = dataTable.Rows[i][sOPTION].ToString();
                if (dOPTION == string.Empty)
                {
                    dOPTION = OPTION.EQ.ToString();
                }
                resultTable[i].SetValue(sOPTION, dOPTION);

                string low = RFC_FunctionBase.ValueProcess(dataTable.Rows[i][sLOW].ToString(), LengthLimit);
                resultTable[i].SetValue(sLOW, low);
                string high = RFC_FunctionBase.ValueProcess(dataTable.Rows[i][sHIGH].ToString(), LengthLimit);
                resultTable[i].SetValue(sHIGH, high);
            }
        }
        // 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);
            }
        }
        // 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);
            }
        }
Пример #9
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);
        }
Пример #10
0
 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));
     }
 }
Пример #11
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 + " -->");
     }
 }
Пример #12
0
 private void AddWhereLine(IRfcTable toptions, string whereline)
 {
     //  toptions.AddRow()["TEXT"] = whereline;
     // IRfcStructure row = toptions.Metadata.LineType.CreateStructure();
     toptions.Append();
     toptions.CurrentRow.SetValue("TEXT", whereline);
 }
Пример #13
0
        /* 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
        /// <summary>
        /// Process SAP RFC Table Input Data
        /// </summary>
        /// <param name="rfcFunc"></param>
        /// <param name="paramIndex"></param>
        /// <param name="tableData"></param>
        /// Owner:Andy Gao 2011-05-11 13:16:47
        private static void ProcessSAPRFCTableInputData(IRfcFunction rfcFunc, int paramIndex, DataTable tableData)
        {
            IRfcTable rfcTable = rfcFunc.GetTable(paramIndex);

            foreach (DataRow tableRow in tableData.Rows)
            {
                rfcTable.Append();

                IRfcStructure rfcStructRow = rfcTable.CurrentRow;

                foreach (DataColumn column in tableData.Columns)
                {
                    int tableIndex = rfcStructRow.Metadata.TryNameToIndex(column.ColumnName);

                    if (tableIndex >= 0)
                    {
                        object value = tableRow[column];

                        if (value != null && value != DBNull.Value)
                        {
                            rfcStructRow.SetValue(tableIndex, value);
                        }
                    }
                }
            }

            rfcFunc.SetValue(paramIndex, rfcTable);
        }
Пример #15
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);
            }
        }
Пример #16
0
        public static IRfcTable SAPExecuteDeulTableData(Hashtable[] arrht1, string Function_Name, string RfcStructure_Name, string SetTable_Name, string GetTable_Name)
        {
            RfcConfigParameters configParam = GetConfigParam();
            RfcDestination      destination = RfcDestinationManager.GetDestination(configParam);
            IRfcFunction        function    = destination.Repository.CreateFunction(Function_Name);

            IRfcTable rfcTable = function.GetTable(SetTable_Name);

            for (int i = 0; i < arrht1.Length; i++)
            {
                RfcStructureMetadata strMeta      = destination.Repository.GetStructureMetadata(RfcStructure_Name);
                IRfcStructure        rfcStructure = strMeta.CreateStructure();

                IDictionaryEnumerator ie = arrht1[i].GetEnumerator();

                while (ie.MoveNext())
                {
                    if (ie.Value.ToString().Length <= 4000)
                    {
                        rfcStructure.SetValue(ie.Key.ToString(), ie.Value);
                    }
                }

                rfcTable.Append(rfcStructure);
            }

            function.Invoke(destination);

            IRfcTable rfcTable2 = function.GetTable(GetTable_Name);

            return(rfcTable2);
        }
Пример #17
0
        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));
            }
        }
Пример #18
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 + " -->");
            }
        }
Пример #19
0
        public IRfcTable GetTable(RfcRepository repository, IRfcTable table)
        {
            for (int i = 0; i < List.Count; i++)
            {
                table.Append(((BAPIPAREX)List[i]).GetStructure(repository));
            }

            return(table);
        }
Пример #20
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);
            }
        }
Пример #21
0
        public IRfcTable GetTable(RfcRepository repository)
        {
            IRfcTable table = repository.GetTableMetadata("EXTENSION2").CreateTable(List.Count);

            for (int i = 0; i < List.Count; i++)
            {
                table.Append(((BAPIPAREX)List[i]).GetStructure(repository));
            }

            return(table);
        }
Пример #22
0
        public IRfcTable GetTable(RfcRepository repository)
        {
            IRfcTable table = repository.GetTableMetadata("ACCOUNTRECEIVABLE").CreateTable(List.Count);

            for (int i = 0; i < List.Count; i++)
            {
                table.Append(((BAPIACAR09)List[i]).GetStructure(repository));
            }

            return(table);
        }
Пример #23
0
        public IRfcTable GetTable(RfcRepository repository)
        {
            IRfcTable table = repository.GetTableMetadata("CRITERIA").CreateTable(List.Count);

            for (int i = 0; i < List.Count; i++)
            {
                table.Append(((BAPIACKEC9)List[i]).GetStructure(repository));
            }

            return(table);
        }
Пример #24
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);
        }
Пример #25
0
        public IRfcTable GetTable(RfcRepository repository)
        {
            IRfcTable table = repository.GetTableMetadata("ACCKEY_TAB").CreateTable(List.Count);

            for (int i = 0; i < List.Count; i++)
            {
                table.Append(((ZACCKEY2)List[i]).GetStructure(repository));
            }

            return(table);
        }
Пример #26
0
        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));
            }
        }
Пример #27
0
        private Boolean ImportInvoice(String databaseName, DocumentCached invoice, out String documentNumber, out String errorMessage)
        {
            errorMessage   = String.Empty;
            documentNumber = String.Empty;

            try
            {
                IRfcFunction fReadTable = repo.CreateFunction("ZZBAPI_DEBIT_MEMO_REQUEST");
                fReadTable.SetValue("CUSTOMER", ("0000000" + invoice.CustomerCode).Right(10));
                fReadTable.SetValue("SALES_ORG", invoice.VLCompany);
                fReadTable.SetValue("PURCH_DATE", invoice.DocDate);
                fReadTable.SetValue("PURCH_NO_C", invoice.Comment);

                foreach (DocumentLineCached line in invoice.Lines)
                {
                    RfcStructureMetadata metaData         = dest.Repository.GetStructureMetadata("ZORDERLINE");
                    IRfcStructure        structConditions = metaData.CreateStructure();

                    structConditions.SetValue("ITM_NUMBER", ("0000" + line.LineNum.ToString() + "0").Right(6));
                    structConditions.SetValue("MATERIAL", line.ItemCode);                     // C => Certificate
                    structConditions.SetValue("TARGET_QTY", line.Quantity);
                    structConditions.SetValue("SALES_UNIT", line.UnitOfMeasure);
                    structConditions.SetValue("COND_VALUE", line.Price);
                    structConditions.SetValue("CURRENCY", line.Currency);
                    structConditions.SetValue("SHORT_TEXT", line.ShortText);

                    IRfcTable tblItems = fReadTable.GetTable("ORDERLINE");
                    tblItems.Append(structConditions);
                    fReadTable.SetValue("ORDERLINE", tblItems);
                }


                fReadTable.Invoke(dest);
                String        result  = (String)fReadTable.GetValue("SALESDOCUMENT");
                IRfcStructure result2 = (IRfcStructure)fReadTable.GetValue("RETURN");

                documentNumber = result.ToString();
                errorMessage   = result2[3].ToString().Replace("FIELD MESSAGE=", "");


                if (String.IsNullOrEmpty(documentNumber) || !String.IsNullOrEmpty(errorMessage))
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }

            return(true);
        }
Пример #28
0
        public static string GetAllProducts(string ProductsList)
        {
            string[] ProductArray = ProductsList.Split(',');

            IRfcTable IRetTable = null;
            List <Z_MM_QUBE_MATNR> Z_MM_QUBE_MATNR_List = new List <Z_MM_QUBE_MATNR>();
            RfcConfigParameters    parms   = RFC.GetSettingParms();
            RfcDestination         rfcDest = RfcDestinationManager.GetDestination(parms);
            RfcRepository          rfcRep  = rfcDest.Repository;
            IRfcFunction           IReader = rfcRep.CreateFunction("Z_MM_QUBE_MATNR");

            IReader.Invoke(rfcDest);
            IRfcTable Itab = IReader.GetTable("IT_MATNR");

            for (int i = 0; i < ProductArray.Length; i++)
            {
                Itab.Append();
                Itab[i].SetValue("MATNR", ProductArray[i].ToString());
            }

            IReader.SetValue("IT_MATNR", Itab);
            IReader.Invoke(rfcDest);

            IRetTable            = IReader.GetTable("ET_MATNR");
            Z_MM_QUBE_MATNR_List = IRetTable.AsQueryable().Select(x => new Z_MM_QUBE_MATNR
            {
                MATNR        = x.GetString("MATNR") ?? "",
                MAKTX        = x.GetString("MAKTX") ?? "",
                ZZCT2        = x.GetString("ZZCT2") ?? "",
                LIFNR        = x.GetString("LIFNR") ?? "",
                ZZMATU       = x.GetString("ZZMATU") ?? "",
                ZFVOLUME     = x.GetString("ZFVOLUME") ?? "",
                ZZPAGE       = x.GetString("ZZPAGE") ?? "",
                WGBEZ        = x.GetString("WGBEZ") ?? "",
                ZFPRESERVE_D = x.GetString("ZFPRESERVE_D") ?? "",
                ZZSE         = x.GetString("ZZSE") ?? "",
                NETPR        = x.GetString("NETPR") ?? "",
                WAERS        = x.GetString("WAERS") ?? "",
                DMBTR        = x.GetString("DMBTR") ?? "",
                ERDAT        = x.GetString("ERDAT") ?? "",
                UDATE        = x.GetString("UDATE") ?? ""
            }
                                                                  ).ToList();

            AddTempTable(Z_MM_QUBE_MATNR_List);

            string result = JsonConvert.SerializeObject(Z_MM_QUBE_MATNR_List);

            return(result);
        }
Пример #29
0
        public static string SAPExecuteTableData(Hashtable[] arrht, Hashtable ImportData, string Function_Name, string RfcStructure_Name, string Table_Name)
        {
            RfcConfigParameters configParam = GetConfigParam();
            RfcDestination      destination = RfcDestinationManager.GetDestination(configParam);
            IRfcFunction        function    = destination.Repository.CreateFunction(Function_Name);

            IRfcTable rfcTable = function.GetTable(Table_Name);

            for (int i = 0; i < arrht.Length; i++)
            {
                RfcStructureMetadata strMeta      = destination.Repository.GetStructureMetadata(RfcStructure_Name);
                IRfcStructure        rfcStructure = strMeta.CreateStructure();

                if (arrht[i] == null)
                {
                    continue;
                }

                IDictionaryEnumerator ie = arrht[i].GetEnumerator();

                while (ie.MoveNext())
                {
                    if (ie.Value.ToString().Length <= 4000)
                    {
                        rfcStructure.SetValue(ie.Key.ToString(), ie.Value);
                    }
                }

                rfcTable.Append(rfcStructure);
            }

            if (ImportData.Count > 0)
            {
                IDictionaryEnumerator ie = ImportData.GetEnumerator();

                while (ie.MoveNext())
                {
                    if (ie.Value.ToString().Length <= 4000)
                    {
                        function.SetValue(ie.Key.ToString(), ie.Value);
                    }
                }
            }

            function.Invoke(destination);

            string returnCode = function.GetString("E_VBELN");

            return(returnCode);
        }
Пример #30
0
        private void createBtn_Click(object sender, EventArgs e)
        {
            try
            {
                RfcRepository rfcRepository = rfcDestination.Repository;
                var           create        = rfcRepository.CreateFunction("BAPI_INTERNALORDRGRP_CREATE");
                create.Invoke(rfcDestination);

                var hierarchyTable = create.GetTable("HIERARCHYNODES");
                hierarchyTable.Append();

                String groupName = createGridView.Rows[0].Cells[0].Value.ToString();
                String hierLevel = "0";
                String valcount  = createGridView.Rows[0].Cells[1].Value.ToString();
                String descript  = createGridView.Rows[0].Cells[2].Value.ToString();

                hierarchyTable.SetValue("GROUPNAME", groupName);
                hierarchyTable.SetValue("HIERLEVEL", hierLevel);
                hierarchyTable.SetValue("VALCOUNT", valcount);
                hierarchyTable.SetValue("DESCRIPT", descript);


                IRfcTable hierarchyValuesTable = create.GetTable("HIERARCHYVALUES");
                hierarchyValuesTable.Append();
                for (int i = 0; i + 1 < valueDataGrid.RowCount; i++)
                {
                    hierarchyValuesTable.Insert();
                    hierarchyValuesTable.CurrentIndex = hierarchyValuesTable.Count - 1;

                    hierarchyValuesTable[i].SetValue("VALFROM", valueDataGrid.Rows[i].Cells[0].Value.ToString());
                    hierarchyValuesTable[i].SetValue("VALTO", valueDataGrid.Rows[i].Cells[1].Value.ToString());
                }

                for (int i = 0; i + 1 < valueDataGrid.RowCount; i++)
                {
                    Console.Out.WriteLine(hierarchyValuesTable[i].GetString("VALFROM"));
                }

                create.SetValue("HIERARCHYNODES", hierarchyTable);
                create.SetValue("HIERARCHYVALUES", hierarchyValuesTable);
                create.Invoke(rfcDestination);
                this.Close();
            }

            catch (Exception ex)
            {
                Console.Out.WriteLine(ex.Message);
                Console.Out.WriteLine(ex.StackTrace);
            }
        }
Пример #31
0
 private void WriteSegmentToTable(string ParentNr, IRfcTable tData, IdocSegment SegToWrite, int HLevel)
 {
     tData.Append();
     IRfcStructure structure = tData.CurrentRow;
     //RFCStructure structure = tData.AddRow();
     string parentNr = tData.RowCount.ToString();
     string str2 = SegToWrite.ReadDataBuffer(0, 0x3e8);
     structure["SEGNAM"].SetValue(SegToWrite.SegmentName);
     structure["MANDT"].SetValue(this.MANDT);
     structure["DOCNUM"].SetValue(this.DOCNUM);
     structure["SEGNUM"].SetValue(parentNr.PadLeft(6, "0".ToCharArray()[0]));
     structure["PSGNUM"].SetValue(ParentNr.PadLeft(6, "0".ToCharArray()[0]));
     if ((HLevel == 1) && (SegToWrite.MaxOccur > 1))
     {
         HLevel++;
     }
     if (this._SkipHLevel)
     {
         structure["HLEVEL"].SetValue("  ");
     }
     else
     {
         structure["HLEVEL"].SetValue(Convert.ToString(HLevel).PadLeft(2, "0".ToCharArray()[0]));
     }
     structure["SDATA"].SetValue(str2);
     if (SegToWrite.HasChildren)
     {
         for (int i = 0; i < SegToWrite.ChildSegments.Count; i++)
         {
             this.WriteSegmentToTable(parentNr, tData, SegToWrite.ChildSegments[i], HLevel + 1);
         }
     }
 }
Пример #32
0
 private void AddWhereLine(IRfcTable toptions, string whereline)
 {
     //  toptions.AddRow()["TEXT"] = whereline;
     // IRfcStructure row = toptions.Metadata.LineType.CreateStructure();
     toptions.Append();
     toptions.CurrentRow.SetValue("TEXT", whereline);
 }
Пример #33
0
 private void InitWhereClause(ref IRfcTable toptions)
 {
     toptions.Clear();
     if (this._WhereClause.Equals(""))
     {
         for (int i = 0; i < this.options.Count; i++)
         {
             toptions.Append();
             toptions.CurrentRow.SetValue("TEXT", this.options[i].ToString());
             //toptions.AddRow()["TEXT"] = this.options[i].ToString();
         }
     }
     else
     {
         for (int j = 0; j < this._WhereClause.Length; j += 0x48)
         {
             if ((this._WhereClause.Length - j) > 0x48)
             {
                 IRfcStructure structure2 = toptions.Metadata.LineType.CreateStructure();
                 bool flag = false;
                 for (int k = 0; k < 0x47; k++)
                 {
                     if (this._WhereClause.Substring((j + 0x47) - k, 1).Equals(" "))
                     {
                         structure2["TEXT"].SetValue(this._WhereClause.Substring(j, 0x48 - k));
                         toptions.Append(structure2);
                         j -= k;
                         flag = true;
                         k = 0x48;
                     }
                 }
                 if (!flag)
                 {
                     structure2["TEXT"].SetValue(this._WhereClause.Substring(j, 0x48));
                     toptions.Append(structure2);
                 }
             }
             else
             {
                 // toptions.AddRow()["TEXT"] = this._WhereClause.Substring(j);
                 toptions.Append();
                 toptions.CurrentRow["TEXT"].SetValue(this._WhereClause.Substring(j));
             }
         }
         string str = "";
         foreach (IRfcStructure structure4 in toptions.ToList())
         {
             str = str + structure4["TEXT"].ToString() + "\r\n";
         }
     }
     if (this._UsePrimaryKeyPackaging)
     {
         if (toptions.ToList().Count == 0)
         {
             this.AddWhereLine(toptions, "(");
         }
         else
         {
             this.AddWhereLine(toptions, "AND (");
         }
         for (int m = 0; m < this._PrimaryKeys.Count; m++)
         {
             string whereline = this._PrimaryKeys[m].FieldName + " >= '" + this._PrimaryKeys[m].LastKeyValue + "'";
             if (m == 0)
             {
                 whereline = "( " + whereline;
             }
             else
             {
                 whereline = "AND " + whereline;
             }
             if (m == (this._PrimaryKeys.Count - 1))
             {
                 whereline = whereline + " )";
             }
             this.AddWhereLine(toptions, whereline);
         }
         for (int n = 0; n < this._PrimaryKeys.Count; n++)
         {
             for (int num6 = n; num6 >= 0; num6--)
             {
                 string str3;
                 if (num6 == n)
                 {
                     str3 = "OR ( " + this._PrimaryKeys[num6].FieldName + " > '" + this._PrimaryKeys[num6].LastKeyValue + "'";
                 }
                 else
                 {
                     str3 = "AND " + this._PrimaryKeys[num6].FieldName + " >= '" + this._PrimaryKeys[num6].LastKeyValue + "'";
                 }
                 if (num6 == 0)
                 {
                     str3 = str3 + " )";
                 }
                 this.AddWhereLine(toptions, str3);
             }
         }
         //toptions.AddRow()["TEXT"] = ")";
         toptions.Append();
         toptions.CurrentRow.SetValue("TEXT", ")");
     }
     //if (!this.con.LogDir.Equals(""))
     //{
     //    this.con.Log("Building where: ");
     //    foreach (RFCStructure structure6 in toptions.Rows)
     //    {
     //        this.con.Log(structure6["TEXT"].ToString());
     //    }
     //}
 }