cancel
Showing results for 
Search instead for 
Did you mean: 

How to display a long static text in webdynpro abap

Former Member
0 Kudos

Hi SAP gurus,

I want to display a long static text in my view.

This text contains instructions for a particular scenario.

I want the text to be displayed in one UI element, as it would be static and will not change.

Please let me know the procedure for the same, also if it is done via coding please help me with the code snippet.

Below is the sample text that I want to display.

Regards,
Aakash Awasthi

Accepted Solutions (1)

Accepted Solutions (1)

AnoopMayamkote
Participant
0 Kudos

METHOD READ_SKILLS .

  DATA: IT_SKILL1 TYPE STANDARD TABLE OF TLINE.

  DATA: IT_SKILL_TEMP TYPE TLINE.

  DATA: STR TYPE STRING.

  CALL FUNCTION 'READ_TEXT'

    EXPORTING

      CLIENT                  = SY-MANDT

      ID                      = 'ST'

      LANGUAGE                = SY-LANGU

      NAME                    = 'ZMYS_ABOUTMYSKILLS'

      OBJECT                  = 'TEXT'

    TABLES

      LINES                   = IT_SKILL1

    EXCEPTIONS

      ID                      = 1

      LANGUAGE                = 2

      NAME                    = 3

      NOT_FOUND               = 4

      OBJECT                  = 5

      REFERENCE_CHECK         = 6

      WRONG_ACCESS_TO_ARCHIVE = 7

      OTHERS                  = 8.

  IF SY-SUBRC <> 0.

  ENDIF.

  DATA LO_ND_SKILL_TEXT TYPE REF TO IF_WD_CONTEXT_NODE.

  DATA LO_EL_SKILL_TEXT TYPE REF TO IF_WD_CONTEXT_ELEMENT.

  DATA LT_SKILL_TEXT TYPE  IF_ABOUTMYSKILLS=>ELEMENTS_ABOUT_MY_SKILLS.

  DATA LS_SKILL_TEXT TYPE  IF_ABOUTMYSKILLS=>ELEMENT_ABOUT_MY_SKILLS.

 

  LO_ND_SKILL_TEXT = WD_CONTEXT->GET_CHILD_NODE( NAME = 'ABOUT_MY_SKILLS' ).

  LOOP AT IT_SKILL1 INTO IT_SKILL_TEMP.

    LS_SKILL_TEXT-TEXT = IT_SKILL_TEMP-TDLINE.

    APPEND LS_SKILL_TEXT TO LT_SKILL_TEXT.

  

  ENDLOOP.

LO_ND_SKILL_TEXT->bind_table( new_items = LT_SKILL_TEXT ).

ENDMETHOD.

Former Member
0 Kudos

Thank You Anoop,

As I am new to webdynpro, Can you also tell me what are the nodes to be created and do I need to call this method in wddomodify view. As I need this text in both the view.

Thanks

Aakash

former_member193460
Contributor
0 Kudos


Hi Akash,

     you will need to use a formattedtextview to display your text as required by customer.

As about which method you need to write the code, its completely dependant on your requirement

for eg: if you want it at launch, then it will be the init method.. if you want it after an action (do it in a action handler).

I suggest you can do a basic reading about the hook methods, i assure you it will help you on the long run.

Regards,

Tashi

ramakrishnappa
Active Contributor
0 Kudos

Hi Akash,

As suggested by Tashi, you can achieve your requirement by using FormattedTextView ui element.

Please follow the below steps

  • Create a FormattedTextView ui element in your view
  • You can find "TEXT" property of ui element and  set the text to the element via code or directly you can bind it to OTR text.

     refer link: Steps to Translate OTR Texts in Webdynpro ABAP

  • Fill your text inside OTR text element, so that it can appear in your ui element

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Thank you Rama,

Just a doubt, is there any restriction in OTR for the text length ?? and how do I print bullets for each point ?

Regards,

Aakash

ramakrishnappa
Active Contributor
0 Kudos

Hi Aakash,

Yes, there is restriction for length of OTR text upto 255 chars. Also you cannot have bullets inside the otr text.

To better fit your case, I suggest you to set the text to attribute of formattedTextView ui element as below

<p><strong> Instructions: </strong></p><p>Prior to completing the formall applicants must: </p><p><ul><li>Read the policy through this link</li><li>text2</li><li>Test 3</li></ul><div><br /></div><div><br /></div></p>

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Thanks Rama,

If I get it correct, I need to directly add the HTML text in the text property...or create a OTR for the same, as it is not allowing to write directly, as the space is less.


Regards,

Aakash

ramakrishnappa
Active Contributor
0 Kudos

Yes,

You could create an attribute of type STRING in the context. Bind the same to TEXT property of FormattedTextView element.

Now, inside WDDONIT method you can populate the required INSTRUCTIONS into attribute and update context.

Regards,

Rama

Former Member
0 Kudos

Hi Ram,

GOt it...thanks...but still the problem is with bullets...

still will check ...

what abt the html tags ?

Regards,
Aakash

ramakrishnappa
Active Contributor
0 Kudos

Hi Aakash,

Only one simple bullet work here. unfortunately, not many options available.

All the best

Regards,

Rama

Former Member
0 Kudos

Hi Ram,

I read somewhere that

append 'u2022     Hello' to text.

will work ??

ramakrishnappa
Active Contributor
0 Kudos

I don't think so, it can be just as normal text.

Former Member
0 Kudos

Then will bullet come normally if I give HTML tag in the text ??

ramakrishnappa
Active Contributor
0 Kudos

Yes. Use <ul><li></li></ul> to get list items

Former Member
0 Kudos

Hi Ram,

I used the following code, and it is getting displayed correctly, but as u suggesting I used the html tags, its printing the tag itself, inspite of bullets. Also do let me know, if this is the correct mehtod for displaying the text.

  DATA lo_nd_textedit     TYPE REF TO if_wd_context_node.
  DATA lo_el_textedit     TYPE REF TO if_wd_context_element.
  DATA ls_textedit        TYPE wd_this->element_textedit.
  DATA lv_textedit_header TYPE wd_this->element_textedit-textedit_header.
  DATA: lv_string_ins         TYPE string_table.

* navigate from <CONTEXT> to <TEXTEDIT> via lead selection
  lo_nd_textedit = wd_context->get_child_node( name = wd_this->wdctx_textedit ).

* get element via lead selection
  lo_el_textedit = lo_nd_textedit->get_element( ).

  APPEND ' Prior to completing this form, all applicants must:' to lv_string_ins.
  APPEND '       1. Read the Purchased Leave Policy available through this link.' to lv_string_ins.
  APPEND '       2. Discuss all proposed leave dates with their Manager.' to lv_string_ins.
  APPEND '       3. Contact the Human Resources Department for any inquiry.' to lv_string_ins.
  APPEND '       4. Check accrued leave balance as indicated in the form below.' to lv_string_ins.
  APPEND '       5. Seek appropriate financial advice to see the effect of purchasing addtional' to lv_string_ins.
  APPEND '              leave will have on their superannuation payments and entitlements, and on ' to lv_string_ins.
  APPEND '              salary packaging items' to lv_string_ins.

* set single attribute
  lo_el_textedit->set_attribute(
    name `TEXTEDIT_HEADER`
    value = lv_string_ins ).

Regards,

Aakash

ramakrishnappa
Active Contributor
0 Kudos

Are you using formattedTextView or other element?  If its formattedTextView html format code should work.

Former Member
0 Kudos

I was using text edit, but for formatted text, I need to create many variables of string type as the text is long and it needs to be split into each line...still after doing so..its giving me an error of data type not valid...

Former Member
0 Kudos

It is giving me this exception

Note

The following error occurred in system ODE : WebDynpro Exception: Tag
"<li>" is not permitted

The error occurred on application server INCAS1039_ODE_00 and in work
process. 14

The termination type was: RABAX_STATE

The ABAP call stack was:
Method: RENDER of program
CL_WD_FORMATTED_TEXT==========CP
Method: RENDER_XHTML of program
CL_WDR_TEXT_FORMATTER=========CP
Method:
IF_NW7_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program
/1WDA/CASTANDARD==============CP
Method:
IF_NW7_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program
/1WDA/C8STANDARD==============CP
Method:
IF_NW7_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program
/1WDA/C8STANDARD==============CP
Method:
IF_NW7_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program
/1WDA/C8STANDARD==============CP
Method:
IF_NW7_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program
/1WDA/C7STANDARD==============CP
Method:
IF_NW7_VIEW_ELEMENT_ADAPTER~SET_CONTENT of program
CL_WDR_VIEW_ADAPTER===========CP
Method:
IF_WDR_NW7_DELTA_RENDERER~CALCULATE_DELTA_BLOCKS of program
CL_WDR_VIEW_ADAPTER===========CP
Method: PROCESS_DELTA_BLOCKS of program
CL_WDR_WINDOW_CONTENT_ADAPTER2CP

Answers (0)