Whisk the eggs, add salt and gradually stir in the flour. Only add enough water to make a very thick spaetzle dough. Simmer through a spaetzle sieve in boiling salted water, bring to the boil once, remove from the water and immediately rinse with cold water.
Melt the butter in a pan, fry the finely chopped onion until golden brown and add the ham cut into cubes, fry briefly. Add the spaetzle to the pan and toast it well, season with salt and pepper. Pour the grated cheese over it and let it melt.