If the pipeline is long, it can be very helpful to divide the line up in segments. All computer analysis programs capable of transient gas analysis do it. Whether you need to break your line up into segments, depends on the conditions you have in the pipeline at the time. With 400 km, I think its a good idea to use segments. Its easy in Excel to do it. Over that length you probably have gas with greatly different pressures and temperatures, which will have different compressibility factors and the line pack will vary in each segment. If you had a diameter change, then you would have to break into segments.
I'd use the average gas pressure in each segment, if each were "short", and note that average pressure is not (P1+P2)/2, but more closely follows,
Pavg = 2/3 * (P1 + P2 - (P1 * P2)/(P1 + P2))
Then calculate the compressibility using that pressure and the average temperature (T1+T2)/2
Pressures and temperatures must be absolute.
Just to see if I've been wasting my time talking about this, take only 1 segment of 408 km and using the max and min pressures, calculate the line pack. Then calculate it again using each of your segments and tell us what the difference is. I think you'll easily have a difference of 10% or more.
**********************
"The problem isn't finding the solution, its trying to get to the real question." BigInch