public BomOutputParameter GetBillOfMaterial(string materialCode, string plantCode) { using IRfcConnection connection = _serviceProvider.GetService <IRfcConnection>(); connection.Connect(); var inputParameter = new BomInputParameter { Aumgb = "0", Capid = "PP01", Datuv = DateTime.Now, Emeng = "1", Mktls = "x", Mehrs = "x", Stpst = "0", Svwvo = "x", Werks = plantCode, Vrsvo = "x", Stlal = "1", Stlan = "1", Mtnrv = materialCode }; using IReadRfc rfcFunction = _serviceProvider.GetService <IReadRfc>(); BomOutputParameter bomResult = rfcFunction.GetRfc <BomOutputParameter, BomInputParameter>(connection, "CS_BOM_EXPL_MAT_V2_RFC", inputParameter); return(bomResult); }
private List <MaterialDefinition> SetMaterialDefinitionOption(MaterialQueryOptions queryOptions, List <Material> materialList) { var definitionList = new List <MaterialDefinition>(); if (queryOptions.IncludeDefinition) { var list = materialList.Where(x => x.Code != null).Select(x => (object)x.Code).ToList(); List <object>[] parts = list.Partition(PartitionCount); foreach (List <object> part in parts) { List <string> query = new AbapQuery() .Set(QueryOperator.In("MATNR", part)) .GetQuery(); using IRfcConnection connection = _serviceProvider.GetService <IRfcConnection>(); connection.Connect(); using IReadTable <MaterialDefinition> tableFunction = _serviceProvider.GetService <IReadTable <MaterialDefinition> >(); List <MaterialDefinition> definitions = tableFunction.GetTable(connection, query); if (definitions.Any()) { definitionList.AddRange(definitions); } } } return(definitionList); }
public Material GetMaterial(string materialCodePrefix, bool getUnsafeFields = true, int rowCount = 0) { var query = new AbapQuery().Set(QueryOperator.Equal("MATNR", materialCodePrefix)) .And(QueryOperator.NotEqual("LVORM", true, RfcTablePropertySapTypes.BOOLEAN_X)).GetQuery(); using IRfcConnection connection = _serviceProvider.GetService <IRfcConnection>(); connection.Connect(); using IReadTable <Material> tableFunction = _serviceProvider.GetService <IReadTable <Material> >(); List <Material> result = tableFunction.GetTable(connection, query, rowCount: rowCount, getUnsafeFields: getUnsafeFields); return(result.First()); }
public List <Material> GetMaterialsByPrefix(string materialCodePrefix, MaterialQueryOptions options = null, bool getUnsafeFields = true, int rowCount = 0) { options ??= new MaterialQueryOptions(); var query = new AbapQuery().Set(QueryOperator.StartsWith("MATNR", materialCodePrefix)) .And(QueryOperator.NotEqual("LVORM", true, RfcTablePropertySapTypes.BOOLEAN_X)).GetQuery(); using IRfcConnection connection = _serviceProvider.GetService <IRfcConnection>(); connection.Connect(); using IReadTable <Material> tableFunction = _serviceProvider.GetService <IReadTable <Material> >(); List <Material> result = tableFunction.GetTable(connection, query, rowCount: rowCount, getUnsafeFields: getUnsafeFields); return(SetOptions(result, options, getUnsafeFields)); }
public VendorBapiOutputParameter GetVerdorsByCompanyCode(string companyCode) { using IRfcConnection connection = _serviceProvider.GetService <IRfcConnection>(); connection?.Connect(); var inputParameter = new VendorBapiInputParameter { CompanyCode = companyCode }; using IReadBapi <VendorBapiOutputParameter> rfcFunction = _serviceProvider.GetService <IReadBapi <VendorBapiOutputParameter> >(); VendorBapiOutputParameter result = rfcFunction?.GetBapi(connection, "BBP_VENDOR_GETLIST", inputParameter); return(result); }
private IRfcConnection GetConnection() { if (string.IsNullOrWhiteSpace(_activeServer)) { if (string.IsNullOrWhiteSpace(_rfcConfiguration.DefaultServer)) { if (_rfcConfiguration.RfcServers.Count == 1) { _activeServer = _rfcConfiguration.RfcServers.Single().Alias; } else { throw new RfcException("The default SAP server could not be detected."); } } else { if (_rfcConfiguration.RfcServers.Exists(s => s.Alias == _rfcConfiguration.DefaultServer)) { _activeServer = _rfcConfiguration.DefaultServer; } else { throw new RfcException("Default SAP server connection settings were not found."); } } } RfcServer server = _rfcConfiguration.RfcServers.Single(s => s.Alias == _activeServer); if (server.ConnectionPooling.Enabled) { IRfcConnectionPoolServiceFactory factory = _serviceProvider.GetRequiredService <IRfcConnectionPoolServiceFactory>(); IRfcConnectionPool connectionPool = factory.GetService(_activeServer); return(connectionPool.GetConnection()); } IRfcConnection rfcConnection = _serviceProvider.GetRequiredService <IRfcConnection>(); rfcConnection.Connect(_activeServer); return(rfcConnection); }
public GetJobOutputParameter GetJobs() { using IRfcConnection connection = _serviceProvider.GetService <IRfcConnection>(); connection.Connect(); var inputParameter = new GetJobInputParameter { StartDate = $"{DateTime.Today:yyyyMMdd}", EndDate = $"{DateTime.Today:yyyyMMdd}", Status = "A", ProgramName = "Z*", ClientCode = "200" }; using IReadRfc rfcFunction = _serviceProvider.GetService <IReadRfc>(); GetJobOutputParameter result = rfcFunction.GetRfc <GetJobOutputParameter, GetJobInputParameter>(connection, "ZBC_GET_JOBS", inputParameter); return(result); }