Supported by
Supported by Inetum

Fix prefixes

images/thumbnail.jpg - Thumbnail

It’s very easy to mess up with object names in SAP. I recently found a way to minimize that problem: set rules to fix per-package prefixes for certain object types.

You’re working on a development called DEV1. The first thing you do (because you’re a neat person) is to create a package dedicated to that development. You call it, for example, ZDEV1. From here on (and because, unfortunately, SAP still doesn’t have decent namespaces) every object name should include a prefix that associates it with DEV1:

  • Classes: ZCL_DEV1_*
  • Tables: ZDEV1_*
  • Functions: Z_DEV1_*
  • Programs: ZDEV1*
  • etc: ZDEV1*.

This is usually left implicit and up to the goodwill of whoever comes next.

But there is a way to fix these rules for the future: SM30 V_TRESN. Isn’t it great? You can set prefixes by package and object type.

An example for our case would be:

  • Program ID: R3TR
  • Object type: CLAS
  • Name range: ZCL_DEV1_
  • Package: ZDEV1
  • Reservation type: H

The reservation type has three options, but only two are useful to us: Package (D) and Package hierarchy (H). The difference is that the package hierarchy is also valid for sub-packages and, as such, it seems to me the most appropriate for most cases.

Once this prefix is set, SE24 will fail if you try to create a class under the ZDEV1 package that does not start with ZCL_DEV1_. This ensures that the names of the objects in DEV1 will remain decent.

Greetings from Abapinho.