To sum up these posts:
Either this popup is a standard message popup (statement MESSAGE of TYPE 'I', 'W',or 'E'), then you may call the function module by intercepting the special classic exception "ERROR_MESSAGE", which will get rid of popups for message type 'I' or 'W' (and messages 'E' will be intercepted).
Otherwise, for other types of screens, as Thomas Jung used to say, "BAPIs are supposed to be safe to call without dynpro." and "I would encourage you to open an OSS problem with SAP when you find something like this"
As a workaround, if the symtom happens while you're executing the BAPI in dialog, but it works in background, then the BAPI has been written to allow 2 behaviors, one with SAP GUI, one without SAP GUI, then you may run the BAPI in background. In case the BAPI is called from a non-ABAP program, then an RFC connection may be started with dialog mode off.