It happened me to once. I book JFK to HKG on Delta. Delta flight from JFK to NRT screw up, flight got delay and can't connect to next one. They put me on Cathay Pacific. Since Delta booked Cathay Pacific on Y class, I deposit the miles on BA.
After the trip, I called Delta back and asked them deposit original itinerary back to my account since this is not my fault.
I think that's the only way to get miles on 2 programs.