Illustration: Definition of a user-defined table in the ABAP Dictionary (SE11). In this example, the table ZCUST_REV is created with fields (e.g. customer number). The developer defines the name, the data type(NUMC with length 6 for the customer number) and the key identifier for each field. Such user-defined tables enable the persistent storage of application-specific data in the S/4HANA database.
As soon as the table is activated, it can be written to by ABAP programs or a maintenance dialog can be created for usersto edit entries. User-defined tables are transported across systems via workbench transports.
Function module
To create a reusable function (e.g. a function for calculating a bonus or for querying aggregated data), use SE37 (Function Builder):
1. open SE37, select Create function module and assign a name (e.g. ZCALC_BONUS) within a user-defined function group (functions exist in groups). Enter a short description.
2. define import parameters, export parameters and exceptions in the upper area of the Function Builder. These parameters form the interface of the function.
3. implement the ABAP logic in the source code area. For example:
- Importing an employee ID
- Query the database for sales data
- Calculate a bonus
- Return the bonus amount as export value
4. save and activate the function module. It can now be called from any ABAP program or released as a remote-capable API (RFC).
Function modules can also serve as user exits(SAP sometimes provides empty function modules that are called and filled by customers when certain events occur). They can also be integrated into OData or SOAP services and made available for external systems.
Developing a Custom Report and Transaction Code
Creation of a customized report and transaction code
Customized report
ABAP reports are stand-alone executable programs that are often used for data queries, simple outputs or batch jobs. To create a report:
1. open SE38 (ABAP Editor) and create a new program (type: "Executable").
2 Alternatively, you can create a new ABAP program in Eclipse ADT.
A simple report that lists customers and their sales could look like this:
REPORT zcustomer_revenue_report.
TABLES: zcust_rev. " declare usage of the custom table
SELECT zcust_no AS Customer, SUM(zrevenue) AS Total_Revenue
FROM zcust_rev
GROUP BY zcust_no
INTO TABLE @DATA(lt_rev_by_cust).
LOOP AT lt_rev_by_cust INTO DATA(ls_line).
WRITE: / ls_line-Customer, ls_line-Total_Revenue.
ENDLOOP.
This program executes a SELECT query on the user-defined table to aggregate sales by customer. The results are then output in a loop. In practice, reports are often created with the ALV grid display for a better user interface and selection screens for user input (using PARAMETERS or SELECT-OPTIONS in the code).
Once the report has been created, it must be activated. You can run it directly in SE38 or via SA38 by entering the program name.
If end users should simply start this report, a transaction code can be created:
1. open SE93 (Maintain transactions).
2. select Create and enter a transaction code (e.g. ZCUST_REV_REP).
3. select "Program and selection screen" as the transaction type and link the transaction to the report program.
4. save the transaction - users can then run the report using this transaction code from the SAP Easy Access menu.
Custom transactions can also be included in user menus or roles so that they are displayed in the SAP Fiori Launchpad (as GUI transactions) or in the SAP GUI Easy Access menu.
Extension of SAP standard functionality (BADIs and user exits)
SAP provides extension mechanisms that allow user-defined code to be executed at predefined hook points in standard programs. This ensures that standard SAP code is not changed (which would make future upgrades more difficult), while still allowing custom logic to be inserted. The two most common enhancement techniques are User Exits (including Customer Exits) and BADIs (Business Add-Ins):
User Exits / Customer Exits
These are classic (usually procedural) extension techniques. A user exit is a subroutine or a function module that SAP calls at certain points in the program. By default, these exits do nothing, but can be implemented by customers.
π Example:
In the SD module, user exit MV45AFZZ enables the insertion of user-defined checks during order processing.
How to implement a user exit:
1. find the relevant SMOD/CMOD extension. SAP often groups several exits in an SMOD extension witha specific name.
2. open CMOD, create a project, assign the relevant extension and insert your code into the designated includes or function blocks.
3. after activation, the user-defined code is automatically executed as part of the standard process.
User exits often require code in includes or function modules that SAP has defined as exit points.
BADIs (Business Add-Ins)
BADIs are a more modern, object-oriented extension technique. A BADI is an interface with one or more methods that SAP provides at a specific point in the code. Developers can create one or more implementations of this interface to execute their custom code.
BADIs are managed via transactions SE18 (definition, by SAP) and SE19 (implementation, by customers). SAP provides BADI definitions (e.g. there is a BADI for enhancing invoice posting). The developer creates a BADI implementation in which he implements the logic in one of the methods provided.
Main difference between user exits and BADIs:
β
User exits are older, procedural methods that are often more limited (e.g. embedded in includes).
BADIs are fully object-oriented and can have multiple implementations(some BADIs allow parallel or filter-controlled implementations).
Implementing a BADI - step by step
1. find the correct BADI definition
- Use SE18, the SAP documentation or the "Where to use" search in SAP GUI with the term "BADI".
- In newer systems, many enhancements are managed via enhancement spots, which can contain several BADIs.
2. create new implementation in SE19
- Open SE19, create a new BADI implementation, give it a name and select the appropriate BADI definition.
3. create class for the implementation
- The system prompts you to create a class that implements the BADI interface.
- In this class, you write the user-defined logic in the methods provided.
4. activate BADI implementation
- As soon as the implementation is activated, your code is automatically executed when the standard program calls the BADI via CALL BADI or the Enhancement Framework.
- If there are several implementations, either all are executed in parallel or only the appropriate implementation is executed based on a filter condition - depending on the BADI configuration.
Example of a BADI implementation
Assume that SAP's standard invoice posting uses the BADI BADI_INVOICE_POST with the CHECK_DATA method, which is called before the invoice is posted for data validation.
A developer could implement this BADI to perform additional checks, e.g:
β
Checking a user-defined table for special rules
β
Comparison with an external system before the invoice is posted
π Important:
The BADI mechanism ensures that the user-defined code is executed without changing the SAP standard logic and thus enables a flexible and maintainable extension of SAP functionality.
π According to official SAP documentation:
"BADIs (Business Add-Ins) are a powerful mechanism in ABAP for extending standard SAP functionality without changing the core code. They offer a flexible and maintainable way to customize SAP applications."
Similarly, user exits enable extensions at predefined points (e.g. at the end of form routines, etc.). Both techniques can be used within a project:
π Example: A user exit is used to add a new field on a screen, while a BADIis usedto fill the value for this field.
Steps for implementing a user exit (brief overview)
1. identify the exit - via SAP Notes or development documentation.
- Example: An SAP SD exit for sales orders could be located in program MV45AFZZ.
2. call up CMOD β create project β assign the relevant extension (an extension combines related exits).
3. for each component of the extension (e.g. an include or function module), click on Components and navigate to the corresponding include.
- Write the user-defined code within the include(between FORM...ENDFORM or as intended).
4. activate the project - The code in the includes is now executed as part of the SAP standard process.
Steps for implementing a BADI (brief overview)
1. find the BADI name
- Use SE18 or debugging/SQL trace to check whether GET_INSTANCE is called for a specific process.
2. open SE19 β create new BADI implementation β enter the BADI definition.
3. specify an implementation class (or accept the default class) and navigate to the class editor.
4. write code in the method
- Example: If the CHECK_DATA method has import parameters, a check can be implemented, an export flag can be set if required or an exception can be triggered.
5. activate the implementation.
Additional BADI options
Many BADIs have a filter option, i.e. the implementation can be restricted to certain criteria (e.g. company code or country). These settings are defined in the BADI implementation configuration.
Extension framework in SAP (from ECC 6.0 and S/4HANA)
With ECC 6.0 and S/4HANA, SAP introduced implicit and explicit enhancements.
These make it possible to add extensions in certain coding blocks or at the beginning/end of form routines.
π These are managed directly in the ABAP Editor via the "Enhance" option and are another way of extending standard or user-defined code.
π’ For medium-sized development projects, however, BADIs and user exits are the most frequently used techniques and should be the focus.
Creation and provision of ABAP CDS views
ABAP Core Data Services (CDS) views are a central component of S/4HANA development and play a crucial role in SAP's strategy for in-memory-optimized programming.
CDS views make it possible to move complex logic and calculations directly to the HANA database level. This allows them to be reused efficiently in user interfaces (Fiori) or integration scenarios.
CDS views are defined in ABAP with an Eclipse-based editor.
β‘ They use a declarative SQL-like syntax and integrate with the ABAP Data Dictionary after activation.
Important features of CDS Views
CDS views are defined with the DEFINE VIEW syntax in a DDL source file.
- You can reference base tables or other views,
- Apply filters, joins, associations and even simple calculations.
β CDS views support annotations - metadata that:
- Provide the view as an OData service,
- Control the UI behavior in Fiori Elements.
After activation, a CDS view is generated:
- An SQL view in the HANA database,
- A runtime object in ABAP that can be used like a table in ABAP programs using a SELECT query.
Creation of a CDS view (step-by-step)
1οΈβ£ In Eclipse ADT:
- Create a new ABAP DDL source document (e.g. ZCUST_REVENUE_VIEW).
- A transport request and a package must be selected depending on the project.
2οΈβ£ Use of the CDS syntax to define the view.
- Example:
@AbapCatalog.sqlViewName: 'ZCUSTREVV'
@AbapCatalog.compiler.compareFilter: true
@OData.publish: true
define view ZCUST_REVENUE_VIEW
as select from zcust_rev
{
zcust_no,
zregion,
sum( zrevenue ) as total_revenue
}
group by zcust_no, zregion
This defines a CDS view that aggregates the user-defined table by customer and region and totals the sales.
The annotations used here specify the associated SQL view name and enable the OData Expose function.
π @OData.publish: true would automatically generate an OData service for this view in SAP S/4HANA.
Steps after defining the CDS view
1οΈβ£ Activate CDS-View
- Activation creates the database view and makes the OData service available.
- If OData is used, SAP automatically generates a service in the background, which you can find in transaction /IWFND/MAINT_SERVICE and activate for use.
2οΈβ£ Test CDS-View
- Perform data preview in Eclipse or
- Call up the generated SQL view in SE16.
CDS Views as a multi-layer architecture
CDS views can be divided into layers:
π Base layer β Composite layer β Consumption layer (Consumption Views).
CDS views are used extensively in S/4HANA - many preconfigured S/4HANA analyses and Fiori elements are based on them.
β
A major advantage is that a CDS view can be provided as an OData service with just a few annotations.
- This often eliminates the need to manually create an OData service for simple read operations - the platform generates this automatically.
Provision and transport of CDS views
- After creation, CDS views can be transferred to other systems via the usual SAP transports.
- CDS views are objects of type R3TR DDLS and can be transported from DEV to QA and production after development and testing.
Summary
ABAP development for add-ons includes:
The creation of user-defined dictionary objects (tables, data elements),
β Writing ABAP programs or extending existing programs,
β The use of ABAP frameworks such as CDS and enhancement spots to extend standard functions in an upgrade-proof manner.
4. development of Fiori applications with SAP BTP
In this section, we switch to front-end development:
SAP Fiori applications with SAPUI5.
These applications run in the web browser (or in the Fiori Launchpad) and communicate with the SAP S/4HANA backend via OData services.
We use SAP's cloud-based development environments (SAP Web IDE or SAP Business Application Studio on SAP BTP) to create, test and deploy a Fiori app.
Overview of the SAP Fiori/UI5 architecture
An SAP Fiori application typically follows a client-server model:
Client side β The SAPUI5 app (HTML5/JavaScript application) runs in the browser and manages the user interface and user interactions.
β Server page β
- The SAP S/4HANA system (or an SAP BTP ABAP environment) provides business data via OData services.
- The SAP Gateway component (integrated in S/4HANA) publishes these OData REST endpoints, which are used by the UI5 app to create, read, update or delete data (CRUD operations).
SAP Fiori Launchpad - The central entry point
SAP Fiori apps are started from the SAP Fiori Launchpad.
π The Launchpad is a web platform that serves as a central homepage with tiles for each app.
β Each tile represents a Fiori app (or a link to a classic GUI transaction).
The tile is linked to an OData service and a UI5 component name.
β When a user clicks a tile, the UI5 app is loaded in the browser and calls the OData services in the backend to fetch or send data.
Fiori apps are role-based:
- Users only see the apps for which they are authorized.
- The authorizations control which actions are possible within the app.
Architecture: Separation of UI and backend through OData
Fiori uses a decoupled model in which the UI is separated from the backend by OData services:
The same OData service can serve multiple interfaces(web UI, mobile UI, etc.).
The UI does not communicate directly with the database, but via defined service APIs.
Summary
β‘ "SAP Fiori apps are developed with SAPUI5, launched via the SAP Fiori Launchpad and obtain business data from the SAP S/4HANA backend via OData services."
The architecture is stateless (each OData call is independent β better scalability).
β Modern concepts such as "draft handling" for long-running transactions are supported.
Now we are developing a Fiori app - step by step. π
Creation of a Fiori app with SAP Web IDE / Business Application Studio
In this example, we use the SAP Web IDE (full stack) to develop a Fiori app.
π The steps are very similar in SAP Business Application Studio (BAS).
Step-by-step guide to creating a Fiori app
1οΈβ£ Launch SAP Web IDE
- Open SAP Web IDE via the SAP BTP Cockpit (make sure it has been activated beforehand, as described in section 2).
- The web-based development environment should now be visible.
- Select File > New > Project from Template to start the project wizard for a new Fiori app.
- (In Business Application Studio: Open a Dev Space and use the "Fiori: Create Project" command or the Yeoman templates.)
2οΈβ£ Select project template
- The SAP Web IDE offers predefined project templates, e.g:
- SAP Fiori Worklist Application
- SAPUI5 Application
- Master-Detail Application
- For example, select the SAP Fiori Master-Detail Application and click Next.
Configure 3οΈβ£ project
- Enter a project name (e.g. CustomerRevenueApp).
- If necessary, specify a namespace.
- Select the data source for the app:
- If an OData service already exists (e.g. the previously created CDS View or an SAP standard service), select Service Catalog.
- Then select the preconfigured destination and the OData service from S/4HANA.
- The wizard automatically retrieves the service metadata.
- Select the entity set to be displayed in the app (e.g. an entity for customer sales).
Complete 4οΈβ£ Wizard
- The Web IDE now generates a complete project with all the necessary files:
- Controller (JavaScript)
- Views (XML)
- i18n texts (multilingualism)
- manifest.json (application description)
- This generated project is ready to run and can be tested immediately.
Run and test 5οΈβ£ app
- Right-click on the newly created project folder and select Run > Run as Web Application.
- This opens a new browser tab with a test URL (often port 8080 for local tests or an FLP sandbox mode in the cloud).
- The app is loaded and calls up the OData service (via the configured destination).
- If everything is set up correctly, you will now see real data from your backend, e.g:
- A customer list
- A detail page with sales data for each customer.
6οΈβ£ Develop the app further
- Now you can customize the generated code:
- Open the view XML files to change the UI layout or the labels.
- Edit the controller JS files to add additional logic (e.g. input validation, dynamic navigation).
- Customize the i18n property files to localize texts.
- Add new UI elements (charts, tables, filters) with SAPUI5 controls and bind them with OData data.
Typical development tasks in a Fiori app
β
Data formatting (with formatters in UI5).
β
Navigation between views (if not included in the template).
β
Custom OData calls - method calls for actions such as approvals or data changes.
β
Performance optimization
- Use of $select or $expand in OData queries to minimize the data load.
Debugging and testing during development
π During development, it is often:
β Use the browser console (Chrome DevTools) for troubleshooting.
β Used the UI5 debugging tools.
β The Fiori Launchpad Sandbox mode in SAP Web IDE or BAS is used to test multiple apps in a simulated Launchpad environment.
π Next step: further develop the Fiori app and make it available for productive use!