I’m not an ABAP expert, so I really don’t know of a way to easily retrieve the Idoc number that was assigned to the inbound message. The RFC mentioned above will not give you that functionality. Basically, SAP assigns a range of Idoc numbers to each app server, so depending on which app server you hit your message will be assigned a number in that range.
I would talk with the ALE guru on your project to find out if there is a way to configure the ALE Layer to return the Idoc numbers that are assigned to the messages when they post. They may need to write a custom program to do this because the flow service created from the inbound routing rule does not return the numbers.