Are you looking for the short version or the long version? The short version is to guess at it and just filter out air units from the units he's sent to attack, as well as filter out units that have an elevation different than his, but to detect if a unit is inaccessible because there is a wall there, now that is a bit of coding which has several approaches.
1. The only one I am comfortable with:
Check pathability every 24 clicks from where the footman is standing towards his targetted unit. If one of those clicks fails (say, lies over a rock doodad) he will not be issued the order. A flaw in this is that maybe the rock is barely blocking him, yet this system wouldn't know that.
2. Create an item on those clicks, check its x,y position to see if they match the x,y position you assigned it to be at; if it's not, then the pathing is unwalkable.
This requires JASS coding, my friend. Are you ready for that?