Getting blank value for filters using via request page

I want to filter posting date and location code from item ledger table. I have created global variable for date as Postingdate -> Date, locationcode -> Code

In C/al code  I write the 

SETRANGE ("Posting Date", Postingdate);

SETFILTER ("Location Code", Locationcode); in OnPreDataItem () trigger

 When i run the code and i filled the values for Posting Date and Location Code. But the filter fetches only empty value.

Please help me? What are the steps to be done to filter based on location and date?