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: 

Text Object - urgent

Former Member
0 Kudos

HI,

i have an internal table with text and i want to save this text as text object or standard text so i can later use it in sapscript.

how can i save this internal table at runtime...

i used save_text fm... but i got error like Text Object is not Available.

regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Giri,

here a short example:

REPORT ZGRO_TEST.

*

DATA: BEGIN OF TEXT OCCURS 0.

INCLUDE STRUCTURE TLINE.

DATA: END OF TEXT.

*

DATA: HEADER LIKE THEAD.

*

START-OF-SELECTION.

*

HEADER-TDOBJECT = 'TEXT'.

HEADER-TDNAME = 'Z_MUSTER'.

HEADER-TDID = 'ST'.

HEADER-TDSPRAS = SY-LANGU.

*

TEXT-TDFORMAT = '*'.

TEXT-TDLINE = '1. Zeile'. APPEND TEXT.

TEXT-TDLINE = '2. Zeile'. APPEND TEXT.

TEXT-TDLINE = '3. Zeile'. APPEND TEXT.

*

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

HEADER = HEADER

TABLES

LINES = TEXT.

*

CLEAR TEXT. REFRESH TEXT.

*

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = 'ST'

LANGUAGE = SY-LANGU

NAME = 'Z_MUSTER'

OBJECT = 'TEXT'

TABLES

LINES = TEXT

EXCEPTIONS

NOT_FOUND = 1.

*

IF SY-SUBRC = 0.

LOOP AT TEXT. WRITE: / TEXT-TDLINE. ENDLOOP.

ELSE.

WRITE: / SY-SUBRC.

ENDIF.

*

END-OF-SELECTION.

Hope it helps.

Regards, Dieter

18 REPLIES 18

Former Member
0 Kudos

Hi

Please check the following blog for the same

/people/igor.barbaric/blog/2005/06/06/the-standard-text-editor-oo-abap-cfw-class

Former Member
0 Kudos

HI Giri,

Use SAVE_TEXT to save the data in SAP.

Go to SE75 to create Object and ID.

READ_TEXT to read the text (in case u want to retrieve the data).

Reward points if this helps.

Manish

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You must first create the object/id using transaction SE75

Regards,

Rich Heilman

0 Kudos

here is my code..

xheader-tdid = gv_subject.

loop at gl_textlines into wa_gl.

textlines-tdformat = '*'.

textlines-tdline = wa_gl.

append textlines.

endloop.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

header = xheader

  • INSERT = ' '

SAVEMODE_DIRECT = 'X'

tables

lines = textlines

.

in SE75 if i create object like ztest then how can i assign it with save text?

0 Kudos

Lets say you create an object called ZTEST and an ID under this object called Z001. Here is how you would use this in your code.



<b>xhearer-tdobject = 'ZTEST'.
xheader-tdid = 'Z001'.
xheader-TDNAME = <some_unique_value>.
xheader-spras  = sy-langu.</b>

loop at gl_textlines into wa_gl.
textlines-tdformat = '*'.
textlines-tdline = wa_gl.
append textlines.
endloop.

CALL FUNCTION 'SAVE_TEXT'
EXPORTING
CLIENT = SY-MANDT
header = xheader
* INSERT = ' '
SAVEMODE_DIRECT = 'X'

tables
lines = textlines


Regards,

Rich Heilman

Former Member
0 Kudos

U need to create the Text object first using transaction 'SO10'.

Madhavi

Former Member
0 Kudos

u need to pass ZTEXT to tdname.

Madhavi

0 Kudos

hi madhavi,

my code is:

xheader-tdname = 'ZTEST'.

xheader-tdid = gv_subject.

loop at gl_textlines into wa_gl.

textlines-tdformat = '*'.

textlines-tdline = wa_gl.

append textlines.

endloop.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

header = xheader

  • INSERT = ' '

SAVEMODE_DIRECT = 'X'

tables

lines = textlines

.

i given xheader-tdname = 'ZTEST'.

ZTEST is test object created in SE75 in update mode.

but still i am getting the same error

0 Kudos

Have you created an ID under your ZTEST object, you need to do this, it can be done in SE75. After that is done, you need to specify it in your code.

xheader-tdid = <b>'Z001'</b>.   " gv_subject.

Also make sure to assign the name of the text, this can be almost anything. It usually holds the value of the business object or some concatenate of objectst. For example, sales document header text, the name here would be the specific sales document number.

xheader-tdname = <some_value>.

Regards,

Rich Heilman

0 Kudos

hi rich

i am getting the error like...

TEXT ID Z001 for text object ZTEST does not exist.

my code is:

xheader-tdobject = 'ZTEST'.

xheader-tdid = 'Z001'.

xheader-TDNAME = gv_subject.

xheader-tdspras = sy-langu.

loop at gl_textlines into wa_gl.

textlines-tdformat = '*'.

textlines-tdline = wa_gl.

append textlines.

endloop.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

header = xheader

  • INSERT = ' '

SAVEMODE_DIRECT = 'X'

tables

lines = textlines

.

0 Kudos

Hi Giri,

the Problem is TDID Z001 use ST ore create Z001.

Regards, Dieter

0 Kudos

HI,

i created Ztest1 in so10 with text id ST. and ZTEST in SE75 with text id Z001.

for Ztest1 it says text object ztest1 does not exist and for ztest i cant retrieve the data.. data is not saving.

code for SO10:

xheader-tdobject = 'ZTEST1'.

xheader-tdid = 'ST'.

xheader-TDNAME = 'Z_TEST'.

xheader-tdspras = sy-langu.

loop at gl_textlines into wa_gl.

textlines-tdformat = '*'.

textlines-tdline = wa_gl.

append textlines.

endloop.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

header = xheader

  • INSERT = ' '

SAVEMODE_DIRECT = 'X'

tables

lines = textlines

.

code for SE75:

xheader-tdobject = 'ZTEST'.

xheader-tdid = 'Z001'.

xheader-TDNAME = 'Z_TEST'.

xheader-tdspras = sy-langu.

loop at gl_textlines into wa_gl.

textlines-tdformat = '*'.

textlines-tdline = wa_gl.

append textlines.

endloop.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

header = xheader

  • INSERT = ' '

SAVEMODE_DIRECT = 'X'

tables

lines = textlines

.

i am not getting where is the mistake.

0 Kudos

hi rich,

this code shows no error... but it not saving the text..

xheader-tdobject = 'ZTEST'.

xheader-tdid = 'Z001'.

xheader-TDNAME = 'Z_TEST'.

xheader-tdspras = sy-langu.

loop at gl_textlines into wa_gl.

textlines-tdformat = '*'.

textlines-tdline = wa_gl.

append textlines.

endloop.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

header = xheader

  • INSERT = ' '

SAVEMODE_DIRECT = 'X'

tables

lines = textlines

.

in sapscript i given..

/: INCLUDE ZTEST OBJECT TEXT ID Z001

then it not retrieving the text.. in debugging i can see textlines has text.

help to figure it out

Regards

giri

0 Kudos
/: INCLUDE<b> Z_TEST</b> OBJECT <b>ZTEST</b> ID Z001

It would need to be like this, right?

Regards,

Rich Heilman

0 Kudos

hi guys,

thanx so much..

i got both in se75 and so10...

thanx very much

points rewarded to all helpful answers

Giri

Former Member
0 Kudos

Hi Giri,

here a short example:

REPORT ZGRO_TEST.

*

DATA: BEGIN OF TEXT OCCURS 0.

INCLUDE STRUCTURE TLINE.

DATA: END OF TEXT.

*

DATA: HEADER LIKE THEAD.

*

START-OF-SELECTION.

*

HEADER-TDOBJECT = 'TEXT'.

HEADER-TDNAME = 'Z_MUSTER'.

HEADER-TDID = 'ST'.

HEADER-TDSPRAS = SY-LANGU.

*

TEXT-TDFORMAT = '*'.

TEXT-TDLINE = '1. Zeile'. APPEND TEXT.

TEXT-TDLINE = '2. Zeile'. APPEND TEXT.

TEXT-TDLINE = '3. Zeile'. APPEND TEXT.

*

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

HEADER = HEADER

TABLES

LINES = TEXT.

*

CLEAR TEXT. REFRESH TEXT.

*

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = 'ST'

LANGUAGE = SY-LANGU

NAME = 'Z_MUSTER'

OBJECT = 'TEXT'

TABLES

LINES = TEXT

EXCEPTIONS

NOT_FOUND = 1.

*

IF SY-SUBRC = 0.

LOOP AT TEXT. WRITE: / TEXT-TDLINE. ENDLOOP.

ELSE.

WRITE: / SY-SUBRC.

ENDIF.

*

END-OF-SELECTION.

Hope it helps.

Regards, Dieter

Former Member
0 Kudos

Hi Giri,

go and create the object using SO10 transaction.

Madhavi

Former Member
0 Kudos

is it anyway that u write ur code in one server and test it another server??

Madhavi