File upload in RFC function: We have developed a function module that automates the creation of a Sales Order. The function is called with a single input parameter; the function then uploads a file into SAP; the text file is then read by the function module and the correct fields are populated. But the file upload always aborts with an RFC error message. What could be the reason?

In order to use the "GUI_UPLOAD" function the called function module needs a connection to SAP GUI.
We suggest you use the -dialog option of the Call statement, e.g.
call ZGUIXT_CREATEORDER -dialog in.I_KTEXT="test" ...

The RFC user needs to be a dialog user in this case.

There are two alternative solutions:

for which a dialog RFC user is required

In your function, execute

for which no dialog user is necessary

Read the file in the InputScript, for example using CopyText ... fromFile=...., and pass the file content to the function module (table parameter).