  Filament S242 is 25 pc long with massive clumps and YSO clusters concentrated
in its end regions; it is considered a good example of edge collapse. We mapped
this filament in the $^{12}$CO(1-0) and $^{13}$CO(1-0) lines. A large-scale
velocity gradient along filament S242 has been detected; the relative velocity
between the two end-clumps is $\sim$ 3 km s$^{-1}$, indicating an approaching
motion between them. These signatures are consistent with the filament S242
being formed through the collapse of a single elongated entity, where an effect
known as "gravitational focusing" drives the ends of the filament to collapse
(edge collapse). Based on this picture, we estimate a collapse timescale of
$\sim$ 4.2 Myr, which is the time needed for a finite and elongated entity
evolving to the observed filament S242. For the whole filament, we find that
increases in surface densities lead to increases in velocity dispersion, which
can be consistently explained as the result of self-gravity. We also calculated
the contribution of longitudinal collapse to the observed velocity dispersion
and found it to be the dominant effect in driving the gas motion near the
end-clumps. We propose that our filament S242 is formed through a two-stage
collapse model, where the edge collapse of a truncated filament is followed by
a stage of longitudinal accretion toward the dense end-clumps.
