Ex.1: ビール一杯を飲む >一杯のビールを飲む >ビールを一杯飲む
Ex.2: ネジ2本を取り付ける >2本のネジを取り付ける > ネジを2本取り付ける
Those 3sentences of both ex.1 and ex.2 have the meaning.
As you know, it has a same meaning even if the order of the words(ex.1 ビール、一杯、飲む)(ex.2 ネジ 2本、取り付ける) changes in Japanese.
Someone already mentioned 一杯のビールを飲む sounds more poetic, ビールを一杯飲む sounds natural in both spoken and written language. All 3 sentences are all correct in grammatically.