In the year of this poem, 1793, Burns has two related to wars, one about Bannockburn and the other on the victory by Admiral Rodney against the French fleet in 1782, where the French lost 9000 killed and injured to 1000 by the English. 1793 was also the start of the 22 year war against France.
I don't know if these were the inspiration, or was he referring to the battle of Culloden, when the Scots were routed by the Duke of Cumberland in 1746.
I am no expert on Burns, so just a few thoughts from an amateur!