In abap it is possible to create both local classes, defined within an ABAP program, or create them in the repository, via the ABAP Class Builder ( SE24 or SE80). The difference being that the global class can be used in several reports, and the local class can only be used within the ABAP program it was created in.
Then, if you are creating program specific logic, you can use the a local class. One example of local classes are the one used to Unit Test
a program, or function module, or local class.
Note that with global classes you should use the ABAP UNIT TEST framework, which is another reason that makes working with global classes so compelling.
But sometimes we realize that a class created a a local class would be useful on another context, thus we should change the class from local to global, so that it can be used in that new context. fortunately the ABAP Class builder provides a very useful re-factoring tool to convert a local class to a global one.
This is how to do it.
- SE24->Object type->Import->Local Classes in program
- Select the program and class to be converted to the ABAP repository, and press the import button.
- The class is created in the ABAP repository, and now the programs should be changed to use this instead of the old local class.
Note: This method does not delete the old local class, only creates a duplicate in the ABAP repository. It is a good practice to remove the local class from the program because it will be no longer used.