Hi,
You can check whether the program is running in background or foreground using system variable
SY-BATCH.
ABAP System Fields - BC - ABAP Programming - SAP Library
Once you get whether the program is running in foreground or background, you can set the screen accordingly in BDC.
Regards,
FB