Then I see 10 iterations from DB1 to DB10, and 5 iterations from G1 to G5.
If you drop the idea of looping through the data, and in stead called the data in the "normal" way, it would be dead easy.
It would also be a small job, because you would have to program an FB or FC where you process f1 to f5. This one you call in another FB or FC which you call 5 times, and you call this FB or FC in another FB or FC another 10 times. You just have to do the repetitive coding 10 + 5 times = 15 times.
Start thinking "reusable code". You can do this in FBs + IDBs, even as multiple instance, or you can do it as FCs + UDTs.
If I had to loop through this data in really large volume, then I would resort to SCL and be done with it in 5 minutes.