SAP Buildmap rule


We have a requirement where we need to skip some accounts from SAP HR source. for this purpose we have added a custom attribute in the extra attributes BAPI - attribute name MAIN_RECORD. Now we need to aggregate only the accounts with MAIN_RECORD=Y.
This cannot be achieved by aggregation filter BAPI as its a custom attribute, could you please help me here .
I am trying to write a build map rule to achieve this filter of records, not sure how do I skip the records in the code.