With vast experience in SAP ABAP (Advanced Business Application Programming), we have come up with a few tips and tricks that an ABAP Developer can use in his day-to-day work with ABAP development tools (i.e. ABAP Workbench) to enhance the quality and speed of development.
Most SAP software is written in ABAP - it is the object -oriented programming language for SAP applications.
Below is a mix of tips that can be used for performance management, RICEF (Reports, Interfaces, Conversions, Enhancements, Forms) development, debugging, and analysis.
ALV (Advanced List Viewer) programs sometimes have inconsistencies due to coding errors in the ALV field catalog and output table, which does not cause any visual issues but causes issues with code performance and maintenance. We can get a list of all these issues with this convenient and straightforward way, instead of reviewing the entire code line-by-line.
The ALV consistency check can be used by pressing the Shift key and simultaneously double-clicking the right mouse button on an area in the ALV Grid Control in which no table rows are displayed (to do this, scroll to the right area of the output).
This action pops up an SAP standard screen with technical report details of the ALV. The consistency check function allows you to access:
SCI stands for SAP Code Inspector. This SCI acts as the best tool for one's code review and peer review. Every project usually has a set of standards and naming conventions that developers are expected to use.
SCI checks the code for the naming convention and performance issues. It is possible to configure and enter the project-specific standards, as shown below.
Go to SAP transaction code SCI and copy the DEFAULT Variant
Add Naming conventions
Once configured, the same variant can be used to review a class, program, or any DDIC object.
If you have ever wondered if you can have a code exit in CDS, the answer is a resounding YES. A Virtual Element can be defined in an ABAP Method to implement a Code Exit for a CDS View. This exit and virtual element will not be visible for data preview in Eclipse or SE16N but will only be visible when the CDS is exposed as an OData service.
This is very simple and can be done within the CDS view field definition, as shown below. The annotation @ObjectModel.virtualElement: true is used to mark it as a virtual element.
The marked section shows the ABAP Class. ZCL_CDS_FUNCTION will be called to populate the text field below. The ABAP class must use the interface "if_sadl_exit_calc_element_read" and implement the methods "calculate".
Before starting any ABAP programming development on ADOBE FORMS, it is imported to check the status and installation of the Adobe LifeCycle Designer in the SAP system. Follow the below steps to validate:
Report FP_TEST_00 checks if your system is configured correctly for processing forms in an ABAP environment.
If the configuration is correct, a form containing several lines on two pages is displayed; otherwise, no form is displayed.
SAP ABAP Developers use ABAP objects such as BAPIs frequently to access, create, change business objects. BAPIs provide a BAPIRET table that holds the success, error, and warning messages. In traditional ABAP code, the developer always loops over this table and build a pop-up ALV to show the user all relevant messages.
However, the SAP prebuilt function module RSCRMBW_DISPLAY_BAPIRET2 performs the same activity. This module accepts the BAPIRET as an input parameter and shows a pop-up display to the user. This reduces the number of code lines the ABAP developer needs to write and provides a consistent experience to users. Below is an example:
Reference Code to call the FM:
Learn how to use Test Driven Development with ABAP in this training course.
Whenever an ABAP developer looks for a solution to a problem, the first approach she uses is to test the solution before spending time on implementing it completely. The testing gets complicated when there is a need to test solutions in sequence. For example, if a BAPI is triggered, the output will only be seen when a BAPI_TRANSACTION_COMMIT is called. For such cases, SE37 way perform sequencing, shown below.
The test sequence can be built using SE37 > Function Module > Test > Test Sequences.
Enter the required sequence of BAPIs to trigger them in the given order for testing.
New Open SQL Syntax
SAP has come up with a new syntax for ABAP versions 7.4 or higher. This new syntax help developers reduce the number of code lines and write performance-optimized code. We are listing some important ones here, while an exhaustive list can be found here: ABAP 7.40 Quick Reference.
Take this training course to learn more about Reading Data in ABAP with Open SQL.
DATA(text) = `ABC`.
LOOP AT itab INTO DATA(wa).
LOOP AT itab ASSIGNING FIELD-SYMBOL().
READ TABLE itab ASSIGNING FIELD-SYMBOL().
SELECT * FROM dbtab INTO TABLE DATA(itab) WHERE fld1 = @lv_fld1.
oref->meth( IMPORTING p1 = DATA(a1) ).
wa = itab[ index ].
wa = itab[ col1 = … col2 = … ].
IF line_exists( itab[ … ] ). ENDIF.
DATA(idx) = line_index( itab[ … ] ).
Data Type Conversion:
CONV dtype( … )
CONV #( … )
Value Operator to populate variables, structures or tables:
Var = VALUE dtype( … ) or Var = VALUE #( … )
Structure = VALUE dtype( … ) or Structure = VALUE #( …)
itab = VALUE #( ( ) ( 1 ) ( 2 ) )
Similarly, there is another new syntax for REDUCE, FOR, COND, SWITCH, GROUP BY, etc. which can be used for effective coding.
Introduction The programming language for SAP, ABAP (Advanced Business Application Programming), is as old as SAP software, and it has been growing and evolving with each SAP release. SAP re-evaluated ...
Introduction SAP WebIDE is a powerful, extensible, web-based integrated development tool that simplifies end-to-end full-stack application development. SAP WebIDE supports the entire application lifecycle, ...
Introduction SAP WebIDE is a web-based development tool to build SAPUI5 and FIORI applications. WebIDE is an open source code editor development environment for a single user. There are two kinds of ...