08-09-2010 9:44 AM
Hi,
i need to fill a variable with some char like 'A' or 'B' but it is flexible.
i mean, i will do it as required, for example i need to put 10 'A' if the variable needs 10,
15 if it needs 15.
And need is like that, variable lenght is 40 and assume 25 of it is full and 15 is blank.
i want to fill this 15 char with 'A'. How can i put a number of char to the variable?
thanks.
08-09-2010 10:31 AM
The best way is to use TRANSLATE:
DATA: v_ip(40) TYPE c.
v_ip = '12345678901234567890123456789012345'. "35 characters
TRANSLATE v_ip USING ' A'. " ' A' --> Replace the space with A, output will have 5 A's
WRITE / v_ip.
Edited by: Suhas Saha on Aug 9, 2010 3:04 PM
08-09-2010 10:11 AM
Hi,
You can achieve ur requirement like this,
Eg.
DATA: v_value(10) TYPE C.
v_value = 'ABCDEF'.
CONCATENATE v_value 'AAAAAAAAAA' INTO v_value.
Check the value of v_value variable. If your variable has 10 char then concatenate 10 'A's, it is 15 char length concatenate 15 'A's
There will be an overflow when it calls in runtime but it gives solution to ur requirement.
Regards,
Selva
Edited by: Selva M on Aug 9, 2010 2:50 PM
08-09-2010 10:24 AM
data:char_var(40) type c.
data:value type char25.
value = '1234567891234567891234567'.
do 40 times.
concatenate char_var 'A' into char_var.
enddo.
len = strlen ( value ).
len = len - 1.
char_var+0(len) = value.
write char_var.
08-09-2010 10:31 AM
The best way is to use TRANSLATE:
DATA: v_ip(40) TYPE c.
v_ip = '12345678901234567890123456789012345'. "35 characters
TRANSLATE v_ip USING ' A'. " ' A' --> Replace the space with A, output will have 5 A's
WRITE / v_ip.
Edited by: Suhas Saha on Aug 9, 2010 3:04 PM