public async Task <BomOutputParameter> GetBillOfMaterialAsync(string materialCode, string plantCode, string alias = null) { 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 IRfcClient client = _serviceProvider.GetRequiredService <IRfcClient>(); if (!string.IsNullOrWhiteSpace(alias)) { client.UseServer(alias); } BomOutputParameter bomResult = await client.ExecuteRfcAsync <BomInputParameter, BomOutputParameter>("CS_BOM_EXPL_MAT_V2_RFC", inputParameter); return(bomResult); }
public async Task <MaterialSaveDataBapiOutputParameter> CreateMaterialAsync() { var inputParameter = new MaterialSaveDataBapiInputParameter { HeadData = new HeadData { MaterialCode = "HSN000000000000030", MaterialType = "7100", Sector = 'B', IsBasicView = 'X' }, MaterialDescription = new MaterialDescription { Name = "Plastik Palet 100 'Lük", LanguageCode = "TR" }, ClientData = new ClientData { MaterialGroup = "71000010", BaseMeasurementUnit = "ST", BaseMeasurementUnitIso = "ST", Divison = "15", ProductionHierarchy = "ZZZ", StorageCondition = "I3" } }; using IRfcClient client = _serviceProvider.GetRequiredService <IRfcClient>(); using IRfcTransaction transaction = client.CreateTransaction(); using IRfcTransactionFunction func = transaction.CreateFunction("BAPI_MATERIAL_SAVEDATA"); await func.InvokeAsync(inputParameter); transaction.SubmitTransaction(); transaction.ConfirmTransaction(); MaterialSaveDataBapiOutputParameter result = func.ReadSubmitResult <MaterialSaveDataBapiOutputParameter>(); return(result); }
public List <ParameterMetaData> GetFunctionMetaData(string functionName) { using IRfcClient client = _serviceProvider.GetRequiredService <IRfcClient>(); List <ParameterMetaData> result = client.ReadFunctionMetaData(functionName); return(result); }
public async Task <List <Material> > GetMaterialsByPrefixAsync(string materialCodePrefix, int recordCount = 5) { List <string> whereClause = new AbapQuery().Set(QueryOperator.StartsWith("MATNR", materialCodePrefix)) .And(QueryOperator.NotEqual("LVORM", true, RfcDataTypes.BOOLEAN_X)).GetQuery(); using IRfcClient sapClient = _serviceProvider.GetRequiredService <IRfcClient>(); return(await sapClient.GetTableDataAsync <Material>(whereClause, rowCount : recordCount, includeUnsafeFields : true)); }
public async Task <Material> GetMaterialAsync(string materialCode) { List <string> whereClause = new AbapQuery().Set(QueryOperator.Equal("MATNR", materialCode)) .And(QueryOperator.NotEqual("LVORM", true, RfcDataTypes.BOOLEAN_X)).GetQuery(); using IRfcClient sapClient = _serviceProvider.GetRequiredService <IRfcClient>(); return((await sapClient.GetTableDataAsync <Material>(whereClause)).FirstOrDefault()); }
public async Task <VendorBapiOutputParameter> GetVendorsByCompanyCodeAsync(string companyCode) { var inputParameter = new VendorBapiInputParameter { CompanyCode = companyCode }; using IRfcClient sapClient = _serviceProvider.GetRequiredService <IRfcClient>(); return(await sapClient.ExecuteBapiAsync <VendorBapiInputParameter, VendorBapiOutputParameter>("BBP_VENDOR_GETLIST", inputParameter)); }
private List <Task> SetMaterialCategoryOptionAsync(MaterialQueryOptions queryOptions, List <Material> materialList, ConcurrentQueue <MaterialCategoryDefinition> materialCategoryDefinitionList, SemaphoreSlim semaphoreSlim = null) { var taskList = new List <Task>(); if (!queryOptions.IncludeMaterialCategory) { return(taskList); } var materialCategoryList = materialList.Where(x => x.MaterialCategoryCode != null) .Select(x => (object)x.MaterialCategoryCode) .Distinct() .ToList(); List <object>[] materialCategoryParts = materialCategoryList.Partition(PartitionCount); foreach (List <object> part in materialCategoryParts) { List <string> queryList = new AbapQuery() .Set(QueryOperator.In("ZZEXTWG", part)) .GetQuery(); taskList.Add(Task.Run(async() => { try { if (semaphoreSlim != null) { await semaphoreSlim.WaitAsync(); } using IRfcClient client = _serviceProvider.GetRequiredService <IRfcClient>(); List <MaterialCategoryDefinition> definitions = await client.GetTableDataAsync <MaterialCategoryDefinition>(queryList, includeUnsafeFields: true); foreach (MaterialCategoryDefinition definition in definitions) { materialCategoryDefinitionList.Enqueue(definition); } } finally { if (semaphoreSlim != null) { semaphoreSlim.Release(); } } })); } return(taskList); }
public async Task <GetJobOutputParameter> GetJobsAsync() { var inputParameter = new GetJobInputParameter { StartDate = $"{DateTime.Today:yyyyMMdd}", EndDate = $"{DateTime.Today:yyyyMMdd}", Status = "A", ProgramName = "Z*", ClientCode = "200" }; using IRfcClient sapClient = _serviceProvider.GetRequiredService <IRfcClient>(); return(await sapClient.ExecuteRfcAsync <GetJobInputParameter, GetJobOutputParameter>("ZBC_GET_JOBS", inputParameter)); }
public async Task <GoodsMovementBapiOutputParameter> MaterialTransferAsync() { var inputParameter = new GoodsMovementBapiInputParameter { Header = new Header { DocumentDate = DateTime.Now, PostingDate = DateTime.Now }, MovementType = new MovementType { MovementTypeCode = "04" }, Items = new MovementItem[] { new MovementItem { MaterialCode = "", PlantCode = "", WarehouseCode = "", MoveType = "413", ValueType = "", Quantity = 1, QuantityMeasurementUnitType = "ST", MovementMaterialCode = "", SpecialStockIndicator = 'E', SalesOrderNumberOld = "", SalesItemNumberOld = "", OrderNumber = "", OrderItemNumber = "", MovementPlantCode = "", MovementValueType = "", MovementWarehouseCode = "" } }, SerialNumbers = new MovementSerialNumber[] { } }; using IRfcClient client = _serviceProvider.GetRequiredService <IRfcClient>(); using IRfcTransaction transaction = client.CreateTransaction(); using IRfcTransactionFunction func = transaction.CreateFunction("BAPI_GOODSMVT_CREATE"); await func.InvokeAsync(inputParameter); transaction.SubmitTransaction(); transaction.ConfirmTransaction(); GoodsMovementBapiOutputParameter result = func.ReadSubmitResult <GoodsMovementBapiOutputParameter>(); return(result); }