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

Former Member
0 Likes
797

Hi all

I have to do a CONCATENATE with some string.

The problem is that if one of this is space, this one doesn't appear in concatenated string, but I want it.

Any solution?

thanks

enzo

1 ACCEPTED SOLUTION
Read only

former_member225448
Participant
0 Likes
764

Hello Enzo,

there is no real good solution, but, if possible, translate the space to e.g. '_', CONCATENATE, and translate it back.

BTW.: Kernel 7.0 will have a "PRESERVING SPACE" extension for CONCATENATE.

If you find my answer useful, please don't forget the reward.

Regards,

Juergen

Hello Enzo,

there is no real good solution, but, if possible, translate the space to e.g. '_', CONCATENATE, and translate it back.

BTW.: Kernel 7.0 will have a "PRESERVING SPACE" extension for CONCATENATE.

If you find my answer useful, please don't forget the reward.

Regards,

Juergen

4 REPLIES 4
Read only

Former Member
0 Likes
764

Check the following thread...

Don't forget to reward

Read only

former_member225448
Participant
0 Likes
765

Hello Enzo,

there is no real good solution, but, if possible, translate the space to e.g. '_', CONCATENATE, and translate it back.

BTW.: Kernel 7.0 will have a "PRESERVING SPACE" extension for CONCATENATE.

If you find my answer useful, please don't forget the reward.

Regards,

Juergen

Read only

Former Member
0 Likes
764

Hi,

The CONCATENATE statement combines two or more separate strings into one.

CONCATENATE <c1> ... <cn> INTO <c> [SEPARATED BY <s>].

This statement concatenates the character fields <c1> to <cn> and assigns the result to <c>. The system ignores spaces at the end of the individual source strings.

The addition SEPARATED BY <s> allows you to specify a character field <s> which is placed in its defined length between the individual fields.

If the result fits into <c>, SY-SUBRC is set to 0. However, if the result has to be truncated, SY-SUBRC is set to 4.

DATA: C1(10) VALUE 'Sum',

C2(3) VALUE 'mer',

C3(5) VALUE 'holi ',

C4(10) VALUE 'day',

C5(30),

SEP(3) VALUE ' - '.

CONCATENATE C1 C2 C3 C4 INTO C5.

WRITE C5.

CONCATENATE C1 C2 C3 C4 INTO C5 SEPARATED BY SEP.

WRITE / C5.

Output:

Summerholiday

Sum - mer - holi - day

In C1 to C5, the trailing blanks are ignored. The separator SEP retains them.

Hope it helps u.

Thanks&Regards,

Ruthra

Read only

0 Likes
764

EX:

DATA : S1 TYPE STRING VALUE 'ABC 123',

S2 TYPE STRING VALUE 'DEF 888',

S3 TYPE STRING VALUE ' '.

CONCATENATE S1 S2 INTO S3 SEPARATED BY ' '.

WRITE:/ S3.