SETRANGE ,SETFILTER AND GET FUNCTIONS
Difference between SETRANGE and SETFILTER:
1) When we apply filter using SETRANGE it directly applies filter with the given value where as SETFILTER converts the given value into text and then applies filter.
2) By using SETRANGE we can not filter multiple values at a time where as in SETFILTER we can filter multiple values at a time. (But using both SETFILTER and SETRANGE we can filter a range of values).
Ex: Customer.SETRANGE (“NO.”,’10000’); In this case we can filter only customer no. 10000.
Customer.SETFILTER (“No.”,’%1%2’,’10000’,’20000.); Here we can filter customer No.10000 as well as 20000.
3) By using SETRANGE we can not avoid one single record or multiple records where as by using SETFILTER we can.
Ex: Customer.SETFILTER (“No.”,’<>%’,’10000’);
Note: In all examples Customer is the Record type of variable and Var1, Var2, Var3…. are the variables.
SETRANGE:
1) When we are directly supplying value through a variable.
Customer.SETRANGE (“No.”,’10000’);
2) When we are assigning value to a variable and then applying filter.
Var1:= ‘10000’;
Customer.SETRANGE (“No.”, Var1);
3) When we are applying filter on one table using another table’s record.
For example we want to know the state code of particular transaction’s customer which is there in ‘Customer Ledger Entry”.
In that case first we need to first find out the record in “customer Ledger Entry” and then apply filter on “Customer” table with that ‘Customer No.’.
Ex: CLE.RESET;
CLE.SETRANGE (“Document No.”,’0000001’) ;{ in this it is understood that we know the document No.}
If CLE.FIND (‘-‘) then
CUSTOMER.GET (CLE.”Customer NO.”); {In this case we can use GET Function or SETRANGE}
OR
CUSTOMER.SETRANGE (“No.”, CLE.”Customer No.”);
SETFILTER:
Filtering multiple values using SETFILTER:
If we want to filter multiple values using SETFILTER we need to follow the following syntax.
CUSTOMER.SETFILTER (“No.”,’%1%2’,’10000’,’20000’);
If we want filter a table except one record or multiple records the syntax is
CUSTOMER.SETFILTER (“No.”,’<>%1&<>%2’,’10000’,’20000’);
Difference between GET function and (SETRANGE & SETFILTER) :
When we know the all primary key field values of a record we use GET function (After using the GET function we don’t need to find the record like Rec.FINDFIRST or Rec.FINDLAST)., where as we use SETRANGE & SETFILTER when we want to filter the records on fields other than the primary key fields. (When we use GET function we need to pass all the primary key fields if the primary is a combination of multiple fields).
1) When we apply filter using SETRANGE it directly applies filter with the given value where as SETFILTER converts the given value into text and then applies filter.
2) By using SETRANGE we can not filter multiple values at a time where as in SETFILTER we can filter multiple values at a time. (But using both SETFILTER and SETRANGE we can filter a range of values).
Ex: Customer.SETRANGE (“NO.”,’10000’); In this case we can filter only customer no. 10000.
Customer.SETFILTER (“No.”,’%1%2’,’10000’,’20000.); Here we can filter customer No.10000 as well as 20000.
3) By using SETRANGE we can not avoid one single record or multiple records where as by using SETFILTER we can.
Ex: Customer.SETFILTER (“No.”,’<>%’,’10000’);
Note: In all examples Customer is the Record type of variable and Var1, Var2, Var3…. are the variables.
SETRANGE:
1) When we are directly supplying value through a variable.
Customer.SETRANGE (“No.”,’10000’);
2) When we are assigning value to a variable and then applying filter.
Var1:= ‘10000’;
Customer.SETRANGE (“No.”, Var1);
3) When we are applying filter on one table using another table’s record.
For example we want to know the state code of particular transaction’s customer which is there in ‘Customer Ledger Entry”.
In that case first we need to first find out the record in “customer Ledger Entry” and then apply filter on “Customer” table with that ‘Customer No.’.
Ex: CLE.RESET;
CLE.SETRANGE (“Document No.”,’0000001’) ;{ in this it is understood that we know the document No.}
If CLE.FIND (‘-‘) then
CUSTOMER.GET (CLE.”Customer NO.”); {In this case we can use GET Function or SETRANGE}
OR
CUSTOMER.SETRANGE (“No.”, CLE.”Customer No.”);
SETFILTER:
Filtering multiple values using SETFILTER:
If we want to filter multiple values using SETFILTER we need to follow the following syntax.
CUSTOMER.SETFILTER (“No.”,’%1%2’,’10000’,’20000’);
If we want filter a table except one record or multiple records the syntax is
CUSTOMER.SETFILTER (“No.”,’<>%1&<>%2’,’10000’,’20000’);
Difference between GET function and (SETRANGE & SETFILTER) :
When we know the all primary key field values of a record we use GET function (After using the GET function we don’t need to find the record like Rec.FINDFIRST or Rec.FINDLAST)., where as we use SETRANGE & SETFILTER when we want to filter the records on fields other than the primary key fields. (When we use GET function we need to pass all the primary key fields if the primary is a combination of multiple fields).
great tutorial
ReplyDeleteThis is what we call the perfection of blog writing. whatever the questions came in my mind during reading this blog i found all of them as goes down..
ReplyDeleteThanks a ton.!!