You need to provide some additional information.
How long will you be in Japan? Will your friend be hosting you the whole time? Will he or she be showing you around the country or will you be on your own for part of the time? Do you have plans to travel around the country on your own or will you be traveling with friends?
I would personally avoid taking a longer flight with a stop-over in another country just to save a few dollars. The savings would have to be in the hundreds to convince me to travel USA-Japan via China. Total travel time would likely be 8 hours or more extra.
Have you looked at an "open jaw" flight wherein you fly into Tokyo and fly home from Osaka (KIX)? Or the other way around? That can save some back-tracking and some time and perhaps some money.
IF you will be purchasing a Japan Rail Pass anyway and IF you will have a little time to spend in Tokyo before you need to be in Osaka, then flying into Tokyo instead of Kansai International near Osaka might make sense. I wouldn't suggest buying the Rail Pass just to get to and from Tokyo but some other travel could make it economic. Again, how long you will be traveling around Japan can make a difference. The Rail Pass comes in 7- and 14-day versions (and longer but that is very expensive.) If you can do all your longer train travel within 7 days, it can be very economic. If you use it for the round-trip Tokyo-Osaka-Tokyo plus at least one-way on the airport train (Narita Express) it will just break even if it is all within the 7- or 14- days your Rail Pass will be valid. Any additional travel within the 7 days is just gravy. If you would be flying in via Tokyo and out via Osaka, then you would need more rail travel - such as to Hiroshima and back - to make it work out economically.