When performing code reviews, one of our checklist items is, "What package did you put your development in?" When asking external developers, we always get a puzzled look, so I'll try and explain why it can be useful. I recently responded to a stack overflow post asking whether ABAP had a similar functionality to libraries in other languages.

If you have worked in ABAP, you know there are no function libraries that you need to include in your code. Now, could you do something similar? Of course, but it's not necessary. All the functions modules, classes, etc. are available to you automatically. The problem is that you need to find them doing a search in the SD network. You'll find a huge amount of posts just asking if there is a Function module, method, or class that does this. Sadly, in most cases there probably is, but developers tend to roll their own because they are not easy to find. The concept of the standard library allows you to add the necessary functionality to your application by adding a library. You can browse the list of functions the library includes. Libraries normally group similar functions - such as, you would expect the System.io namespace/library to include functions to read and write files. But how do you know that? Like most of us, you are probably aware of this through experience - but it's also not hard to find documentation.

In ABAP we can use packages for this purpose. A package closely resembles the UML package construct.

In UML a Package is a general purpose mechanism for organizing model elements & diagrams into groups. It provides an encapsulated namespace within which all the names must be unique. It is used to group semantically related elements. It is a namespace as well as an element that can be contained in other packages' namespaces.

As I mentioned in my response, a package in SAP is a useful tool to be able to group like functions. There are examples in ABAP that are grouped this way. For example, to look for functions/classes involved in client side controls, we would look at the controls package SCET. Here, I will find functions that access the front end controls framework. Certainly not as comprehensive as the System.io namespace, but sure enough I have functions to perform reading and writing of files. 

So, the main reason this has not gotten much attention in ABAP is that the meaning and usefulness of packages has changed over time. In pre-4.6 days, a package was called a development class; the typical use of the package was to group like objects (functions, classes, etc.) that are associated with a project. For example, we would see packages named BestPractices because a company had an initative called BestPractices and thought, "Hey, let's call the development class the same thing." Now, that's great while the project is taking place, but a couple years down the road, no one will know what the BestPractices project is - so what does this grouping in the package mean? You see my point. The name of the package should be useful, with no shelf life, and similar as namespaces and libraries in other languages would be the optimal use.


So if you do roll your own File I/O function, or even better, inherit an exiting SAP class to perform file I/O, then I would suggest developing your own package(s) in meaningful ways. This ensures that in the future, you or the developers that follow you will be able to view your ZfileIO library and find all the functions you made related to file reading and writing.

I'll talk more about packages in my next blog post to continue the discussion.




Go To Top