In a user program, you can programmatically set the commanded axis. For a command in a user program, the Commanded Axes has an option called Default Axis. The _CurAxis tag defines the Default Axis for the task on which the user program is running. Therefore, you can use a variable to set the Default Axis.
Notice that _CurAxis is a DINT.