public DataTable ObtenerDatosCobranza() { 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(); } try { IRfcFunction function = rfcDest.Repository.CreateFunction("ZSD_REXSAP_009"); RfcRepository rfcRep = null; IRfcTable cliente; cliente = function.GetTable("TI_KUNNR"); BdConnection bd = new BdConnection(); foreach (Cliente cli in bd.GetCliente()) { cliente.Append(); cliente.SetValue("SIGN", cli.SIGN); cliente.SetValue("OPTION", cli.OPTION); cliente.SetValue("LOW", cli.LOW); cliente.SetValue("HIGH", ""); } function.Invoke(rfcDest); IRfcTable doc = function.GetTable("IT_DOCSAPREX"); DataTable table = IRfcTable_To_DataTable(doc, "IT_DOCSAPREX"); return(table); } catch (RfcBaseException e) { e.ToString(); return(null); } }
public DataTable ObtenerStock() { DataTable dt = new DataTable(""); 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; RfcRepository rfcRep = null; try { rfcDest = RfcDestinationManager.GetDestination(rfc); rfcRep = rfcDest.Repository; } catch (Exception e) { e.ToString(); } IRfcFunction function = rfcRep.CreateFunction("ZSD_REXSAP_006"); IRfcTable material; material = function.GetTable("TI_MATNR"); BdConnection bd = new BdConnection(); foreach (TI_MATNR mat in bd.GetMaterial()) { material.Append(); material.SetValue("SIGN", mat.SIGN); material.SetValue("OPTION", mat.OPTION); material.SetValue("LOW", mat.LOW); material.SetValue("HIGH", ""); } try { function.Invoke(rfcDest); IRfcTable doc = function.GetTable("MSTOCKS"); DataTable table = IRfcTable_To_DataTable(doc, "MSTOCKS"); dt = table; return(dt); } catch (RfcBaseException e) { return(null); } }