Hi,
You could create a BDC Recording for WDYID transaction and populate the STARTMODE dynamically and call the BDC Transaction. Or create 2 separate transaction with STARTMODE as GUI and BROWSER and then call the corresponding transaction based on condition.
hope this helps,
Regards,
Kiran