Hi ALejandro ,
Get the GL Accounts which are required and harcode in your program,
You can go for BSAS table to get the the Accounting: Secondary Index for G/L Accounts (Cleared Items) and pass the Company Code , GLAccount , GJAHR , BELNR and verify the clearing documents AUGBL and clearing date AUGDT. So by going to the BSAS table may be it might improve the performance but check the data carefully.
I hope this will be helpful.
Thanks & Regards,
Raghunadh Kodali.