In normal screen, debugging can be switched on by entering /H in command field. However, if you have dialog box being displayed you will not have access to command field to switch to debugging mode.
You can get around this problem by creating a /H command shortcut and drag-drop that to dialog box.
To create /H command shortcut right click on your desktop and choose ‘SAP GUI Shortcut’
Rename the shortcut to something you prefer. I usually rename it to Debug.
Now right click on shortcut and choose Edit and in screen enter following value as highlighted in below screen shot. Obviously System Description and Client will be different. Although we have specified System here it can be used in any SAP session irrespective of whether you are logged in to development, quality or live.
Next time you have dialog box and you want to switch to debugging just drag drop this shortcut to SAP screen.
You should see message ‘Debugging switched on’ in status bar as confirmation and PAI will be trigged in debug mode.