示例#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));
        }
示例#2
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));
        }