This is possible even without a regular visa if your stay in China is less than 24 hours . You need to have your connecting ticket from Beijing at hand before boarding your flight to China or the airline in Vietnam will not let you on board. At the airport in Beijing you need to go immediately to the transfer desk (72 hour Beijing visa desk) within the international zone to get your visa stamp allowing you to enter China for one day. Pick up your stuff and make sure you leave China within 24 hours or you will be stuck for at least a week (that is how long it will take to process a new visa needed for leaving the country).
As of 2013 in the case of Beijing you can stay up to 72 hours with this visa. But be reminded that you are NOT entitled to leave the Beijing Municipality!