Maybe there is a misunderstanding.
Do you have a message mapping?
If yes.
The source will be an IDOC. With control segment EDIDC40 and the field DOCNUM.
So you have the data that you need
In the mapping, you create the UDF to set the JMS variable