How Do I Control the Initial Focus Within Tab Pages/Grids/Search Pages?
The system automatically places the initial focus on an appropriate widget (generally input fields) within a Tab Page/Search Page/Grid.
By default it will place focus on the first enabled field with a data class defined on it. (If input fields do not have the Field Name / Table Name defined within Meta Data they will have no data class)
If there are no fields satisfying this criteria within the tab page it will continue to look (recursively) into all the contained frames (e.g. list grids etc.)
If no field is found then no element receives focus.
You can override the default behavior at each level via the provision of a focusWidgetOverride() function within the user exit file which will return the Name of the Field to receive the focus or null.
If null is returned it will ignore all fields within this document and continue to search in lower level documents.
E.G.
From within a Tab Page (If you want focus to go on to a sub document)


function focusWidgetOverride() {
  return null;
}

From within a List Grid

function focusWidgetOverride() {
  return "TD_TYPE_DRLKY:0$TBL_NAME";
}

from within a Search Page

function focusWidgetOverride() {
return "LAST_NAME";
}

Note:
These functions can be as simple or complicated as you want. You could conditionally return a field name or null and this code will run each time the window loads. Also, if a tab page has a popup window or a search window open as it is loading then the initial focus will not be set to the tab page but stay with the popup window