How to set Lock Rotation in code

In the Editor it is possible to Change the the Constraints especially Lock Rotation (what I want to modify) from a Pawn (or any other Actor).
But I couldn’t find the variable (or function) to modify it in the Pawn class (obiously in the Constructor). Is there any way to modify it? Or did I missundstand something?

More Details:
I have a custom Pawn with an capsualComponent as collider (physics simulated RootComponent ). The Problem is, everytime I run against a wall the Pawn is falling down (which is physically correct and something I expected)
I Need to Lock Rotation in the X- and Y-axis (without the freedom to rotate in these axes it is not possible to fall down).

Probably a bit late, but I believe you can achieve this by setting the public variables [FONT=Courier New]bLockXRotation and [FONT=Courier New]bLockYRotation in the [FONT=Courier New]BodyInstance. e.g.

Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
Mesh->BodyInstance.bLockXRotation = true;
Mesh->BodyInstance.bLockYRotation = true;

Note for those who stumble upon this and could use this info for actors without Meshes or that have other colliders:
UShape components such as Sphere, Box or Capsule Collision also have a BodyInstance member used to Lock Rotation and Location by Axis.

MyUShapeComponent->BodyInstance.bLockXRotation = true; //Locks rotation (prevents rotation changes) around the X axis
MyUShapeComponent->BodyInstance.bLockXLocation = true ///Locks location (prevents location changes) along the X axis