In this sentence the default position is before the noun, but you cannot generalize that based on grammatical functions. It's a semantical thing.
Ich habe nicht das gleiche Buch. (default)
Ich habe das Buch nicht. (default)
These are the normal versions.
Ich habe das gleiche Buch nicht.
Ich habe nicht das Buch.
These work too but they mean something slightly different. They have something extra, in a way.
The point is that "das gleiche" is the main focus of that sentence and the "nicht" negates that. When it is final, the "nicht" take away focus from "THE SAME" and shifts it to the aspect of possession/non-possession. In the other example it is different. We're talking about a book that has been established before (das) and we introduce a new "verbal configuration" (I + having). The focus is on the whole thing. With the "nicht" before book you'll get a strong focus on book, which is fine too.
Position of "nicht" is something you have to feel. It is not possible to put that into a concise grammatical rule.