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

Concatenate with empty string

vallamuthu_madheswaran2
Active Contributor
0 Likes
4,384

Hi Friends,

I've concatenate around 10 strings,  if any one of the string is empty then it concatenate the space also

For example: 

   CONCATENATE w_report-bukrs  w_report-year     w_report-month   w_report-matnr w_report-orgcom
                    w_report-orggeo w_report-destcom  w_report-destgeo w_report-units INTO l_output SEPARATED BY '^'.

Current Output is:  6038^2012^03^9000000200^000^100^^9900^0000000000010

Expecting result is: 6038^2012^03^9000000200^000^100^         ^9900^0000000000010

Thanks & Regards,

Vallamuthu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,537

Vallamuthu,

I think it's not possible with concatenate statement. But try with ASCII codes ie in place of 'space' use alt+32.

Regards,

Phani.

9 REPLIES 9
Read only

Former Member
0 Likes
2,538

Vallamuthu,

I think it's not possible with concatenate statement. But try with ASCII codes ie in place of 'space' use alt+32.

Regards,

Phani.

Read only

0 Likes
2,537

Hi Phani,

Can you provide the example code.

Thanks & Regards,

Vallamthu M

Read only

0 Likes
2,537

Hi Sony,

Use the code as below:

T1 type string value '001',

T2 type string value '002',

TR type string.      " result

concatenate t1 'perss alt button and hold press number 32(This will create spce)'  t2 into tr.

*If it fails then take a dummy variable(extra) t3 type string value '    D'     " remember before D there should be spaces.

concatenate t1 t3 t2 into tr.

replace all occurances of 'D' in TR with space.

Regards,

Phani.

Read only

Former Member
0 Likes
2,537

Hi Vallamuthu,

Are you only concatenating numbers? If yes, maybe you can do this:

  1. Check the variables if any of them is initial. If yes, fill them with 'x'.
  2. Concatenate the variables.
  3. Replace 'x' with space using REPLACE.

Regards,

Karl

Read only

0 Likes
2,537

Hi Karl,

Thanks for your reply, I Tried that logic also, but it gives the same result.

6038^2012^03^9000000200^000^100^^9900^0000000000010

Thanks & Regards,

Vallamuthu

Read only

jitendra_it
Active Contributor
0 Likes
2,537

Hi Vallamuthu,

Use RESPECTING BLANKS  addition of concatenate statement.

Many Thanks,

Jitendra

Read only

0 Likes
2,537

Hi Jitendra,

Thanks for your reply, RESPECTING BLANKS give space inbetween all the variables. I need to concatenate the blank variable as blank.

Thanks & Regards,

Vallamuthu M

Read only

Former Member
0 Likes
2,537

HI,

if replacing blanks dont work, you can do the following things.

for all your strings before concatinate do

TRANSLATE ur string name USING ' #'.

After concatinate do this for the reculted string,

TRANSLATE The Result String USING '# '.

This worked for me.

hope this helps.

Read only

Former Member
0 Likes
2,537
Hi,
You would also have achieved this with a single assignment...
DATA: l_output TYPE string.
l_output = w_report.
WRITE: l_output.
In case a special separator is needed, you can add dummy fields in your w_report structure to hold that value.
e.g.
TYPES: BEGIN OF ts_report,
        bukrs(4) TYPE c,
        dummy1 TYPE c,
        year(4) TYPE c,
        dummy2 TYPE c,
"...
END OF ts_report.
DATA: w_report type ts_report.
w_report-dummy1 = w_report-dummy2 = ... = '^'.
Cheers,
Manu.