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

strings

Former Member
0 Likes
818

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..

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
799

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

6 REPLIES 6
Read only

Former Member
0 Likes
799

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

Read only

JozsefSzikszai
Active Contributor
0 Likes
800

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

Read only

Former Member
0 Likes
799

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

Read only

0 Likes
799

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!

Read only

Former Member
0 Likes
799

plz see my response below

Read only

Former Member
0 Likes
799

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.