What you want to do, while theoretically possible, would be very challenging to achieve. Let me explain:
You'd need to find an apartment that either was already being used for business purposes (can't think of any), or buy one and re-purpose it for it. This second option would be a complete nightmare. First of all, you'd have to convince the majority of the neighbors to approve this change. It would be easier for you to win the lottery than to achieve that majority. No community will allow you to open a business within a residential building, much less in the rooftop. They would be concerned about people coming and going all the time, use of the elevator, security, etc.
Should you achieve that, you'd still need to get all the necessary permits from the city council to carry out this transformation. Getting a yes from them would be as unlikely as getting one from the neighbors. Also, Barcelona has way too many bars (at least the city council thinks so), so they are not issuing food and beverage licenses for all the interesting neighborhoods (Gràcia, Eixample, Sant Antoni).
Where does this leave you?
You either buy a license and the right to operate a F&B business from a current owner (you'd have to use the same space, although you'd be able to re-purpose it). You'd pay for the transfer of the business and for the transfer of the lease. Depending on the size, location and licenses owned by the current owner, you'd be looking to a figure starting at 10.000€ in the less popular neighborhoods, and going up as high as you can imagine.
You find a building in a not-so-hot neighborhood (or an empty lot), and present your project to the city council in order to open and operate your business idea.
All in all, you are looking at quite a tedious enterprise, not only cost-wise (minimum 100.000€, and that's being wildly optimistic), but also time consuming.
Here's a page were you can find businesses that are currently available for transfer. I'd suggest you use the word "terrado" (an approximate translation for rooftop), if you're interested in searching for properties that might fit what you're looking for.
Also, although this is a given, do NOT embark into this without consulting and having someone seasoned in Barcelona bureaucracy. Doing so will just ensure you get scammed and lose a lot of money.
Best of luck!