Since this section is the only place where rows are placed into #db_ledger:
>insert into #db_ledger
>SELECT *
>FROM GENLED
>WHERE GLCD = @LEDCODE AND GLDT >=@FROMDATE AND GLDT <= @TODATE
>ORDER BY GLDT
>
Maybe there are no rows in GENLED for the date range that you're calling it with??
-Mike