Steam the endive. Let it cool and squeeze it well to remove excess moisture.
Melt the butter in a large pot over medium heat until it foams. Then add the flour all at once and let it cook briefly.
Add half of the milk, whisk vigorously to avoid lumps until you have a smooth mixture. Then add the remaining milk and continue whisking until the mixture boils.
Stir half of the grated cheese into the sauce and season with pepper, salt, and nutmeg to taste.
Cook the macaroni according to the cooking instructions on the package.
Cut the ham into strips and add it along with the pre-cooked macaroni to the sauce.
Cut the steamed endive into coarse pieces and stir half into the macaroni mixture. Then pour this into a baking dish.
Spread the remaining endive pieces over the macaroni mixture and sprinkle with the remaining cheese.
Gratin the dish for about 30 minutes in a preheated oven at 190°C until the top is golden brown. Serve the gratin immediately.