Beispiel #1
0
        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));
        }
Beispiel #2
0
        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());
        }
Beispiel #3
0
        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());
        }
Beispiel #4
0
        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));
        }