现在的位置: 首页 > 综合 > 正文

TextEdit UI for Long Text Word-break 英文字符串自动换行处理

2013年09月01日 ⁄ 综合 ⁄ 共 1940字 ⁄ 字号 评论关闭

http://scn.sap.com/message/8424824

 

7 Replies
Latest reply: Nov 20, 2009 6:20 AM by amit saini
RSS

TextEdit UI for Long Text

This question has been
Answered.

Adrian Lim
Not Active Contributor

Currently Being Moderated

Hi,

 

I have binded a TextEdit to a String Table. The purpose is to be able to save this texts as a Standard Text in the system. Noticed that it can only be appended as a new line in the String Table when user hits enter while entering the text.

 

Problem is, if the user keeps on entering texts without hitting enter, and there are >255 chars, the remainder texts will be truncated.

 

Is there anyway we can obtain the full text that are >255 chars entered by user, if he does not hit enter?

 

 

Correct Answer by amit saini  on Nov 20, 2009
6:20 AM

hi ,

to save the text use the FMs SWA_STRING_SPLIT ( String needs to be split into multiple lines of characters )

and SAVE_TEXT

 

I guess the following piece of code wud help

 

 DATA lo_node        TYPE REF TO if_wd_context_node.
  DATA lo_element     TYPE REF TO if_wd_context_element.
  DATA ls_text        TYPE if_main=>element_text_editor.
  DATA lv_string      TYPE string.
  DATA lt_str_comp    TYPE TABLE OF swastrtab.
  DATA ls_str_comp    TYPE swastrtab.
  DATA lt_lines       TYPE TABLE OF tline.
  DATA ls_tline       TYPE tline.
  DATA ls_header      TYPE thead.
  lo_node = wd_context->get_child_node( name = 'TEXT_EDITOR' ).
  lo_element = lo_node->get_element( ).
  lo_element->get_static_attributes( IMPORTING static_attributes = ls_text ).
  LOOP AT ls_text-text INTO lv_string.
* String needs to be split into multiple lines of characters
* of length 132 each to be passed to SAVE_TEXT FM.
    CALL FUNCTION 'SWA_STRING_SPLIT'
      EXPORTING
        input_string                 = lv_string
        max_component_length         = 132
      TABLES
        string_components            = lt_str_comp
      EXCEPTIONS
        max_component_length_invalid = 1
        OTHERS                       = 2.
    LOOP AT lt_str_comp INTO ls_str_comp.
      IF sy-tabix EQ 1.
        ls_tline-tdformat = '*'.
      ELSE.
        CLEAR ls_tline-tdformat.
      ENDIF.
      ls_tline-tdline   = ls_str_comp-str.
      APPEND ls_tline TO lt_lines.
      CLEAR ls_tline.
    ENDLOOP.
    CLEAR lt_str_comp[].
  ENDLOOP.

 

抱歉!评论已关闭.