Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

long text display on screen using dialog programmin

Former Member
0 Kudos

Hi Experts,

How long text long text display on screen using dialog programmin.

Thanks

4 REPLIES 4

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You can read the text using READ_TEXT and put in a text editor in your screen. Here is an example, this is implemented in a docking container in a selection screen, but it would be the same if you were to attach it to a custom container in your dynpro. Simply create these objects in the PBO of your screen.

Cut and paste this program in to your system and run it.



report zrich_0001
       no standard page heading.

* Variable for "Text Container" Abap Object
data: editor type ref to cl_gui_textedit,
      docking type ref to cl_gui_docking_container.

data: wa_text like tline-tdline.

data: begin of lines occurs 0.
        include structure tline.
data: end of lines.

data: textlines like tline-tdline occurs 0.
data: syrepid type sy-repid.

parameters: p_check type c.

at selection-screen output.

  syrepid = sy-repid.

  check docking is initial.

  create object docking
              exporting repid     = syrepid
                        dynnr     = sy-dynnr
                        side      = docking->dock_at_left
                        extension = 500.

  create object editor
      exporting parent = docking.

  perform set_text.

start-of-selection.

  perform write_text.

************************************************************************
*       FORM write_text                                                *
************************************************************************
form write_text.

  data: modified type i.

* Retrieve text from container
  call method editor->get_text_as_r3table
     exporting
           only_when_modified = space
     importing
           table              = textlines
           is_modified        = modified
     exceptions
           others             = 1.

* Write out contents of text editor
  leave to list-processing.
  loop at textlines into wa_text.
    write:/ wa_text.
  endloop.

endform.

************************************************************************
*      FORM  SET_TEXT
************************************************************************
form set_text.

* Here use the READ_TEXT function module to get the text for your
* long text.  In this example, I'm filling the text manually

  lines-tdline = 'Here we are filling the text editor - Line 1'.
  append lines.

  lines-tdline = 'Here we are filling the text editor - Line 2'.
  append lines.

  loop at lines .
    shift lines left deleting leading space.
    append lines to textlines .
  endloop.

* Fill container with text lines
  call method editor->set_text_as_r3table
     exporting
           table              = textlines
           exceptions
           others             = 1.

endform.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi,

use FM read_text Fm to read long text

check table stxh,stxl.

use read_text function module to read text lines

edit_text to edit existing text

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = 'ST'

LANGUAGE = SY-LANGU

NAME = THEAD-TDNAME

OBJECT = 'TEXT'

TABLES

LINES = TLINE_TAB

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 7

OTHERS = 8.

Regards

amole

0 Kudos

You can use <b>RKD_WORD_WRAP</b> after <b>READ_TEXT</b>...That way you can have multiple lines and maybe use a Table Control -;)

Greetings,

Blag.

Former Member
0 Kudos

Hi asha,

first create a conntainer on the screen in which you want to display the long text.

write the following code in PBO.

IN TOP INCLLIUDE DECLARE THIS

DATA : TEXTEDIT_CUSTOM_CONTAINER1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

DATA : G_CONTAINER2 TYPE SCRFNAME VALUE 'TEXT_EDITOR2' ,

TEXT1111 TYPE REF TO CL_GUI_TEXTEDIT ,

G_CUSTOM_CONTAINER2 TYPE REF TO CL_GUI_CUSTOM_CONTAINER .

DATA : TEXTEDIT_CUSTOM_CONTAINER1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

DATA : editor1 type ref to cl_gui_textedit.

CONSTANTS : line_length1 type i value 128.

TYPES : BEGIN OF my_table_struct_definition1,

LINE1(line_length) TYPE C,

END OF my_table_struct_definition1,

MY_TABLE1 TYPE my_table_struct_definition1 OCCURS 0.

DATA : MYTABLE1 TYPE MY_TABLE1.

Class CL_GUI_CONTROL definition LOAD.

Class CL_GUI_OBJECT definition load.

DATA : V_REPIDD LIKE SY-REPID.

V_REPIDD = SY-REPID.

if editor1 is initial.

CREATE OBJECT TEXTEDIT_CUSTOM_CONTAINER1

EXPORTING

CONTAINER_NAME = 'TEXTEDITOR2'

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5.

IF SY-SUBRC NE 0.

  • add your handling

ENDIF.

  • create calls constructor, which initializes, creats and links

  • a TextEdit Control

CREATE OBJECT EDITOR1

EXPORTING

PARENT = TEXTEDIT_CUSTOM_CONTAINER1

WORDWRAP_MODE = CL_GUI_TEXTEDIT=>WORDWRAP_AT_FIXED_POSITION

WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>FALSE

EXCEPTIONS

OTHERS = 1.

refresh mytable1.

endif.

IF SY-SUBRC NE 0.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

TITEL = V_REPIDD "--> program name

TXT2 = SPACE

TXT1 = 'Error in flush'.

ENDIF.

IF YOU ARE RETRIEVING THE DATA FROM ZTABLE USE THIS CODE IMMEDIATELY AFTER THE ABOVE CODE .

ELSE YOU CAN USE READ_TEXT IN YOU HAVE OBJECT CREATED FOR LONG TEXT.

DATA : MYTABLE2 LIKE mytable WITH header line.

CLEAR MYTABLE2.

REFRESH MYTABLE2.

LOOP AT ITAB99.

*INSERT ITAB99-ZTEXT1 INTO MYTABLE.

MYTABLE2-LINE = ITAB99-ZTEXT1..

APPEND MYTABLE2.

ENDLOOP.

MYTABLE1[] = MYTABLE2[].

call method editor1->set_text_as_r3table

exporting table = mytable1.

let me know if you are not successful with achieving the results

Thanks

VENKI