cancel
Showing results for 
Search instead for 
Did you mean: 

FormattedTextView - related question

matteo_montalto
Contributor
0 Kudos

Hi all gurus,

I need to insert a huge amount of text in a custom WD (a popup view, specifically).

This text should be formatted, as there are titles, bold parts and so on. I already have it in HTML, so... what's the best way to insert it into my popup?

Considering:

- that the text is formatted (and I should keep that format);

- that the text will be translated into few languages;

as far as I've seen, FormattedTextView is the right way to approach the task. But I didn't understand what's the correct procedure...

In particular, i'm confused about TEXT property binding... How can I enter the (formatted) text into the system?

An OTR element seems not adeguate; SAPScript is too limited. And if it's not an OTR element, then "direct" binding shouldn't be possible so the steps should be:

- bind the TEXT property to a Context attribute (type string?!?);

- in WDDOINIT, retrieve the text (how? where?) and fill the Context attribute with it.

Hope someone will clarify these aspects, even with a step-by-step procedure, if possible.

Thanks all,

M.

Accepted Solutions (1)

Accepted Solutions (1)

Abhinav_Sharma
Contributor
0 Kudos

Hi Matteo,

This is an interesting question. As rightly said, OTR and TextSymbols are not suitable for such kind of requirement because of huge size of the text that you want to display.

So the option left is using the FormattedTextView. How to use it? Here is code snippet that you can try..


Lets say you have created a context attribute of type String, say msg and bound the same with the TEXT property of the FormattedTextView.
Now in the wdDoInit what you can do is:

DATA: el_root type REF TO if_wd_context_element,
      lv_msg type string.


     lv_msg = `Click <a href="mailto:someone@example.com">here</a> to send mail`.
      el_root = wd_context->get_element( ).
      el_root->set_attribute( exporting name = 'MSG' VALUE = LV_msg ).

No wthe main question is where to store the data. I think we can create a Z-table and store the data. There can be SPRAS field which we can use to identify the language and we cna maintain the translations in the ZTABLE itself.

You can embedd the HTML tags in FormattedTextView. For complete list of supported tags refer FormatedTextView

Hope it will guide you in the right direction. Thanks!

Regards

Abhinav

matteo_montalto
Contributor
0 Kudos

Hello Abhinav,

I did as follows:

- created a general text in SE61, for the desired language;

- created a FormattedTextView element in my view and binded it to a context's custom attribute (type string);

- wrote this snippet of code in WDDOINIT:

* bind text

Data: lo_el_context_ftv type ref to if_wd_context_element,

          lv_ftv_text type string,

          lt_ftv_text TYPE STANDARD TABLE OF tline,

          ls_header TYPE thead,

          lo_format_text TYPE REF TO cl_wd_formatted_text,

          lv_doc_state TYPE dokstate,

          se61_object type dokhl-object value 'my_sample_text',

          lo_ft_text type ref to cl_wd_formatted_text.

* Get the formmated text by passing the se61 text id

   CALL FUNCTION 'DOCU_GET_FOR_F1HELP'

     EXPORTING

       id         = 'TX'

       langu    = sy-langu

       object   = 'ZTERMS_AND_CONDITIONS'

     IMPORTING

       dokstate = lv_doc_state

       head       = ls_header

     TABLES

       line     = lt_ftv_text

     EXCEPTIONS

       ret_code = 1

       OTHERS   = 2.

* Format the se61 text

     CALL METHOD cl_wd_formatted_text=>create_from_sapscript

       EXPORTING

         sapscript_head  = ls_header

         sapscript_lines = lt_ftv_text

         type            = cl_wd_formatted_text=>e_type-formatted_text

       RECEIVING

         formatted_text  = lo_ft_text.

     IF lo_ft_text is not initial.

      lv_ftv_text = lo_ft_text->m_xml_text.

     ENDIF.

* Bind the text to the context

   DATA lo_el_context TYPE REF TO if_wd_context_element.

   DATA ls_context TYPE wd_this->Element_context.

   lo_el_context = wd_context->get_element( ).

   lo_el_context->set_attribute(

     name `RENDER_TEXT`

     value = lv_ftv_text ).

It works? Yes, BUT...

The format of the text is quite horrible; I've seen the list of supported tags and found nothing that could help with the following tasks:

- increase Font dimension (yep, by now it's *too* small);

- set the horizontal alignment so that the title is centered.

Moreover: even if I use SAPscript editor in SE61, I'm not able to set words in a row with different formats: for example:

THIS is an example


Actually, my guess is this way is a bit limited in terms of text formatting... but can't figure out any other approach, as the text should be in login language.


Abhinav_Sharma
Contributor
0 Kudos

Hello Matteo,

There are certain limitations on the tags. You can not freely use that in the FormattedTextView like increasing the font size though you can emphasize the text. Also you can not use nesting of tags also. So it is pretty much rigid.

Coming to your requirement, what I guess is that you want to display the Terms and Conditions page. So why dont you give a URL which points to the write HTML page.

Or you can try with the Z-Table option also, but as I said there is limitations so I doubt if that will cater your requirement.

Regards

Abhinav

matteo_montalto
Contributor
0 Kudos

Hi Abhinav,

you're right, the page is a "Term and Condition" one... I cannot simply point to an HTML page because I need to code a simple logic (which is something like: there are some checkboxes, I have to check that the user has selected at least one the options).


An idea could be to embed an HTML page in my WD view and then adding the checkboxes at the end of the page. But I don't know if this solution is feasible or not... can we embed an HTML page into a view?

Thanks again

Abhinav_Sharma
Contributor
0 Kudos

Hi Matteo,

A quick idea would be to open the link in BSP page and capture the event there and check it in the WD ABAP component. The link can be presented in the FormattedtextView and we can set the flag when user clicks on the link.

BSP will display the Terms and Condition and it will have Checkboxes. On click of checkbox, you can update the temporary table. Read the table in the WD and write the further logic.

You can embed the HTML page also in a view. There are certain UI elements that you can use but not sure what version you have. Refer HTML Integration

You can use the IFrame for embedding the html page but that is not recommended. Also, what you can do is

The other option is if you have portal, you can create an iView based on HTML and then capture the portal event (in your case Checkbox ) in the WD ABAP component. However, there will be a change in the layout but this is also one of the possible approach.

Regards

Abhinav

Message was edited by: Abhinav S

Answers (0)