Application Development 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: 

concatenate strings without trim space

Former Member
0 Kudos

Hi, i am looking for a Method in ABAP that concatenate strings without trim space on any string.

I will send a PDF-Document from the archivelink as attachment in an E-Mail, but the archivelink function deliver the document in lines with 1024 character und the input function for the attachment of the E-Mail need the document in lines with 255 character.

I think, concatenate all lines und seperate them, but sometimes i lose a space.

I try some solutions:

DATA l_document(65535) TYPE c.

DATA line_doc_length TYPE i.

line_doc_length = 0.

LOOP AT archivobject INTO wa_archivobject.

l_document+line_doc_length = wa_archivobject.

line_doc_length = line_doc_length + 1024.

ENDLOOP.

That solution match, but the max length of the document is 65535 character.

I try the same with a dynamic Object like 'Create Data ...', but in this case it is not allowed to use an offset.

Thanks for help

Frank Dehle

1 ACCEPTED SOLUTION

former_member194669
Active Contributor
0 Kudos

Hi,

Why don't you declare as string


DATA l_document TYPE string.

aRs

4 REPLIES 4

former_member194669
Active Contributor
0 Kudos

Hi,

Why don't you declare as string


DATA l_document TYPE string.

aRs

0 Kudos

Hi,

thanks for your response, but this was my first try. The one and only command that i found in ABAP to concatenate strings, is 'CONCATENATE' and this command has no option for no trim space und that is, I think, the main problem.

The second problem is, I can't found a function to set the length of a parameter from type string und you receive a compiler error by use offsets and/or length on parameter from type string.

DATA l_document TYPE string. "<<<<<<<<< I try your suggestion

DATA line_doc_length TYPE i.

line_doc_length = 0.

LOOP AT archivobject INTO wa_archivobject.

l_document+line_doc_length = wa_archivobject. "<<<<<<<<<<<<<<< Error

line_doc_length = line_doc_length + 1024.

ENDLOOP.

original message from compiler:

- At the write position, you cannot use offset and length specifications with fields of type "STRING" or "XSTRING". -

Thanks

Frank Dehle

0 Kudos

use the character ` ` instead of ' '.

example:


DATA: vl_data TYPE string.
CONCATENATE 'a' `   `    'b' INTO vl_data.
WRITE vl_data.

the output:

a b

0 Kudos

You can use this code to make sure that a space is inserted between the lines that you are concatenating:

CONCATENATE string_a string_b INTO total_string SEPARATED BY space.

I hope this helps.

- April King