INSERTING TABS INTO A STRING

INSERTING TABS INTO A STRING:

Inserting tabs into output strings can be performed using the code below. This can be very useful when building an EXCEL output file. Using the tab value you are able to create a .xls(EXCEL) file containing a TAB value to separate each column.

Any ASCII character can be inserted in this way by simply replacing the hex value for tab with the hex value of another command(i.e. carrage return = '0D').

PROGRAM:

*&---------------------------------------------------------------------*
*& Report  Z_INSERT_TABSINTOSTRING
*&
*&---------------------------------------------------------------------*

REPORT Z_INSERT_TABSINTOSTRING.
*
DATAgd_result(50type c.
*constants: con_tab type STRING value '09'.
*
** con_tab can then be concatenated to create tab spaces.
*CONCATENATE 'text1' con_tab 'text2' con_tab 'text3' into gd_result.
*
*WRITE GD_RESULT.
class cl_abap_char_utilities definition load.
constantsc_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
CONCATENATE 'text1' c_tab 'text2' c_tab 'text3' into gd_result.
WRITE GD_RESULT.

OUTPUT: