What is the use of message variant and message function in IDoc partner profile? Which one to be used as per the requirement?
As above mentioned they are key to uniquely identifying a process code/Function Module for processing of the incoming or outgoing IDOCs. A couple of examples are company, plant specific IDOC processing. If you perform any custom processing we can read this value from within a user exit and functions to process differently based on the value.
Its also useful for further selection of IDOCS in reports as shown below.
Note a simple suggestion, define a standard for their use and publish it internally, over time things can get messy.