I advise you to research the transit procedures at both airports. Originally Chinese airports did not have international transfer capabilities although I think that PEK T3 does now offer that service.
You can get a 24 hour transit visa and leave the airport if you want (48 hours for some at PVG). I think you always go through immigration, anyway, although if there is a transit system in place you will not be sent out of the airport after immigration.
At PVG you may still have to leave with your luggage and go to check-in (and therefore no re-entry if your airline's counter is not open). Others I am sure have more up-to-date info.