Source Code Editing of Global Classes
The following source code shows a typical ABAP class. You recognize the declaration part, where components are declared in their visibility sections, and the implementation part, where methods are implemented.
Because we all know that local classes are edited in the ABAP Editor while the global classes of the class library are created with the Class Builder, where you enter the class definition via input masks, I would expect that everbody will say now: “This is clearly a local class!”,
But wrong, the above class is not a local but a global class. If you paste it into a normal ABAP program, you will receive a syntax error. The reason is the “PUBLIC” addition behind “DEFINITION”. This little syntax difference is all what you need, to define a class as a global class in the class library. And as you surely know, such classes are only allowed in class pools, which can only be handled via the Class Builder. In a class pool, the above class would be perfectly correct and, in fact, the Class Builder does nothing more than generating such a class from your inputs on its screen (of course the source code is distributed over a set of internal Include programs).
Why do I show this? First, I want to point out that besides that little “PUBLIC” local and global classes are basically the same. Second, it becomes clear from that simple example that defining classes in the form based Class Builder seems to be quiet an overkill. If you like hacking more than clicking, the handling of the class builder can be pretty cumbersome. This is especially true since the release of the new ABAP Editor, where the code completion does most of the typing work for you anyway.
As a consequence, wouldn’t it be nice to edit global classes like local classes in the ABAP Editor where you have all the source code in front of you and on your fingertips? The good news is: As of Release 7.1, you can toggle between the well known form based mode and a new source code mode in the Class Builder. The source code mode will fulfill exactly the demands: Any global class can be shown as above in the ABAP Editor (and this even without giving up the distribution of the class in Include programs – you simply don’t see them). The bad news is, of course: The new source code mode is only available as of Release 7.1 🙁
But heads up folks. Did you know that the current class builder already offers a feature that is very close to real source code based editing? The secret lies behind the menu entry “Goto”. You can select “Public Section”, “Protected Section”, and “Private Section” there! This navigates you directly to the ABAP Editor, where you can edit the source code of these sections (see Figure). In fact, if you want to define new data types, structures or internal tables you can only do so by navigating into these sections (the yellow button “Direct Type Entry” on the “Types” and “Attribute” tabs also serve this purpose). After saving such a section, all your changes will be reflected in the corresponding Class Builder screens.
To summarize, all relevant parts of the source code of a global class can be edited in the ABAP Editor already now: the “CLASS” statement for changing the class options, the three visiblity sections, and – of course – the method implementations. Doesn’t this add some sugar to the waiting time for Release 7.1 and the real source code based editing?
In Chapter 4 of the book “ABAP Objects – ABAP Programming in SAP NetWeaver” you find more about creating and editing global and local classes.