示例#1
0
文件: Program.cs 项目: arcaleg/SAP_AM
 public void GenerateProfile(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_PROFILE_NAME_GET");
             func.SetValue("ACT_OBJID", item.Item1);
             OnLog(new LogEventArgs("Creazione del profilo per " + item.Item1));
             func.Invoke(destination);
             String profName = func.GetString("ACT_PROFILE_NAME");
             String profText = func.GetString("ACT_PROF_TEXT");
             func = repo.CreateFunction("PRGN_AUTO_GENERATE_PROFILE_NEW");
             func.SetValue("ACTIVITY_GROUP", item.Item1);
             func.SetValue("PROFILE_NAME", profName);
             func.SetValue("PROFILE_TEXT", profText);
             func.SetValue("NO_DIALOG", "X");
             func.SetValue("ORG_LEVELS_WITH_STAR", "X");
             func.Invoke(destination);
             OnLog(new LogEventArgs("OK"));
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine(ex.Message + " " + ex.StackTrace);
         OnError(new LogEventArgs(ex.Message));
     }
 }
示例#2
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);
        }
示例#3
0
        public IRfcTable tablaEscalas(string knumh)
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_043");//Módulo de función

                bapi.SetValue("KNUMH", knumh);
                //bapi.SetValue("USUARIO", usuario);

                bapi.Invoke(oDestino);

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

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
        public InvoiceValueModel GetInvoiceValue(RfcDestination rfcDest)
        {
            InvoiceValueModel invoiceValueModel = new InvoiceValueModel();
            RfcDestination    SAPRfcDestination = RfcDestinationManager.GetDestination("accelyides");

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


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

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

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

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

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

            return(invoiceValueModel);
        }
示例#5
0
        public IRfcTable tablaCabeceraL(string visto, string pernr)
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_018");//Módulo de función

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

                bapi.Invoke(oDestino);

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

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

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

                bapi.Invoke(oDestino);

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

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

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

                bapi.Invoke(oDestino);

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

                if (oper.Equals("P"))
                {
                    cadena = "Pendiente";
                }
                else if (oper.Equals("R"))
                {
                    cadena = "Rechazada";
                }
                else if (oper.Equals("A"))
                {
                    cadena = "Aprobada";
                }
                return(cadena);
            }
            else
            {
                return(null);
            }
        }
示例#8
0
        public List <meins> meinss() //Trae cadena de mail y teléfono
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_045");//Módulo de función

                bapi.Invoke(oDestino);

                IRfcTable    tcurr = bapi.GetTable("IT_T006A");
                List <meins> mm    = new List <meins>();

                for (int i = 0; i < tcurr.Count; i++)
                {
                    tcurr.CurrentIndex = i;
                    meins m = new meins();
                    m.MSEHI = tcurr.GetString("MSEHI");
                    //m.MSEHI = tcurr.GetString("MSEH3");
                    m.MSEH3 = tcurr.GetString("MSEH3");
                    m.desc  = tcurr.GetString("MSEHL");
                    mm.Add(m);
                }
                //List<string> ms = new List<string>();
                //foreach(meins m in mm)
                //{
                //    ms.Add("<option value='"+m.MSEHI+"'>"+ m.MSEH3+ " - " + "</option>");
                //}

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

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

                bapi.Invoke(oDestino);

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

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

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

                bapi.Invoke(oDestino);

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

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#11
0
        public List <string> monedas() //Trae cadena de mail y teléfono
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_021");//Módulo de función

                bapi.Invoke(oDestino);

                IRfcTable     tcurr = bapi.GetTable("IT_TCURC");
                List <string> m     = new List <string>();

                for (int i = 0; i < tcurr.Count; i++)
                {
                    tcurr.CurrentIndex = i;
                    m.Add(tcurr.GetString("WAERS"));
                }

                return(m);
            }
            else
            {
                return(null);
            }
        }
示例#12
0
        public IRfcTable consultaLPDetail(string vk, string vt, string sp, string ku, string ma, string mk, string pl, string ta)//Trae detalle KONH por lista de precio
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_011");//Módulo de función

                bapi.SetValue("VKORG", vk);
                bapi.SetValue("VTWEG", vt);
                bapi.SetValue("SPART", sp);
                bapi.SetValue("KUNNR", ku);
                bapi.SetValue("MATNR", ma);
                bapi.SetValue("MATKL", mk);
                bapi.SetValue("PLTYP", pl);
                bapi.SetValue("TABLA", ta);

                bapi.Invoke(oDestino);

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

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#13
0
        /// <summary>
        /// 调用Sap服务器函数
        /// (非IDOC)
        /// </summary>
        /// <param name="orderCode"></param>
        /// <returns></returns>
        public string InvokeRFCFunctionGetCompanyID(string orderCode)
        {
            IRfcFunction function  = null;
            string       companyID = String.Empty;

            try
            {
                function = _rfcDestination.Repository.CreateFunction("ZRFC_JGM_INFO2"); //调用sap函数
                function.SetParameterActive(0, true);
                function.SetValue("VBELN", orderCode);                                  //给函数 ZRFC_JGM_INFO2 传值
                function.Invoke(_rfcDestination);
                IRfcTable tb = function.GetTable("E_TAB");                              //获取 ZRFC_JGM_INFO2函数返回的 "E_TAB"表

                foreach (IRfcStructure dr in tb)
                {
                    string orderNumber = dr.GetValue("VBELN").ToString(); //获取表 "E_TAB"结构中 "VBELN" 字段的值
                    if (orderNumber.Equals(orderCode))
                    {
                        companyID = dr.GetValue("KUNNR").ToString();
                        break;
                    }
                }
            }
            catch (RfcBaseException e)
            {
                throw e;
            }
            return(companyID);
        }
        /// <summary>
        /// Remote Function Module YBAPI_UPD_INSTKEY1.
        /// Update eForm Id to Accounting Doc.
        /// </summary>
        /// <param name="Acckey_Tab">Key of Accounting Doc</param>
        /// <param name="Return0">Return Parameter</param>
        //[RfcMethod(AbapName = "YBAPI_UPD_INSTKEY1")]
        //[SoapDocumentMethodAttribute("http://tempuri.org/YBAPI_UPD_INSTKEY1",
        // RequestNamespace = "urn:sap-com:document:sap:rfc:functions",
        // RequestElementName = "YBAPI_UPD_INSTKEY1",
        // ResponseNamespace = "urn:sap-com:document:sap:rfc:functions",
        // ResponseElementName = "YBAPI_UPD_INSTKEY1.Response")]
        public virtual void Ybapi_Upd_Instkey1(

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

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

            #region set parameter value

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

            #endregion

            function.Invoke(destination);


            Acckey_Tab.SetValue(function.GetTable("ACCKEY_TAB")); //Acckey_Tab = (ZACCKEY2Table)results[0];
            Return0.SetValue(function.GetTable("RETURN"));        //Return0 = (BAPIRET2Table)results[1];
        }
示例#15
0
        public IRfcTable consultaDetalleL(string folio, string pernr)
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_019");//Módulo de función

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

                bapi.Invoke(oDestino);

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

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

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

                bapi.Invoke(oDestino);

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

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#17
0
        public TOutput GetStruct <TOutput>(List <string> options, bool includeUnsafeFields = false, string delimiter = "|", string noData = "")
            where TOutput : class, ISapTable
        {
            using IRfcConnection rfcConnection = GetConnection();
            using IRfcFunction rfcFunction     = rfcConnection.CreateFunction(READ_TABLE_FUNCTION_NAME);

            List <string> fieldNames = GetRfcEntityFieldNames(typeof(TOutput), includeUnsafeFields);

            var inputParameters = new TableInputParameter
            {
                Query     = GetRfcTableName <TOutput>(),
                Delimiter = delimiter,
                NoData    = noData,
                RowCount  = 1,
                RowSkips  = 0,
                Fields    = fieldNames?.Select(f => new TableField {
                    FieldName = f
                }).ToArray(),
                Options = options?.Select(o => new TableOption {
                    Text = o
                }).ToArray()
            };

            TableOutputParameter result = rfcFunction.Invoke <TableOutputParameter>(inputParameters);

            return(ConvertToStruct <TOutput>(result, delimiter, fieldNames));
        }
示例#18
0
        public IRfcTable ListaVKORG(string v, string p) //Trae TODAS las Organizaciones de compra
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_001");//Módulo de función

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

                bapi.Invoke(oDestino);

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

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#19
0
        public string getLP_Desc(string idioma, string lista) //Trae la descripción lista de precio consultada
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_007");//Módulo de función

                //bapi.SetValue("SPRAS", ");
                bapi.SetValue("PLTYP", lista);

                bapi.Invoke(oDestino);

                //IRfcTable tabla = bapi.GetTable("IT_KNVP");
                string    cadena = "";
                IRfcTable tabla  = bapi.GetTable("IT_T189T");
                for (int i = 0; i < tabla.Count & i < 1; i++)
                {
                    tabla.CurrentIndex = i;
                    cadena             = tabla.GetString("PLTYP") + " " + tabla.GetString("PTEXT");
                }

                return(cadena);
            }
            else
            {
                return(null);
            }
        }
示例#20
0
        public responce_ZMOV_10000 sapRun(request_ZMOV_10000 import)
        {
            RfcDestination configSap        = RfcDestinationManager.GetDestination("SCLEM");
            RfcRepository  SapRfcRepository = configSap.Repository;
            IRfcFunction   rfcFunction      = SapRfcRepository.CreateFunction("ZMOV_10000");

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

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

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

            return(res);
        }
示例#21
0
        public IRfcTable ListaPLTYP() //Trae TODAS las listas de precios
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_007");//Módulo de función

                //bapi.SetValue("SPRAS", ");
                //bapi.SetValue("PERNR", pr);
                //bapi.SetValue("SPART", sp);
                //bapi.SetValue("ZTIWF", "005");

                bapi.Invoke(oDestino);

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

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

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

                bapi.Invoke(oDestino);

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

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

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

                bapi.Invoke(oDestino);

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

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
示例#24
0
        public IRfcTable AutoPLTYP(string pl, string sp, string pr) //Trae la lista de clientes para autocompletar
        {
            if (conectar())
            {
                RfcRepository repo = oDestino.Repository;
                IRfcFunction  bapi = repo.CreateFunction("ZFWF_AP_016");//Módulo de función

                bapi.SetValue("PLTYP", pl);
                bapi.SetValue("PERNR", pr);
                bapi.SetValue("SPART", sp);
                bapi.SetValue("ZTIWF", "005");
                bapi.SetValue("TIPO", "02");
                bapi.SetValue("CONDICION", "X");

                bapi.Invoke(oDestino);

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

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

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

                bapi.Invoke(oDestino);

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

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

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

                bapi.Invoke(oDestino);

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

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

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

                bapi.Invoke(oDestino);

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

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

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

                bapi.Invoke(oDestino);

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

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

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

                bapi.Invoke(oDestino);

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

                return(tabla);
            }
            else
            {
                return(null);
            }
        }
        public static string RFCxSociedad(string xname, string appsh, string xsapr, string sysn, string xuser, string pasw, string cliente, string sociedad)
        {
            RfcConfigParameters parms = new RfcConfigParameters();

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

            RfcDestination rfcDest = null;

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

            conexion.SetValue("SOCIEDAD", sociedad);
            conexion.Invoke(rfcDest);                  //Se ejecuta la consulta
            //string xresul = conexion.GetString("RFC");
            return(conexion.GetString("RFC"));
        }
        public FunctionResult ExecuteInsert(string functionName, List<NTable> parameters, List<string> tableNames)
        {
            try
            {
                _function = _destination.Repository.CreateFunction(functionName);

                for (int i = 0; i < tableNames.Count; i++)
                {
                    RfcStructureMetadata metaData = _destination.Repository.GetStructureMetadata(parameters[i].StructureName);

                    IRfcTable tblInput = _function.GetTable(tableNames[i]);

                    foreach (DataRow row in parameters[i].Parameters.Rows)
                    {
                        IRfcStructure structRow = metaData.CreateStructure();

                        foreach (DataColumn column in parameters[i].Parameters.Columns)
                        {
                            object obj = row[column];
                            structRow.SetValue(column.ToString(), obj);
                        }

                        tblInput.Append(structRow);
                    }
                }

                RfcSessionManager.BeginContext(_destination);
                _function.Invoke(_destination);

                IRfcTable returnTable = _function.GetTable("NOTESRETURN");

                return new FunctionResult
                {
                    IsSuccess = true,
                    Data = new List<object> { returnTable }
                };
            }
            catch (Exception ex)
            {
                return new FunctionResult
                {
                    IsSuccess = false,
                    ErrorMessage = ex.ToString()
                };
            }
        }
        public FunctionResult ExecuteSelect(string functionName, List<NParameter> parameters, List<string> tableNames)
        {
            try
            {
                _function = _destination.Repository.CreateFunction(functionName);

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

                _function.Invoke(_destination);

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

                return new FunctionResult()
                {
                    IsSuccess = true,
                    Data = tables
                };
            }
            catch (Exception ex)
            {
                return new FunctionResult
                {
                    IsSuccess = false,
                    ErrorMessage = ex.ToString()
                };
            }
        }
示例#33
0
 /// <summary>
 /// Invoca a la RFC para que prepare la tabla de retorno
 /// y luego la devuelve
 /// </summary>
 /// <param name="rfcDestination"></param>
 /// <param name="rfcFunction"></param>
 /// <returns></returns>
 private static IRfcTable getReturnTable(RfcDestination rfcDestination, IRfcFunction rfcFunction)
 {
     rfcFunction.Invoke(rfcDestination);
     return rfcFunction.GetTable(RFC_FUNCTION_RETURN_TABLE_NAME);
 }
        private void ExecuteRFC_READ_TABLE(ref IRfcFunction f)
        {
            SendMessage(String.Format("开始调用{0}", f.Metadata.Name));
            if (this.BackgroundExtraction)
            {
                f["ACTIONID"].SetValue("D");
                f["REQUESTID"].SetValue(this.BackgroundRequestID);
                if (!this.BufferLocation.Equals(""))
                {
                    f["LCTN"].SetValue(this.BufferLocation);
                }
            }
            IRfcTable toptions = f.GetTable("OPTIONS");
            this.InitWhereClause(ref toptions);
            this.anzahlaufrufe++;
            if ((this._UsePrimaryKeyPackaging && (this.anzahlaufrufe > 1)) && (((int)f["ROWCOUNT"].GetValue()) > 0))
            {
                f["ROWCOUNT"].SetValue(((int)f["ROWCOUNT"].GetValue()) + 1);
            }
            f["DELIMITER"].SetValue(this.Delimiter);
            //if (this.con.Logging)
            //{
            //    try
            //    {
            //        f.SaveToXML("ReadTableBeforeCall_" + this.anzahlaufrufe.ToString() + ".xml");
            //    }
            //    catch
            //    {
            //    }
            //}
            if (this._UsePrimaryKeyPackaging)
            {
                f["ROWSKIPS"].SetValue("0");
            }
            try
            {
                SendMessage("Invoke开始");
                f.Invoke(_des);
                SendMessage("Invoke结束");
            }
            catch (RfcAbapException e)
            {
                this.fields.Clear();
                this.options.Clear();
                throw new SAPException(e.Key + e.Message);
            }
            catch (RfcAbapRuntimeException ee)
            {
                throw new SAPException(ee.Key + ee.Message);
            }

            SendMessage(String.Format("结束调用{0}", f.Metadata.Name));
        }
示例#35
0
 /// <summary>
 /// Call the SAP remote function
 /// </summary>
 /// <param name="function"></param>
 /// <param name="rfc"></param>
 private void InvokeSAP( SAPFunction function, IRfcFunction rfc)
 {
     try
     {
         DateTime start = DateTime.Now;
         rfc.Invoke(this.Destination);
         DateTime end = DateTime.Now;
         TimeSpan total = end.Subtract(start);
         double seconds = total.TotalSeconds;
         double milliseconds = total.TotalMilliseconds;
     }
     catch (Exception ex)
     {
         LogException(ex, function);
     }
 }