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

Dynamic values

Former Member
0 Likes
1,007

Guys,

Data: var type i,

chhar(10) type c.

do 3 times.

add 1 to var.

chhar = 'CHARACTER( var )'.

WRITE: / chhar.

enddo.

I want the output as

CHARACTER1

CHARACTER2

CHARACTER3.

but im unable to do it. Could anyone please help me out. I donot want to use concatenate.

Thanks,

Santosh.

12 REPLIES 12
Read only

rejish_balakrishnan
Contributor
0 Likes
984

Hi,

Data: var type c,
chhar(9) type c,
char(9) type c value 'character'.

do 3 times.
add 1 to var.
chhar = char.

WRITE  :  chhar .
write  : 10 var.
skip .

enddo.

Please check if it does meet your requirement.Otherwise please feel to reply in wt condition u want that required output.

Read only

Pawan_Kesari
Active Contributor
0 Likes
984

DATA: var TYPE i,
chhar(10) TYPE c.

DO 3 TIMES.
  chhar = sy-index .
  CONDENSE chhar .
  CONCATENATE 'CHARACTER' chhar into chhar .
  WRITE: / chhar.
ENDDO.
Read only

Former Member
0 Likes
984

Data: var(1) type N,

ch type C,

chhar(10) type c.

do 3 times.

add 1 to var.

ch = var.

concatenate 'CHARACTER' ch into chhar.

WRITE: / chhar.

enddo.

Regards

Sandip

Read only

former_member156446
Active Contributor
0 Likes
984

try this way:

DATA: var TYPE i,
chhar(10) TYPE c.

DO 3 TIMES.
  ADD 1 TO var.
  chhar+0(9) = 'CHARACTER'.
  chhar+9(1) = var.
  WRITE: / chhar.
ENDDO.

Read only

Former Member
0 Likes
984

No Guys,

I said No Concatenate. How do we assign it dynamically.

Thanks,

Santosh.

Read only

0 Likes
984

>

> I said No Concatenate. How do we assign it dynamically.

>

my reply has no concatenate..

Read only

0 Likes
984

Thank you so much Jay for ur answer but i am looking for something like this

chhar = 'CHARACTER( var )'. but not offsets or concatenation.

Thanks,

Santosh.

Read only

0 Likes
984

Maybe you could use REPLACE, if you know the var name, do you know?

Regards

Read only

0 Likes
984

>

> but not offsets or concatenation.

>

Hi, you are like the business team, don't say all at once.... Kidding I doubt if its possible without offset or concatenate...

Read only

0 Likes
984

Hi,

Did u try the code written by me.Just to know whether u had a look at it !

Read only

Pawan_Kesari
Active Contributor
0 Likes
984

Could you explain the actual problem.. or is that a interview question?

Read only

former_member222860
Active Contributor
0 Likes
984

Try

Data: var type i.

var = 0.
Do 3 times.
add 1 to var.
WRITE: /'CHARACTER ', var .
Enddo.