05-31-2007 1:42 AM
hello friends,
i was trying to concatenaete two values with space in between,
but its not giving space in the output file.
concatenate var1 ' ' var2 into result.
but its outputting var1var2 continously with out that gap.
can some one help.
05-31-2007 1:43 AM
05-31-2007 1:43 AM
05-31-2007 1:55 AM
but friends,
if my case
i have to display
v1 v2 v3 v4
if v3 doesnot have value, it should show space.
like
v1 v2 ' ' v4.
05-31-2007 2:56 AM
HI saritha
U can use the following statement
CONCATENATE V1 V2 V3 V4 into V5 separated by space.
Reward points me if its useful.
Regards
ravi
05-31-2007 3:06 AM
05-31-2007 3:12 AM
Hi Saritha,
I think this is not possible.
It concatenates all the variables and puts one space in between all of them.
It will ignore v3 if it has no value or value ' '.
Earlier i had to get 2 spaces in between 2 variables in a concatenate statement but i couldn't.
I had to do it using +offset(length) method.
05-31-2007 3:48 AM
Hi Saritha,
Now let me give solution for your situation.
You say you have 3 variable v1 v2 v3 and you want to cancatnate into v4. If any of the variable is empty you want to display space.
Ex:
DATA : v1(3) value 'one',
v2(3),
v3(3) value 'two',
v4(15).
IF v1 IS INITIAL.
v1 = '#'.
ENDIF.
IF v2 IS INITIAL.
v2 = '#'.
ENDIF.
IF v3 IS INITIAL.
v3 = '#'.
ENDIF.
CONCATENATE v1 v2 v3 into v4.
REPLACE '#' with SPACE into v4.
WRITE v4.
Output Here is 'ONE TWO'
I guess this solves your problem.
Reward points to all useful answers.
Regards,
SaiRam
05-31-2007 1:58 AM
why dont u try this one
concatenate var1 var2 into result separated by space.
05-31-2007 2:27 AM
Hi Saritha
When you concatenate without separating the strings by space then it doesnt take into account the spaces in the strings being concatenated.
Only by the addition of 'SEPARATED BY space' can you take care of the variables with a value of space in them.
So go ahead with
CONCATENATE var1 ' ' var2 into result SEPARATED BY space.
Cheers
Shivika
05-31-2007 3:16 AM
hey darshil
if the value in v2 is space and u use the concatenate with separated by space , it can never ignore that space in v2. instead it will introduce 2 spaces in between v1 and v3. code and check.
cheers
shivika
Message was edited by:
Shivika Bhorchi
05-31-2007 3:38 AM
Hi Shivika,
you can write the code and check.
data : v1(10), v2(10), v3(10), v4(40).
v1 = 'hi'.
v2 = ' '.
v3 = 'abac.'.
concatenate v1 v2 v3 into v4 separated by space.
write v4.
those 2 spaces are : one space after v1 and one space before v3.
v2's spaces will never be displayed.
you can try having value of v2 as 'a '.
it will still display 'hi a abac.' and it will ignore spaces fo variable v2.
05-31-2007 3:17 AM
try this one this is working
concatenate var1 var2 var3 var4 into result separated by space.
if there is nthng in variable thn it will be displayed as a space.
eg var1='one', var2 = 'two', var4= 'four'.
thn o/p = one two four.
after two there will be 2 spaces.
does this works ?
05-31-2007 5:31 AM
Hi darshil
I guess you are right. Sai's solution is working perfectly in this case.
05-31-2007 5:54 AM
Hi,
Try this just copy n paste the code n run.
DATA: var1(6) TYPE c VALUE 'ABCDEF',
var2(5) TYPE c VALUE 'GHIJK',
result(12) TYPE c .
CONCATENATE var1 var2 INTO result SEPARATED BY ' '.
WRITE: result.
with regards,
Sudha.
reward points if useful.
06-22-2007 9:12 AM
you can use the folloing code to do the formating of the data .
CONCATENATE l_str_tmp(4) '-' l_str_tmp4(2) '-' l_str_tmp6(2) INTO l_str_date .
CONCATENATE l_str_tmp8(2) ':' l_str_tmp10(2) ':' l_str_tmp+12(2) INTO l_str_time.
CONCATENATE l_str_date l_str_time INTO l_str_tmp SEPARATED BY space .