what do you mean by "so as the TO which needs te be created automatically" r u facing problem with TO creation or the queue determination for the TO.
If it is related to Queue then Please ask your developer to put a breakpoint at function module L_TO_QUEUE_SET and let you know what is the exact error