One simple way is to use c_trace
What you need to do is to trace a small way from a point on the player where the hands of the grabbing animation should be(way above his head usually)
When you go up to a low wall and check the c_trace it should give you the distance to the wall.
When you jump, the c_trace distance will dramatically change if it passes over the top of the wall. It should return a 0 as the trace hits nothing as it only traces a small distance.
Use this as a basic indicator to then tell your character that he is at the top of a wall and then stop his gravity/ z movement so he hangs there.
One other thing is to rotate the player to the ledge so that the hanging animation fits to the rotation of the ledge.