Customer Ok-codes should always be evaluated during PAI of the main-screen. If this is not possible, e.g. the main-screen does not provide a user-exit for Ok-code processing, Customer Ok-codes will have to be evaluated during PAI of the Screen Exit. However, the OK_CODE field of the main-screen is usually not available in Screen Exits and the SY-UCOMM field cannot be used as it is not overwritten by blank Ok-codes, such as scrolling in table controls (the use of the SY-UCOMM field can result in repetitive execution of Customer Ok-codes). The actual Ok-code can be obtained by calling system-function 'DYNP_OKCODE_GET'.
DATA okcode LIKE sy-ucomm. CALL 'DYNP_OKCODE_GET' ID 'FCODE' FIELD okcode. IF okcode(1) EQ '='. SHIFT okcode. ENDIF.