Application Development and Automation 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: 
Read only

Repeat a Char

Former Member
0 Likes
2,704

Hi everybody. Does anyone know if there's a function to repeat a certain character into a string/character variable, for example repeat "0" 10 times, returns a string "0000000000". Regards.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,443

Hi,

You can use field symbols.


data: var(10)  type c value '0'.
FIELD-SYMBOLS : <str> type char10.
ASSIGN var to <str>.
do 10 times.
concatenate var <str> INTO var.
enddo.
WRITE var.

4 REPLIES 4
Read only

Former Member
0 Likes
1,443

Try this out:

Data:w_char(10) type c,
        w_index type i.
DO 10 times.
w_char+w_index(1) = '0'.
add 1 to w_index .
ENDDO.

Result: 0000000000.

Regards,

Gurpreet

Read only

Former Member
1,443

You can try:

CLEAR var(long) WITH char.

Read only

Former Member
0 Likes
1,443

will this help?

data: var type i value 10.
data: str(20).
do var times.
concatenate str '0' into str.
enddo.

Regards,

Sumit Nene.

Read only

Former Member
0 Likes
1,444

Hi,

You can use field symbols.


data: var(10)  type c value '0'.
FIELD-SYMBOLS : <str> type char10.
ASSIGN var to <str>.
do 10 times.
concatenate var <str> INTO var.
enddo.
WRITE var.