‎2009 Apr 16 12:16 PM
hi experts,
i have one problem when concatenate string.
{ for example:
condition 1: values of f1 = thane
f2 = mumbai
f3 = delhi
concatenate f1 ',' f2 ',' f3 ',' into f separated by space.
then f = thane , mumbai , delhi ,
this is ok.
condition 2: values of f1 = thane,
f2 = mumbai,
f3 = delhi,
concatenate f1 ',' f2 ',' f3 ',' into f separated by space.
then f = thane, , mumbai, , delhi, ,
but i want f = thane , mumbai , delhi ,
condition 3: values of f1 = thane
f2 =
f3 = delhi,
concatenate f1 ',' f2 ',' f3 ',' into f separated by space.
then f = thane , , delhi, ,
but i want f = thane , delhi ,
}
give me idea
Thanks.
‎2009 Apr 16 12:21 PM
well for condition 2 remove the commas before tha concatenate.
in condition 3 after your concantenate do following:
search f for '., ,.'.
if something is found the position of your pattern in string is beeing publishen in sy-fdpos.
the do:
data: lv_fdpos type syst-fdpos.
lv_fdpos = sy-fdpos + 3.
f = f(sy-fdpos) + f+lvfdpos.
‎2009 Apr 16 12:23 PM
>
> hi experts,
> i have one problem when concatenate string.
> { for example:
>
> condition 1: values of f1 = thane
> f2 = mumbai
> f3 = delhi
> concatenate f1 ',' f2 ',' f3 ',' into f separated by space.
> then f = thane , mumbai , delhi ,
> this is ok.
>
> condition 2: values of f1 = thane,
> f2 = mumbai,
> f3 = delhi,
> concatenate f1 ',' f2 ',' f3 ',' into f separated by space.
> then f = thane, , mumbai, , delhi, ,
> but i want f = thane , mumbai , delhi ,
>
> condition 3: values of f1 = thane
> f2 =
> f3 = delhi,
> concatenate f1 ',' f2 ',' f3 ',' into f separated by space.
> then f = thane , , delhi, ,
> but i want f = thane , delhi ,
> }
> give me idea
>
> Thanks.
FOR condition 2:
values of f1 = thane,
f2 = mumbai,
f3 = delhi,
concatenate f1 f2 f3 into f separated by ','.
then f = thane, mumbai, delhi,
‎2009 Apr 16 12:23 PM
Use CONDENSE Statement with f.
CONDENSE F.Edited by: Amresh kumar Panda on Apr 16, 2009 4:59 PM
‎2009 Apr 16 12:24 PM
>
> hi experts,
> i have one problem when concatenate string.
> { for example:
>
> condition 1: values of f1 = thane
> f2 = mumbai
> f3 = delhi
> concatenate f1 ',' f2 ',' f3 ',' into f separated by space.
> then f = thane , mumbai , delhi ,
> this is ok.
>
> condition 2: values of f1 = thane,
> f2 = mumbai,
> f3 = delhi,
> concatenate f1 ',' f2 ',' f3 ',' into f separated by space.
> then f = thane, , mumbai, , delhi, ,
> but i want f = thane , mumbai , delhi ,
>
> condition 3: values of f1 = thane
> f2 =
> f3 = delhi,
> concatenate f1 ',' f2 ',' f3 ',' into f separated by space.
> then f = thane , , delhi, ,
> but i want f = thane , delhi ,
> }
> give me idea
>
> Thanks.
Hi Ramayya,
condition 1: values of f1 = thane
f2 = mumbai
f3 = delhi
concatenate f1 ',' f2 ',' f3 ',' into f separated by space.
* then f = thane , mumbai , delhi ,
*this is ok.
>
condition 2: values of f1 = thane,
f2 = mumbai,
f3 = delhi,
concatenate f1 ',' f2 ',' f3 ',' into f separated by space. " Use zseperated by ',' instead of Space
then f = thane, , mumbai, , delhi, ,
but i want f = thane , mumbai , delhi ,
condition 3: values of f1 = thane
f2 =
f3 = delhi,
concatenate f1 ',' f2 ',' f3 ',' into f separated by space.
then f = thane , , delhi, ,
but i want f = thane , delhi ,
try this
condense f.
use this syntax to acheive the thane , delhi..
replace ',,' with ',' into f. "Use this syntax it will work
regards,
Prabhudas
‎2009 Apr 16 12:26 PM
Hi.
I would do this within a loop, where you check if the string you would like to add to your list is in the correct format. like this: 'delphi'
- check if initial
- check if ',' in the string
In addition you are able to do this for as many strings as you want to.
Regards, Clemens
‎2009 Apr 16 12:29 PM
DATA :F1(9),F2(9),F3(9),F(30).
f1 = 'thane'.
f2 = ''.
f3 = 'delhi'.
IF F1 <> '' AND F2 <> '' AND F3 <> ''.
concatenate f1 f2 f3 into f separated by ','.
ELSEIF F1 <> '' AND F2 = '' AND F3 <> ''.
concatenate f1 F3 into f separated by ','.
ENDIF.
WRITE f .
TRY THIS ..IT WILL SOLVE UR PROBLEM.
‎2009 Apr 16 12:32 PM
Hi,
Check the following code, it is working fine.
ata: thane(5) type c value 'thane',
mumbai(6) type c value 'mumbai',
f(15) type c.
concatenate thane ',' mumbai into f SEPARATED BY space.
condense f.
write f.
Please let me know if there are any further issues on this
‎2009 Apr 16 12:34 PM
hi,
it very simple
use this code i will get it ..
condition 2: values of f1 = thane,
f2 = mumbai.
f3 = delhi.
concatenate f1 ',' f2 ',' f3 ',' into f separated by space.
then f = thane, mumbai, delhi,
but i want f = thane , mumbai , delhi ,
‎2009 Apr 16 12:36 PM
Hello Ramya,
This will solve thee second part of your question
IF f CA ',,' .
REPLACE ',' IN f WITH ''.
ENDIF.
Explanation :
CA - Contains Any
Regards,
K.Sibi
Please revert back if the answer is not the expected .
‎2009 Apr 16 12:44 PM
well that wont work, this will remove exactly ONE comma.
you´d need this addition "ALL OCCURRENCES" of statement replace.
But still it wont wor cause then you wont have any commas at all in your string afterwards.
‎2009 Apr 16 12:50 PM
Hello Florian Kemmer ,
I would like to add a point to your reply.We can replace all occurences of "',," with "," this would solve the problem rite?.I have tried to do that .Please correct me if I am wrong .
Regards,
K.Sibi
‎2009 Apr 16 1:25 PM
Try this:
Split the concatenate statement.
DATA f1(20) TYPE c VALUE 'Thane'.
DATA f2(20) TYPE c VALUE 'Mumbai'.
DATA f3(20) TYPE c. VALUE 'Vashi'.
DATA result(100) TYPE c.
IF f1 IS NOT INITIAL.
CONCATENATE f1 ' , ' INTO f1.
ENDIF.
IF f2 IS NOT INITIAL.
CONCATENATE f2 ' , ' INTO f2.
ENDIF.
IF f3 IS NOT INITIAL.
CONCATENATE f3 ' , ' INTO f3.
ENDIF.
CONCATENATE f1 f2 f3 INTO result SEPARATED BY space.
WRITE result.regards,
Advait
‎2009 Apr 16 6:14 PM
USE THESE STATEMENTS BEFORE YOU CONDITION STARTS.
SHIFT F1 RIGHT DELETING TRAILING ',' .
SHIFT F2 RIGHT DELETING TRAILING ',' .
SHIFT F3 RIGHT DELETING TRAILING ',' .This will give you output as you get it in the first case, for every condition.
Regards,
Lalit Mohan Gupta.
‎2009 Jun 24 2:31 PM