ABAP Tips & Tricks

Here you will find some tips and tricks for ABAP Programming. Please, feel free to contribute with us by sending your own tips.

ALV - Find errors

ALV reports are very useful to create lists and to provide standard functionality like sums, order and so on. To do this without ALV you would have to code all of this functions on your own.

There are several examples in the SAP system to see all these functionalities; they all start with BCALV_TEST_*.

To make sure that all works fine, the ALV FM or class must be called with the appropriate parameters. To make sure you are doing this OK, you can use this trick: for ALV reports created by the FM's REUSE_ALV_LIST*, insert the value &SOS in the command line and press enter. For ALV objects or FM REUSE_ALV_GRID* double right-click on an empty place of the ALV container while pressing the SHIFT key. You will get a full report of many parameters regarding the ALV.

Debug anywhere

Sometimes we need to debug a Dynpro but it does not have the command line where we can enter '/h'. You don't need to debug previous screens in order to get there! Just drag'n'drop the following text file and the debugger will be started!


Load Dynamic internal table using Field Symbols

With this code we will load an internal table using field symbols. It is useful when you do not know the structure of the table in programming time.

<field> TYPE ANY.
l_preis(13), "LIKE eipa-preis,
l_count(1) TYPE n,

LOOP AT ti_eipa.
l_count = l_count + 1.
* Price.
CLEAR l_field.
WRITE ti_eipa-preis TO
l_preis CURRENCY ti_eipa-bwaer.
CONCATENATE 'P_PREIS' l_count INTO l_field.
ASSIGN (l_field) TO <field>.
<field> = l_preis.

Dynamic F4 for any field

Create a matchcode for any field using this code.

DATA: carrid TYPE spfli-carrid, 
hlp TYPE string,
struc TYPE dfies-tabname,
comp TYPE dfies-fieldname.


SPLIT hlp AT '-' INTO struc comp.
tabname = struc
fieldname = comp
field_not_found = 1
no_help_for_field = 2
inconsistent_help = 3
no_values_found = 4