Code to set filters for a report and then save the report as a pdf in NAV 2016

Hello! I need to set the filters of a report in code and then save it as a pdf. I am using NAV 2016. Any help would be greatly appreciated!


To set filter for report:

locRec.SETFILTER or locRec.SETRANGE - set filters for record.

locReport.SETTABLEWIEV(locRec); - After set filters from record to report

locReport.SAVEASPDF(File) - Save report as PDF