Thanks a lot for your suggestions.
I'm not a programmer and I need to have a solution as soon as possible so, at the moment, I'll keep the abap code as I wrote in my previous reply. It seems to perform relatively fine.
In the future I'll check all your solutions and I hope to improve my code with all your replies.
Thanks again.
Regards.