‎2008 Jun 30 3:12 PM
Hi..
I have some strings in an internal table and i am using concatenate to get the strings in the following format.
Format : Mrfirstnamesecondnamemiddlenameage
now this middle name may not always exist for all records, and in that case i need a space in that section
Eg : MrABCDEFGH^ ^33
At present my output is MrABCDEFGH^^33, i want it the above way
How can i traverse through the string till the third ^ and insert a space there..the first name n second name lengths vary with each record..
‎2008 Jun 30 3:19 PM
hi Rahul,
fiirst check is Middlename has any value, than CONCATENATE accordingly:
IF Middlename IS INITIAL.
CONCATENATE Mr firstname secondname space age INTO string SEPARATED BY '^'.
ELSE.
CONCATENATE Mr firstname secondname middlename age INTO string SEPARATED BY '^'.
ENDIF.
hope this helps
ec
‎2008 Jun 30 3:17 PM
Hi,
You can Try this.
Concatenate first two fields.
Before concatenating MiddleNAme write this.
if itab-middle is initial.
concatenate string itab-middle into string separated by space.
else.
concatenate string itab-middle into string.
endif.
That will definately help.
Reward if useful.
Sumit Agarwal
‎2008 Jun 30 3:19 PM
hi Rahul,
fiirst check is Middlename has any value, than CONCATENATE accordingly:
IF Middlename IS INITIAL.
CONCATENATE Mr firstname secondname space age INTO string SEPARATED BY '^'.
ELSE.
CONCATENATE Mr firstname secondname middlename age INTO string SEPARATED BY '^'.
ENDIF.
hope this helps
ec
‎2008 Jun 30 3:30 PM
Hi,
try this.
1. concatenate field 1 and field 2 into resulting string.
2. Check wheather exists or not by IF...ENDIF. block
If it exists then concatenate it or else do nothing. DON'T CONCATENATE SPACE , AS TRAILING SPACE IS NOT CONCATENATED . SO TAKE A FLAG VARIABLE AND SET ITS VALUE 1 (INITIALY KEEP IT IN 0).
3. If FLAG = 0 ---> concatenate age
elseif Flag = 1 --> concatenate space age to the resulting string.
it will defenitely work.
revert me for any doubt.
Reward if found helpful.
Anirban Bhattacharjee
‎2008 Jun 30 3:44 PM
Hi...
I am using this
if itab-middle is initial.
concatenate 'Mr' Firstname secname SPACE age into text.
else.
concatenate 'Mr' Firstname secname middlename age into text.
endif.
And guess what my output doesn still have the space!!!
I tried replacing SPACE by ' ', still no luck!
‎2008 Jun 30 3:48 PM
‎2008 Jun 30 5:54 PM
Hello Rahul,
you can try this way..
concatenate 'Mr' Firstname secname into text.
concatenate text age into text seperated by space.Hope this works for you
Regards
Indu.