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

increment a number within a string

Former Member
0 Likes
2,511

Hi!

How can I increment a number within a string ?

This code doesn' t provide the rigth result

DATA zahl TYPE I.

DO 10 TIMES.

zahl = zahl + 1.

write:/ 'HALLO zahl'.

ENDDO.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,674

thanks but it is not ecatly what I mean.

It is a special case by a special matter. The

variable zahl must stay be within the string.

like

write:/ 'HALLO zahl'.

and not

write:/ 'HALLO', zahl.

This variable can't stay outboard of the string. This the problem

Reagrds

sas

13 REPLIES 13
Read only

Former Member
0 Likes
1,674

hi write write:/ 'HALLO zahl'

as write : / 'HALLO' , zahl.

Read only

Former Member
0 Likes
1,674

Do this:

DATA zahl TYPE I.

DO 10 TIMES.

zahl = zahl + 1.

write:/ 'HALLO ' zahl.

ENDDO.

Read only

Former Member
0 Likes
1,674

HI!

Try this:

DATA zahl TYPE I.

DO 10 TIMES.

zahl = zahl + 1.

write:/ 'HALLO', zahl.

ENDDO.

Regards

Tamá

Read only

Former Member
0 Likes
1,674

try this

DATA zahl TYPE I.

DO 10 TIMES.

zahl = zahl + 1.

write:/ 'HALLO', <b>zahl</b>.

ENDDO.

Read only

Former Member
0 Likes
1,674

Chnage the code like this:


DATA ZAHL TYPE I.
DO 10 TIMES.
  ZAHL = ZAHL + 1.
  WRITE:/ 'HALLO ' ,ZAHL.
ENDDO.

Regards,

Vasanth

Read only

Former Member
0 Likes
1,674

hi,

check this in bold

DATA zahl TYPE I.

DO 10 TIMES.

zahl = zahl + 1.

write:/ 'HALLO :' <b>, zahl.</b>

ENDDO.

reward if useful

regards,

nazeer

Read only

Former Member
0 Likes
1,674

Hi erdem,

This will work fine.

DATA zahl TYPE I.

DO 10 TIMES.

zahl = zahl + 1.

write:/ 'HALLO', zahl.

ENDDO.

Reward points.

Younus

Read only

Former Member
0 Likes
1,675

thanks but it is not ecatly what I mean.

It is a special case by a special matter. The

variable zahl must stay be within the string.

like

write:/ 'HALLO zahl'.

and not

write:/ 'HALLO', zahl.

This variable can't stay outboard of the string. This the problem

Reagrds

sas

Read only

0 Likes
1,674

hi

any thing writen within ' ' is printed as given ..only....

Read only

0 Likes
1,674

Hello,

Change the code like this.


DATA ZAHL TYPE I.
DATA: LV_ZAHL(8),
      CHAR(255).

DO 10 TIMES.

  ZAHL = ZAHL + 1.
  WRITE: ZAHL TO LV_ZAHL.
  CONCATENATE 'HALLO' LV_ZAHL INTO CHAR.
  CONDENSE CHAR NO-GAPS.
  WRITE:/ CHAR."'HALLO'NO-GAP,ZAHL NO-GAP.
ENDDO.

Regards,

Vasanth

Read only

0 Likes
1,674

Erdem,

Concatenate 'HALLO' and zahl value into another variable and write that.

Would that help?

Johnson

Read only

Former Member
0 Likes
1,674

try this

data:

zahl(3),

w_test(10).

DO 10 TIMES.

zahl = zahl + 1.

<b>CONDENSE</b> zahl NO-GAPS.

concatenate 'HALLO' zahl INTO w_test.

write:/ w_test.

ENDDO.

Message was edited by:

Rajesh

Read only

sreekanthreddy_marella
Product and Topic Expert
Product and Topic Expert
0 Likes
1,674

I have faced the same problem . this works

CONSTANTS str_con type string value 'Hello'.

data: index(2) type n value 0,

str type string.

DO 20 TIMES.

index = index + 1.

CONCATENATE str_con index into str.

write:/ str.

ENDDO.

hope this helps you .

regards

teenshark