I have just created a document within SAP using create transaction. The Document number appears in the status message. How do I capture the document number?

There are two ways of retrieving the document number.
If you are using an input script to create document, simply go to the corresponding change or display transaction. The document number will be stored on the screen. Or you can use "Search" option in the set command with _message variable.

Example: Let's assume that your status message is: "Document 12345678 is created"
GuiXT will store this message in _message variable.

Set V[doc_number] "&[_message]" "Search=Document"

The above command searches for a word Document and Returns the next word to it. In this case variable doc_number will contain value 12345678