Application Development and Automation 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: 
Read only

How to Call Text Objects in Report Program

Former Member
0 Likes
1,588

Friends,

I have to call a text object ( with text name & text-id) in my report program to display a text.

How can I achieve this? Please suggest with an example.

Regards,

Alok.

5 REPLIES 5
Read only

former_member188829
Active Contributor
0 Likes
1,044

Hi,

Goto So10 Tcode and enter Your Standard Text Name and press on Display Button.

in menu GOTO--->HEADER.

Here You Will Findout Text Id and Text Name

Check this Example.

DATA:ID LIKE THEAD-TDID VALUE 'ST'.

DATA:LANGUAGE LIKE THEAD-TDSPRAS VALUE 'E'.

DATA:NAME LIKE THEAD-TDNAME VALUE 'ZSTANDARD'.

DATA:OBJECT LIKE THEAD-TDOBJECT VALUE 'TEXT'.

DATA:BEGIN OF ITAB OCCURS 0.

INCLUDE STRUCTURE TLINE.

DATA:END OF ITAB.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = ID

LANGUAGE = SY-LANGU

NAME = 'ZSTANDARD'

OBJECT = 'TEXT'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = ITAB

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.

LOOP AT ITAB.

WRITE:/ ITAB-TDLINE.

ENDLOOP.

Read only

Former Member
0 Likes
1,044

alok,

use FM READ_TEXT

give text name and text id as input,

DATA: custom_container TYPE REF TO cl_gui_custom_container,

editor TYPE REF TO cl_gui_textedit,

repid LIKE sy-repid.

CONSTANTS: line_length TYPE i VALUE 256.

DATA: gw_thead LIKE thead.

DATA: BEGIN OF itab OCCURS 0,

edit(50),

END OF itab.

DATA: wa LIKE LINE OF itab.

DATA: BEGIN OF itab1 OCCURS 0,

edit(100),

END OF itab1.

*data: wa like line of itab.

DATA: wa_thead TYPE TABLE OF thead WITH HEADER LINE.

DATA: loc_nam TYPE thead-tdname VALUE '001'.

DATA: int_line TYPE TABLE OF tline WITH HEADER LINE.

data: wg_flag type i.

*do 10 times.

*wa-edit = 'hi'.

*append wa to itab.

*clear wa.

*enddo.

CALL SCREEN 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'MENU'.

  • SET TITLEBAR 'xxx'.

IF editor IS INITIAL.

  • repid = sy-repid.

CREATE OBJECT custom_container

EXPORTING

container_name = 'CUSTOM_CONTROL'

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

CREATE OBJECT editor

EXPORTING

parent = custom_container

wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position

wordwrap_position = line_length

wordwrap_to_linebreak_mode = cl_gui_textedit=>true.

ENDIF. "editor is initial

CALL FUNCTION 'READ_TEXT'

EXPORTING

id = 'ST'

language = sy-langu

name = loc_nam

object = 'YTEST'

TABLES

lines = int_line

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.

wg_flag = 1.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

refresh itab.

LOOP AT int_line.

wa-edit = int_line-tdline.

APPEND wa TO itab.

ENDLOOP.

CALL METHOD cl_gui_cfw=>flush.

CALL METHOD editor->set_text_as_r3table

EXPORTING

table = itab[].

  • 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.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE user_command_0100 INPUT.

CALL METHOD editor->get_text_as_r3table

IMPORTING

table = itab[].

  • 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.

**

**

**break-point.

*

refresh int_line.

LOOP AT itab INTO wa.

int_line-tdline = wa-edit.

APPEND int_line.

clear int_line.

ENDLOOP.

gw_thead-tdname = loc_nam.

gw_thead-tdid = 'ST'.

gw_thead-tdspras = sy-langu.

gw_thead-tdobject = 'YTEST'.

CASE sy-ucomm.

WHEN 'EXIT'.

LEAVE PROGRAM.

when 'SAVE'.

if wg_flag = 0.

CALL FUNCTION 'DELETE_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

id = 'ST'

language = sy-langu

name = loc_nam

object = 'YTEST'

  • SAVEMODE_DIRECT = ' '

  • TEXTMEMORY_ONLY = ' '

  • LOCAL_CAT = ' '

  • EXCEPTIONS

  • NOT_FOUND = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

endif.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

header = gw_thead

TABLES

lines = int_line

EXCEPTIONS

id = 1

language = 2

name = 3

object = 4

OTHERS = 5.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Read only

Former Member
0 Likes
1,044

Hi,

You can use the function module READ_TEXT to achieve this.

You have to specify the name,object and id one in that which you already have. So it will work.

If you get any problem please post it.

Hope this helps. Pls reward points if useful.

Regards,

Renjith Michael.

Read only

Former Member
0 Likes
1,044

hi

good

Check this standard program

SAPTEXTEDIT_DEMO_3

also u can check DWDM for standared program example.

go through this link too

http://help.sap.com/saphelp_nw04/helpdata/en/d6/0db841494511d182b70000e829fbfe/content.htm

thanks

mrutyun^

Read only

Former Member
0 Likes
1,044

Hi,

I think you need to display text w/o actually hardcoding it into your program.

Goto--> Text elements --> text symbols.

There you give the text symbol(eg T01) and write the text.

You can access the texts as: Text-T01.

Deserve reward.

regards