How do I iterate through all subelements of one transaction in SAP?

I want to lookf for specific transaction, and when get in it, I want to click on every subelement (cost center) that is in and extract data. How can I make loop, so that i click on every subelement that exists in that transaction? I dont want to click on every element by myself? Thank you in advance!

@Ida_L this can probably be done. Could you post a screen shot or maybe click on a few elements with the macro recorder and post that. Also, what is the T-code? I just need a little more info to help.