This code should get you what your looking for. Good Luck!
// Adapter:
IPredicate filter = PredicateFactory.CompareValue(arrecFieldIndex.branch_id, ComparisonOperator.Equal, "01");
DataAccessAdapter adapter = new DataAccessAdapter();
Integer max = (Integer)adapter.GetScalar(EntityFieldFactory.Create(arrecFieldIndex.arrec_no), null,
AggregateFunction.Max, filter, null);
// selfservicing:
arrecCollection col = new arrecCollection();
IPredicate filter = PredicateFactory.CompareValue(arrecFieldIndex.branch_id, ComparisonOperator.Equal, "01");
Integer max = (Integer)col.GetScalar(arrecFieldIndex.arrec_no, null, AggregateFunction.Max, filter, null);