Law & Order often takes from reality. The ham sandwich phrase is attributed to Solomon Wachter who was a judge on the New York court of Appeals and is anecdotally dated to the mid or late '80s. And then went widely into the culture and has shown up in novels, academic papers, and tv.