You can use the Extract Function to clean up your lengthy or overly-complicated functions.
When you extract a function, note that the Extract Function is disabled if the code fragment that you select is in an interface, record, external type, form, or form group parts that cannot contain function declaration.
To extract a function, complete the following steps: