An agricultural machine for working grass, hay or other crops on the field, comprises a frame, a rake member arm mounted on the frame, and a rake member. The rake member comprises a centre body rotatably mounted on the rake member arm, at least one rake element arm extending from the centre body, and one or more rake elements mounted on the rake element arm. The rake element arm comprises a first arm part and a second arm part, which are pivotally connected to each other between a working position and a transport position. The rake member comprises a locking device for locking the first arm part with respect to the second arm part. The locking device comprises a locking pin movably mounted on the first arm part between a locking position and a releasing position. The locking device comprises a first slot and second slot which are mounted on the second arm part. The first slot is arranged to receive the locking pin in the locking position when the first arm part and the second arm part are positioned in the working position to lock the first arm part with respect to the second arm part in the working position. The second slot is arranged to receive the locking pin in the locking position when the first arm part and the second arm part are positioned in the transport position to lock the first arm part with respect to the second arm part in the transport position.