Skip to Content
author's profile photo Former Member
Former Member

Displaying Text in Text editor

Hi all,

Curenlty I am using SET_TEXT_AS_STREAM method of class CL_GUI_TEXTEDIT to display text. Since my table contains voth the format and the text, the format is also getting displayed as a text in the editor.

Eg. My table contains value as

TDFORMT TDLINE

  • Vijay

My output in the Text editor is

  • Vijay

but i need only 'Vijay' to be displayed not the *.

Regards,

Vijayakumar

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 06:39 AM

    Hello Vijay,

    Use the function module CONVERT_ITF_TO_STREAM_TEXT to convert the text from the ITF format into the Stream format and then use the returned internal table in the SET_TEXT_AS_STREAM method.

    Hope this helps.

    Manoj

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 10, 2007 at 03:48 PM

    Hello Vijayakumar

    For filling the textedit control you can use coding like this:

        CREATE OBJECT oref_cust_cont_0250
          EXPORTING
    *        PARENT                      =
            container_name              = 'CUST_CONT_0250'
    *        STYLE                       =
    *        LIFETIME                    = lifetime_default
    *        REPID                       =
    *        DYNNR                       =
    *        NO_AUTODEF_PROGID_DYNNR     =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc <> 0.
    *     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    
    
        CREATE OBJECT oref_textedit
          EXPORTING
    *        MAX_NUMBER_CHARS       =
    *        STYLE                  = 0
    *        WORDWRAP_MODE          = WORDWRAP_AT_WINDOWBORDER
    *        WORDWRAP_POSITION      = -1
            wordwrap_to_linebreak_mode = cl_gui_textedit=>true
    *        FILEDROP_MODE          = DROPFILE_EVENT_OFF
            parent                 = oref_cust_cont_0250
    *        LIFETIME               =
    *        NAME                   =
          EXCEPTIONS
            error_cntl_create      = 1
            error_cntl_init        = 2
            error_cntl_link        = 3
            error_dp_create        = 4
            gui_type_not_supported = 5
            OTHERS                 = 6.
        IF sy-subrc <> 0.
    *     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    
    
        CLEAR: gs_thead.
        gs_thead-tdobject = <your text object>.
        gs_thead-tdname   = <your name>.
        gs_thead-tdspras  = syst-langu.
        gs_thead-tdid     = <your text id>.
    
        CALL FUNCTION 'READ_TEXT'
          EXPORTING
    *       CLIENT                        = SY-MANDT
            id                            = gs_thead-tdid
            language                      = gs_thead-tdspras
            name                          = gs_thead-tdname
            object                        = gs_thead-tdobject
    *       ARCHIVE_HANDLE                = 0
    *       LOCAL_CAT                     = ' '
    *     IMPORTING
    *       HEADER                        =
          TABLES
            lines                         = gt_lines
          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.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    
    
        CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT'
          EXPORTING
            language    = sy-langu
          TABLES
            itf_text    = gt_lines
            text_stream = gt_stream.
    
    
    
        CALL METHOD oref_textedit->set_text_as_stream
          EXPORTING
            text            = gt_stream
          EXCEPTIONS
            error_dp        = 1
            error_dp_create = 2
            OTHERS          = 3.
        IF sy-subrc <> 0.
    *     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.

    For retrieving the data from the textedit control is could look like this:

        CALL METHOD oref_textedit->get_text_as_stream
    *      EXPORTING
    *        ONLY_WHEN_MODIFIED     = FALSE
          IMPORTING
            TEXT                   = gt_stream
            IS_MODIFIED            = ld_is_modified
          EXCEPTIONS
            ERROR_DP               = 1
            ERROR_CNTL_CALL_METHOD = 2
            others                 = 3.
        IF sy-subrc <> 0.
    *     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    
    
        IF ( ld_is_modified > 0 ).
          CALL FUNCTION 'CONVERT_STREAM_TO_ITF_TEXT'
    *       EXPORTING
    *         LANGUAGE          = SY-LANGU
            TABLES
              text_stream       = gt_stream
              itf_text          = gt_lines.
    
          CALL FUNCTION 'SAVE_TEXT'
            EXPORTING
    *         CLIENT                = SY-MANDT
              header                = gs_thead
    *         INSERT                = ' '
    *         SAVEMODE_DIRECT       = ' '
    *         OWNER_SPECIFIED       = ' '
    *         LOCAL_CAT             = ' '
    *       IMPORTING
    *         FUNCTION              =
    *         NEWHEADER             =
            tables
              lines                 = gt_lines
            EXCEPTIONS
              ID                    = 1
              LANGUAGE              = 2
              NAME                  = 3
              OBJECT                = 4
              OTHERS                = 5.
          IF sy-subrc <> 0.
     MESSAGE ID SY-MSGID TYPE 'I' NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.

    The text formatting is preserved.

    Regards

    Uwe

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.