Note: Attached script will not work beyond 11138 SDP Version.
We can use custom schedule to achieve this requirement.
Step 1: we have to run the below query in query report and save the report.
select userid,reportingto from sduser where status='ACTIVE' and reportingto is not null
Configure the saved report in custom schedules.
Step 2: Configure the set linemanager script in admin-> change custom scripts.