If the buildings themselves possess an expansion joint and are compressing and moving independently of the pipe that's housed within, I would recommend splitting the analysis into 3 parts - what happens before the expansion joint, what happens after the expansion joint, and what happens at the expansion joint.

It is your responsibility to ascertain and estimate (or design!) the distance from the expansion joint at which point the pipe is unaffected by the expansion joint.

Thus, all 3 of your models will have displacements where they connect to the other models, but you don't have to risk user error or CAESAR non-convergence problems through mass input of displacements everywhere.