Programming Layers

Is there any way to set layers programmatically? If there is please please how?