cancel
Showing results for 
Search instead for 
Did you mean: 

How to find newline in a string?

ira_smailer
Explorer
0 Kudos

Hi Experts,

I have a comment box on the UI where the user can type a longtext. This is saved as a string. Later, this string is used to create a text with SAVE_TEXT. My problem is that the formatting information is lost somehow, especially the carriage return (newline) information.

Example:

longtext:

This is text

Text on second line

Text on third line

after using SAVE_TEXT:

This is textText on second lineText on third line

So I need to preserve the newline. I have tried

split lv_string at cl_abap_char_utilities=>cr_lf

that does not work.

Similarly, function module CONV_TEXTSTRING_TO_ITF does not work either.

Any suggestions?

Thanks, Ira

Accepted Solutions (0)

Answers (7)

Answers (7)

deepak_dhamat
Active Contributor
0 Kudos

Hi ira ,

When you use dialog for multiple line text . There it mogth not be storing Line feed character . so you have to Divide Those String by maintaining certain standard of Special Character while Breaking the line .

Can you tell me What you are using as Dialog for entering data .

Hope we all can come up with good Solution .

regards

Deepak.

Former Member
0 Kudos

Hi,

Use CL_ABAP_CHAR_UTILITY with CR_LF and split the string...

Hope this might help..

deepak_dhamat
Active Contributor
0 Kudos

Hi ,

Check spliting the string with NEWLINE .

i.e

CONSTANTS :c_tab type ABAP_CHAR1 value CL_ABAP_CHAR_UTILITIES=>NEWLINE .

split t_text at c_tab into t_text1 t_text2 in CHARACTER MODE.

regards

Deepak.

Edited by: Deepak Dhamat on Oct 11, 2011 11:50 AM

ira_smailer
Explorer
0 Kudos

Hello experts,

I have tried all your suggestions but nothing works.

Splitting at cl_abap_char_utilities=>cr_lf does not work. Same for cl_abap_char_utilities=>newline.

Trying an own "cr_lf" based on what I see in the debugger in the hex representation also does not work. That is because my string is in character mode, and if I try to convert to Xstring then my "own_crlf" also gets converted and has some different value. And in one split statement I cannot mix variables in char and byte mode.

Any other ideas?

Thanks, Ira

Former Member
0 Kudos

Hi,

If you are saving the text using SAVE_TEXT then why don't you use READ_TEXT function module to read the text?

ChandraMahajan
Active Contributor
0 Kudos

Hi,

are u using string table to collect the contents? try to use as below,

DATA : it_string TYPE string_table.

CONSTANTS: crlf TYPE string VALUE cl_abap_char_utilities=>cr_lf.

SPLIT lv_content AT crlf INTO TABLE it_string.

Thanks,

Chandra

deepak_dhamat
Active Contributor
0 Kudos

Hi Ira ,

DO you find any special Character in string .

regards

Deepak.

ira_smailer
Explorer
0 Kudos

Hi Deepak,

No, in the debugger I do not see any special character in my string. I was looking for '#' characters but they are also not there.

Regards, Ira

ira_smailer
Explorer
0 Kudos

Hi Matt,

The example was created by me. So yes, I'm sure that newline was pressed. The text can also wrap sometime, but for sure I need to detect when the newline has been pressed.

This comes from Adobe Interactive form. The comment box on the form is then evaluated by looking at the XML representation. This then gives me the text in string form.

I have not analyzed the binary representation because I did not know how or what to look for.

Any suggestions?

Ira

Former Member
0 Kudos

Hi Ira,

try to debug and look at the HEX-Values.

CR_LF has '0D0A'.

Does your string has this Value?

Hope it helps.

Regards, Dieter

ira_smailer
Explorer
0 Kudos

Hi Dieter,

I looked in the debugger at the HEX version of my string. I do not see any '0D0A'. At the place where the newline should be I see '6100'.

Any suggestions?

Thanks, Ira

Former Member
0 Kudos

Hi,

i'm not quit sure but can you try this

CONSTANTS:

OWN_CRLF(2) TYPE X VALUE '6100'.

and split with own_crlf.

Regards, Dieter

matt
Active Contributor
0 Kudos

If lv_string is receiving the value from the xml without the CR, then the solution probably doesn't exist within the ABAP environent. Maybe there's something in the way you've defined the text box that is stripping these characters out.

If you like, I'll move the thread to the Adobe Interactive Forms forum, where you might get more specialist help, then people repeatedly suggesting that you use split...

ira_smailer
Explorer
0 Kudos

Hi Matt,

Yes, please feel free to move this thread to Adobe forms forum. It would definitely help to know if there is some feature of Adobe forms that either adds or removes these special characters.

Thanks, Ira

matt
Active Contributor
0 Kudos

Are you sure newline is pressed, and the text isn't wrapping? What UI are you using - Dynpro, Web Dynpro, BSP? Have you debugged the source and checked the hex representation of lv_string?

matt