Inserting TAB's into text strings

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. Also see 'Upload Tab Delimited file'.

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'). See sample list of hex values.

-- Non Unicode system
*Code used for inserting a TAB value on a
DATA: gd_result(50) type c.
constants: con_tab type x value '09'.
* con_tab can then be concatenated to create tab spaces.
CONCATENATE 'text1' con_tab 'text2' con_tab 'text3' into gd_result.

-- Unicode system
* When requiring unicode compliancy you will need to use the following syntax.
* Double click on 'cl_abap_char_utilities' then choose attributes for list
* of possible commands.
class cl_abap_char_utilities definition load.
constants: c_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
CONCATENATE 'text1' c_tab 'text2' c_tab 'text3' into gd_result.

Related Articles

Data manipulation - Example code and information on various data manipulation techniques
Retrun the fraction / whole value of a decimal number using MOD, DIV, FRAC or SHIFT
Remove spaces from character field (CONDENSE)
Move minus sign(-) from end to start of field
ABAP Round functionality to round values down to nearest value based on your decimal place requirement
Round ABAP values up to the nearest value
Change characters within a string ( TRANSLATE )