While heating the olive oil in a saucepan or a deep frying pan, cut finely the onions. Before the oil starts boiling, add the onion and the beans and cover the pan.
Cook slowly, with a very low heat, stiring ocasionally so the beans can be cooked. When the beans become soft, add some ham previously cut in thin slices and some in small cubes. Stir and cover the saucepan,leaving the beans in the fire 5 minutes more. Serve.
The beans with ham are usually served with fried egg and bread.