You're correct that you'd need a programmatic way to let Mendix store the file for you. This way Mendix will take care of generating the correct file name and placing it in the correct location.
The alternative you mentioned, copying something yourself to WEBINF/uploadedfiles, is something you should never do, as this is very error prone. (The "uploadedfiles" location is not fixed but is configurable, the file name depends on object data from the database, Mendix could theoretically completely change the way files are saved in a next release, etc)
To instruct Mendix to store a file, you need to create a Java action containing something like the following code:
import java.io.FileInputStream;
import com.mendix.core.Core;
import system.proxies.FileDocument;
...
Core.storeFileDocumentContent(getContext(), FileDocument.create(getContext()).getMendixObject(), new FileInputStream("C:/test.dat"));
Obviously you'd need some more code for a full working solution, but the line with the storeFileDocumentContent call is the important bit here. After this line Mendix will have created a new System.FileDocument object for you with the correct attributes and file content. (By the way, there is also a corresponding getFileDocumentContent function)
One other thing: in the example code above a System.FileDocument object is directly created, but I'd recommend against this. Instead, create some entity in your domain model (in your case you could call it something like SAPImportFile), let that entity inherit from System.FileDocument and use an object of this type in your Java code and micro flows.
EDIT: I noticed you mentioned that the file you're importing is an XML file. If you're using this file as the input for an XML mapping, you'd need a System.XmlDocument object instead of a System.FileDocument object. Because these entities are related to each other, the above still works, just set the created System.FileDocument object as the value of the System.XMLDocument_FileDocument association of a System.XmlDocument object.
However, in this case there's a much simpler option that doesn't involve any Java actions: in a micro flow, create a System.XmlDocument object (or, preferably, an object that inherits from it). Next set the Path attribute of this object with the full (absolute) file name of the XML file generated by SAP that you want to import. You can then pass this object as the argument to your XML mapping.