cancel
Showing results for 
Search instead for 
Did you mean: 

Help required on parsing data

abhay_sah
Advisor
Advisor
0 Kudos

Hi,

I need some inputs/pointers on this issue :

There is a webdynpro(ABAP) UI element Formattedtextedit which allows rich text to be added to a note .

When the data is saved and reopened and displayed in the same UI element ,the text is shown with the same features as it was entered (Bold/strong/header etc.) . But when the saved text is displayed in any other field (e.g. textedit) , the data is displayed with the entire tags , the same way as it was saved. Similarly , if the rich text is entered as a note and the same is sent via a mailing agent , the entire saved data is displayed with the tags .

Is there any existing API through which the text could be parsed before displaying the data in the two cases mentioned above?

Please provide us with some input/pointers on this issue.

Thanks and regards,

Abhay

Edited by: Abhay Sah on Jul 16, 2008 10:11 AM

Edited by: Abhay Sah on Jul 16, 2008 10:11 AM

Edited by: Abhay Sah on Jul 16, 2008 10:12 AM

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I see that you are an SAP employee. Also you are asking questions about the formattedTextEditor, so you must be working on NetWeaver 7.1 or 7.0 Enhancement Package 1 since formattedTextEditor is not yet released for customers. It is probably more appropriate to ask quesitons about unreleased features in the SAP employees-only version of the Web Dynpro ABAP formum on SDN in the future.

The API for conversion of the formattedText is CL_WD_FORMATTED_TEXT. However there isn't method to strip the tags out. However removing tags can be done with one line of code using a greedy REGEX:

replace all occurrences of regex '<[^>]+>' in l_formatted_text with ``.

Answers (4)

Answers (4)

abhay_sah
Advisor
Advisor
0 Kudos

Hi all,

Thanks for the inputs.

I have found a working solution .

Regards,

Abhay

Uwe_Klinger
Advisor
Advisor
0 Kudos

Hi,

there is some functionality available that supports "rendering" a formatted text differently, e.g. as plain text:

You need to create a class that implements the interface IF_WD_FORMATTED_TEXT_RENDERER.

Just implement method RENDER_TEXT to extract the text. Use an instance of this class (plain_text_renderer) like this:

formatted_text = CL_WD_FORMATTED_TEXT=>CREATE( xml_text ).

formatted_text->render( plain_text_renderer ).

Best Regards,

Uwe

abhay_sah
Advisor
Advisor
0 Kudos

Thanks!

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi Abhay

I didn't find any API as such, you can make use of this code snippet for typical use

str is a formatted text

data: offset1 type i,

offset2 type i,

len type i,

line type i.

DATA: matcher TYPE REF TO cl_abap_matcher,

match TYPE match_result,

matches type MATCH_RESULT_TAB.

IF cl_abap_matcher=>contains( pattern = '>*</' text = str ) = abap_true.

matcher = cl_abap_matcher=>get_object( ).

match = matcher->get_match( ).

offset1 = match-offset.

ENDIF.

IF cl_abap_matcher=>contains( pattern = '>' text = str ) = abap_true.

matcher = cl_abap_matcher=>get_object( ).

matches = matcher->find_all( ).

loop at matches into match.

if match-offset > offset1.

exit.

endif.

offset2 = match-offset.

endloop.

ENDIF.

offset2 = offset2 + 1.

len = offset1 - offset2.

write: str+offset2(len).

Abhi