Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to add space before a string a variable.

Former Member
0 Kudos

Hi,

If i have a string variable ' 80 '.I want it as ' 80 ' ie some space appended before it.

I used concatenate ' ' variable into variable..Its not working.How to do it??

Thanks.

1 ACCEPTED SOLUTION

varma_narayana
Active Contributor
0 Kudos

Hi..

To add spaces before a string use the SHIFT statement.

Eg:

Data : Var(10) type c value 'ABC'.

SHIFT VAR BY 1 PLACES LEFT.

WRITE:/ VAR.

<b>reward if Helpful.</b>

3 REPLIES 3

Former Member
0 Kudos

it will not work...

use shift statement ...

regards

vijai

varma_narayana
Active Contributor
0 Kudos

Hi..

To add spaces before a string use the SHIFT statement.

Eg:

Data : Var(10) type c value 'ABC'.

SHIFT VAR BY 1 PLACES LEFT.

WRITE:/ VAR.

<b>reward if Helpful.</b>

Former Member
0 Kudos

check below code

Concatenate ' ' string into string respecting blanks.

<b>

... RESPECTING BLANKS</b>

Effect

The addition RESPECTING BLANKS is only allowed during string processing and causes the closing spaces for data objects dobj1 dobj2 ... or rows in the internal table itab to be taken into account. Without the addon, this is only the case with string.

Note

With addition RESPECTING BLANKS, statement CONCATENATE can be used in order to assign any character strings EX>text - taking into account the closing empty character - to target str of type string: CLEAR str. CONCATENATE str text INTO str RESPECTING BLANKS.

Example

After the first CONCATENATE statement, result contains "When_the_music_is_over", after the second statement it contains "When______the_______music_____is________ over______" . The underscores here represent blank characters.

TYPES text TYPE c LENGTH 10.

DATA itab TYPE TABLE OF text.

DATA result TYPE string.

APPEND 'When' TO itab.

APPEND 'the' TO itab.

APPEND 'music' TO itab.

APPEND 'is' TO itab.

APPEND 'over' TO itab.

CONCATENATE LINES OF itab INTO result SEPARATED BY space.

...

CONCATENATE LINES OF itab INTO result RESPECTING BLANKS.

Rewards if useful.........

Minal