Make sure your form class implements SysIFilterProvider interface. as shown in image.
On Init method initialize your filter control change event from which you will get the value for filter your records as shown in image.
Write parmFilter method on which you passes the value to your form part as shown in image.
In SysFilterValueFactory class there are six types of filters that you can use. In my case I am using RecId filter.
Write parmChangeEvent as shown in image.
Implement SysIFilterConsumerForm, SysIFilterEventHandler Interfaces to your form part classes as shown in image.
Write register & fiter events and provide implementation of your datasource as shown in image.