> For the complete documentation index, see [llms.txt](https://docs.prebilt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.prebilt.com/prebilt-for-im-wm-strm/enhancing-prebilt/making-enhancements-in-the-backend-abap.md).

# Making enhancements in the backend (ABAP)

## Custom classes and methods

In this section we will cover how to make enhancements to established PreBilt apps and their methods in the backend.

### Option A – create a customised method

This option we create an enhancement within our class to create a customised method. We can then create an implicit enhancement within the original method to call our customised method, passing in any parameters and then return out of the original method before any of the original code is executed.

It is a good option if we only want to make a change to a single method within an app.

To do this, within the class you want to enhance, go to the methods and click the enhance button. This will bring up the below screen where you can fill in the following fields:

<figure><img src="https://3149936122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CkvzIq48sLzTY4bfcWl%2Fuploads%2FDAgw2n7lXv5GnFB57tNV%2Fimage.png?alt=media&amp;token=b683c12e-4eac-4e52-b6d7-fe6c37050877" alt=""><figcaption></figcaption></figure>

Clicking the tick will confirm the enhancement and request you add it to a transport.

Once added we can then add custom methods to our class, for example if we want to create a customised method of VALIDATE\_ITEM, we can create a Z version called ZVALIDATE\_ITEM then copy all the code from the original method and remove any of the enhancement points.

<figure><img src="https://3149936122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CkvzIq48sLzTY4bfcWl%2Fuploads%2FibdDeu4zx355JaffyQo2%2Fimage.png?alt=media&amp;token=f5e1a220-b622-4fb2-845d-9b2c7f287c0b" alt=""><figcaption></figcaption></figure>

Within the original method we can then create an implicit enhancement point (right click > Enhancement Operations > Show Implicit Enhancement Options) at the start of the method to call our custom method (ZVALIDATE\_ITEM) and then RETURN out of the original method.

When we call our custom method, we need to ensure we pass any exporting/importing/changing parameters which can be found in the Signature of the original method.

<figure><img src="https://3149936122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CkvzIq48sLzTY4bfcWl%2Fuploads%2FBwx6MUf2wzhy3N0EsJPl%2Fimage.png?alt=media&amp;token=7a48a3c6-e044-4783-80cf-ba9fd962f259" alt=""><figcaption></figcaption></figure>

Note: When passing parameters; we are EXPORTING any “imported” parameters (denoted by the prefix i…), we are IMPORTING any “exported” parameters (denoted by the prefix e…) and CHANGING parameters are the same (denoted by the prefix g…). It must be done this way to “pass on” any parameters from the original method to our custom method. For example, parameters that are exported to the original method then need to be imported to our custom method, likewise parameters that are imported from the original method need to be exported from our custom method. It is important these parameters are “reversed” for this enhancement to work.

### Option B - create a custom app

This option involves creating a Z version of the app which we can customise and is useful if we want to make changes to multiple methods.

* &#x20;In the Object Navigator (SE80) within the package ZTCTM, create a custom package called <kbd>ZTCTM\_WM\_APP\_XXX</kbd> and within that package create a class also called <kbd>ZTCTM\_WM\_APP\_XXX</kbd>.
* Open the class then select Properties and Superclass, enter the superclass you wish to inherit from which will be in the format <kbd>/TCTM/WM\_APP\_XXX</kbd>. Then save and activate.

<figure><img src="https://3149936122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CkvzIq48sLzTY4bfcWl%2Fuploads%2F9rhyzKsthMYgdU59uzSr%2Fimage.png?alt=media&amp;token=34c6fe9f-caca-46b1-a160-47d23f524f1c" alt=""><figcaption></figcaption></figure>

* Add any Macros you may wish to use that these will not be copied over. On the toolbar Goto -> Local Definitions/Implementations -> Macros.
* &#x20;In change mode, right click on the method you want to change and select Redefine or click on the method and click the Redefine button.

<figure><img src="https://3149936122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CkvzIq48sLzTY4bfcWl%2Fuploads%2Fv7vrl63PJFMZEWNjPurA%2Fimage.png?alt=media&amp;token=1ddbadd3-5efc-400e-9217-48f9074ad06d" alt=""><figcaption></figcaption></figure>

* You may want to copy the code from the original as this will be replaced, but it can still be found in the same method of the Superclass. Once a method has been redefined it will turn from blue to black

<figure><img src="https://3149936122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CkvzIq48sLzTY4bfcWl%2Fuploads%2FDlicxWowLUwCdu7WP1mt%2Fimage.png?alt=media&amp;token=62ddb040-ca69-4717-b4d3-b7f85c78e068" alt=""><figcaption></figcaption></figure>

* You can now start making changes to the custom Z version of the app/method.
* The custom backend service class (<kbd>ZTCTM\_WM\_APP\_XXX</kbd>) will then need to be assigned to the app’s transaction code in config.&#x20;

## TCTM/WM package structure

When making enhancements you may want to use code within the /TCTM/WM package. The package has 3 subpackages:

<figure><img src="https://3149936122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CkvzIq48sLzTY4bfcWl%2Fuploads%2FtsNXK1UfJywgGMsLs7q5%2Fimage.png?alt=media&amp;token=ba82a3f9-4a31-4c16-af8a-ca402fbb9ea8" alt=""><figcaption></figcaption></figure>

* <kbd>/TCTM/SERVICES</kbd> – contains a series of service classes that we use throughout PreBilt apps and can be reused when dealing with Batches, Bins, Materials, MatDocs, Transfer Orders, Serial numbers and Stock amongst others.

It is worth taking the time to familiarize yourself with these service classes and using the “Where-Used” functionality can provide examples of how each service/method has been implemented.

<figure><img src="https://3149936122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CkvzIq48sLzTY4bfcWl%2Fuploads%2FX2iOYrvqlrMAkiMkNu4a%2Fimage.png?alt=media&amp;token=742117cd-950c-40c7-9674-f64fd9590c8a" alt=""><figcaption></figcaption></figure>

* &#x20;<kbd>/TCTM/WM\_APPS</kbd> – holds the packages that contain each app’s backend code.

<figure><img src="https://3149936122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CkvzIq48sLzTY4bfcWl%2Fuploads%2FCBRAyLwKYHM6P78tqFMM%2Fimage.png?alt=media&amp;token=4b82285e-d824-49ba-a918-36802136cd39" alt=""><figcaption></figcaption></figure>

* <kbd>/TCTM/WM\_BASE</kbd> – this package holds the ‘base’ information used across all apps.

### Dictionary objects

* &#x20;Database Tables – holds information about the database tables we use.
* Table Types – custom tables types we use when defining tables within our ABAP code.
* Structures – custom structures which we use to define structures in our ABAP code.
* &#x20;Search help – manages our search help functionality across apps.

### &#x20;Class library

* Holds Classes and Interfaces that we commonly use within our code and some useful helper functions.
* &#x20;In particular <kbd>/TCTM/WM\_CFG\_HELPER</kbd> and `/TCTM/WM_UTILS` hold a lot of common methods we see used in our apps and are worth getting familiar with:

### &#x20;Programs

* &#x20;Holds programs that we may not want to directly reference in our apps but allows for additional functionality within an SAP system. For example, <kbd>/TCTM/WM\_CFG</kbd> is the program that runs our CFG transaction that we will discuss below.

### Function groups

* This is where our Conversion Exits are defined and can be added to.

### Transactions

* Handles additional transactions we may want in an SAP system; this is where we define our CFG and CFG\_D (AMD) transactions.

<figure><img src="https://3149936122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CkvzIq48sLzTY4bfcWl%2Fuploads%2FxOg5PJo6QCij3fxyuVBy%2Fimage.png?alt=media&amp;token=f78b238b-590a-4b51-b3ac-3b939af6e726" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3149936122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CkvzIq48sLzTY4bfcWl%2Fuploads%2FXh4eoIjjHRSJWqMRIXqm%2Fimage.png?alt=media&amp;token=b18954a2-490b-4cc6-98b9-2a6d588a2543" alt=""><figcaption></figcaption></figure>

## SELECT\_OPTS, FIELDS and ACTION classes

Within the packages of our apps we have <kbd>SELECT\_OPTS</kbd> and <kbd>FIELDS</kbd> classes with the naming convention:

<kbd>/TCTM/WM\_APP\_XXX\_SELECT\_OPTS</kbd>

<kbd>/TCTM/WM\_APP\_XXX\_FIELDS</kbd>

These classes are referenced in AMD next to a field and allow us to write code that can make changes to on screen fields or inputted values, suppress fields based on conditions that we define, populate dropdown lists and process fields (for example for field validation). This allows us to make changes outside of the app's main classes and reuse code.&#x20;

Within our ABAP class <kbd>/TCTM/WM\_UTILS</kbd> we have functions <kbd>PROCESS\_SELECT\_OPTS</kbd> and <kbd>PROCESS\_FIELDS\_IN</kbd> that when called handle the changes we make within our <kbd>SELECT\_OPTS</kbd> and <kbd>FIELDS</kbd> classes respectively.

<figure><img src="https://3149936122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CkvzIq48sLzTY4bfcWl%2Fuploads%2FYLJIGUoSf3VslP4QyWne%2Fimage.png?alt=media&amp;token=e2fb5eaf-4dda-4dc9-ac75-7e7513058b3e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3149936122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CkvzIq48sLzTY4bfcWl%2Fuploads%2FWA1I9HdnRlzngriwFvnn%2Fimage.png?alt=media&amp;token=8af3a27e-a47b-42ef-b4ec-cf00a7b2566a" alt=""><figcaption></figcaption></figure>

We also have <kbd>ACTIONS</kbd> classes that operate in a similar way but allow us to change actions within AMD, often this is for showing/suppressing a field but other logic can be added in aswell.

These classes have the naming convension:

&#x20;<kbd>/TCTM/WM\_APP\_XXX\_ACTIONS</kbd>
