Madrid cites humanitarian and economic reasons to give undocumented workers legal status.