Masturbation (male form).
A flam is a musical term, meaning "a drumbeat consisting of two notes in quick succession, with the accent on the second." Flamming as a verb means "to deceive; delude; cheat."
In the expression "flamming the ham," the meaning of flamming is primarily the musical one, i.e., the noun form, but modified to, in effect, coin a verb -- and is used in the sense of beating (as in a drum).
There's no need to expound on the meaning of "ham," is there?
Yeah, it was another washout of an evening, no chemistry, no fun, no interest, so I ended up at home again, flamming the ham, as usual.