If you have one flight with one flight code (IB6977), you will get miles which equals the direct distance between your originating point to your final destination point. CAI-MAD will be approximately 2085 miles, even if the flight is CAI-BCN-MAD (2109 miles). If your flight is CAI-BCN you would get 1808 miles.
According to my own experience this will also apply if you have a change of plane but you continue with the same flight code. I had this experience once when flying from EZE to MEX on LAN Chile via SCL. There was an aircraft change in SCL, but flight code remained the same and I got miles for the direct distance between EZE and MEX.
Also in mileage based tickets (such as Global Explorer), miles are calculated according to direct distances.