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: 

Storing text

Former Member
0 Kudos

Hi Everybody

m back here

I want to store texts of about 500 characters

I have created a text box using controls along with one key field on the screen

Now i want that text to be saved and then again display when user enter the key

Can u plz tell me how to store the texts in the table

coz these tests doesnt store in the tables

Thanks in advance

28 REPLIES 28

sbhutani1
Contributor
0 Kudos

Hi rashmi,

You can use the data type LCHR for storing your long text and then you can also fetch this data into your text box. if the length is not sufficient then you can use more than one LCHR field and the while displaying just concatenate those fields and then display

Regards

Sumit Bhutani

Former Member
0 Kudos

Hi Sumit

thnks for ur quick response

but its not good idea to display a single line of length 500 chars or more

thatz y we have created a text box using control

and now i want to store and then again access the text

I have found that these texts doesnt store in the z-tables

so any idea about where does this text store and how sap stores this text and then again access the same

Thanks

Former Member
0 Kudos

Hi guyz

m waiting for ur replies

0 Kudos

To store long text, you could use the tables STXH, STXL. Don't write directly in the tables, use the functions :

READ_TEXT

DELETE_TEXT

SAVE_TEXT

....

(function group LSTX)

Rgd

Frédéric

0 Kudos

Thanks Frederic for ur reply

i wann give points but not able to see those stars so will definately give latter

anyway.. i tries fg lstx.. its saying this fg doesnt exist

THanks

0 Kudos

Function group is STXD (I read to fast)

Fred

0 Kudos

Hi Frederic again

I am new to this

I have gone through the FM documentation .

In that we can transfer the text to the tables parameter

but can u plz tell me how to transfer this text to std table or how to link fm save_text with std table

Secondly i have gone thorugh tables stxh but in that therz no field exceeding length of 100

ya therz one field of type lraw in table stxd

so do we need to use the same for this purpose??

THanks a lot

0 Kudos

Rashmi,

There are three important paramters in reading and saving the texts like this.

TDOBJECT, TDNAME, TDID.

So, if you are not dealing with any of the texts of the documents like PO / SO, you can use SO10 transaction to do this.

TDOBJECT = TEXT

TDNAME = Whatever name you want

TDID = ST

Now, you can pass these values to the READ_TEXT and SAVE_TEXT funcitons to read and save texts.

Regards,

Ravi

Note : Please mark the helpful answers

0 Kudos

if you are going to use FMs from function group STXD the text will be stored in the standard table where long texts for documents and standard texts are stored.

if you want to store them in custom table (Z)

you can create a ztable with field type string (if you are on WAS) or LCHR to hold large texts.

as far the formatting when you read the text from the textedit control use method GET_TEXTSTREAM to get the text from the control into a string . (all line breaks, tabx will be retained within the string)

this string you can then directly store it in database and when you want to read this text from database and set it in the text editor you can use method SET_TEXTSTREAM for the same.

Regards

Raja

0 Kudos

THanks Ravi

but can u plz bit elaborate the point

I have gone thru the transaction SO10.. therz option textname but as such no option tdobject

where do we need to mention all these tdobject, tdname and tdid and how do we relate this with fm save_text??

and ya Raja .. we need to store all these texts in std tables but we are accessing the key from z table

Thanks a lot

0 Kudos

Rashmi,

These are the values that you enter on SO10 transaction before you can see the text - First screen of SO10.

In case of a ZTABLE, all I have store is the name of the TEXT and I can retrieve that by passing the name to READ_TEXT. So, I don't have to worry about storing the entire text in the ZTABLE myself.

And the TDOBJECT / Object field on SO10 is what he is mentioning about, so in this case we are hard coding it to TEXT. If you see the texts of the PO / SO, it will have different values like , EKKO (For header), EKPO (For item) etc etc. See the table TTXID (Not sure of the exact name).

Regards,

Ravi

Note : Please mark all the helpful answers

Message was edited by: Ravikumar Allampallam

0 Kudos

Hi Ravi

le me explain my requirement again

What we want to do is

we have one z table and screen for these table fields

Now we want user to enter texts say description of length more than 300 chars

For this we can have one lchar type field in z table but we don want to display a single line on the screen

and thatz why instead of creating field of type lchar in the z table , we have created textcontrol using controls on the screen

Now i want to store and again access this text depending on the table key of ztable in the control on the same screen..

so what should be the approach

1. using FM save_text and read_text

when m using fm save_text,

its giving error message ' Text ID TID for text objt DMC does not exist"

Plz reply soon its argunt

Thanks

0 Kudos

Rashmi,

Yes SAVE_TEXT / READ_TEXT is the way to go with the key in the ZTABLe. While using SAVE_TEXT passing ST for TDID and TEXT for TDOBJECT and with whatever key as the TDNAME.

Now, you should be able to retrieve the same with the same values using READ_TEXT function.

Regards,

Ravi

0 Kudos

but where do we need to mention all these tdid, tdobjt, tdname

threz no such import parameter in fm save_text

thanks

0 Kudos

Look under the HEADER Parameters, I am not sure of the exact name. There will be a structure parameter under which all these will be there.

Regards,

Ravi

Note : Please mark all the helpful answers

0 Kudos

Check structure THEAD and pass it to Header of save_text .

Regards

Siddharth

0 Kudos

Thanks Siddharth, Ravi

I am now able to save the text as its not giving any error message

but now when i am trying to read it using read_text fm

its giving dump

The procedure is same for both read and save_text fm or its different??

I have given same parameters as :

CLIENT = SY-MANDT

ID = 'ST'

LANGUAGE = 'EN'

NAME = 'TKEY'

OBJECT = 'TEXT'

in the fm read_text

but its giving dump

0 Kudos

m waiting for ur replies

0 Kudos

The procedure is exactly same. What is the dump reason, can you post it here.

Regards,

Ravi

0 Kudos

This is my code

DATA: g_0011_cntl_body type ref to cl_gui_textedit,

g_0011_custom_container_body type ref to cl_gui_custom_container.

DATA: BEGIN OF HEAD OCCURS 0.

INCLUDE STRUCTURE THEAD.

DATA: END OF HEAD.

DATA: BEGIN OF I_LINE OCCURS 0.

INCLUDE STRUCTURE TLINE.

DATA: END OF I_LINE.

MOVE 'TKEY' TO HEAD-TDNAME.

MOVE 'EN' TO HEAD-TDSPRAS.

MOVE 'ST' TO HEAD-TDID.

MOVE 'TEXT' TO HEAD-TDOBJECT.

APPEND HEAD.

call screen 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'MAIN100'.

  • SET TITLEBAR 'xxx'.

if g_0011_cntl_body is initial.

  • create control container

create object g_0011_custom_container_body

exporting

container_name = 'GRID1'

exceptions

others = 1.

create object g_0011_cntl_body

exporting

parent = g_0011_custom_container_body

wordwrap_mode =

cl_gui_textedit=>wordwrap_at_windowborder

wordwrap_to_linebreak_mode = cl_gui_textedit=>false

exceptions

others = 1.

call method g_0011_cntl_body->set_toolbar_mode

exporting

toolbar_mode = cl_gui_textedit=>false.

endif.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'SAVE'.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

HEADER = HEAD

  • INSERT = ' '

  • SAVEMODE_DIRECT = ' '

  • OWNER_SPECIFIED = ' '

  • LOCAL_CAT = ' '

  • IMPORTING

  • FUNCTION =

  • NEWHEADER =

TABLES

LINES = I_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.

*ENDIF.

WHEN 'DISPLAY'.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = 'ST'

LANGUAGE = 'EN'

NAME = 'TKEY'

OBJECT = 'TEXT'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

LINES = I_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.

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

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

ENDIF.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

now m getting dump

0 Kudos

Try to use variables for the parameters, assign values and pass the variables.

Also, give us the details of the dump.

Regards,

Ravi

Note : Please mark the helpful answers

Former Member
0 Kudos

and ya one more thing

in the documentation of fm save_text, therz a line like

"The function module writes a text module to the text file or text memory, depending on the specific <b>text object</b>"

so whatz this text object and whr do we need to mention this

Thanks once again

Former Member
0 Kudos

its giving error at call fucntion read_text

FM read_text is called incorrectly

If anybody having code for the similar requirement (for passing and retrieving texts on scrren using table key)or if you know demo program plz le me know.. its urgent

THanks

0 Kudos

Rashmi,

What you need to do is to declare variable of the same type that are there in the function. Look at the parameters and declare your variables exactly like that and then assign the values and pass the variables.

That should work.

Regards,

Ravi

Note : Please mark all the helpful answers

0 Kudos

hi rashmi,

pass the structure <b>thead</b> to .<b>Header</b> in the FM READ_TEXT also and check.

hope this helps,

priya

0 Kudos

hi again

its giving error

"FM read_text was called with the parameter header

this parameter is not defined"

I have defined this parameter

0 Kudos

Rashmi,

Can you post the code here?

Regards,

Ravi

0 Kudos

ya.. this is the program

DATA: g_0011_cntl_body type ref to cl_gui_textedit,

g_0011_custom_container_body type ref to cl_gui_custom_container.

DATA: BEGIN OF HEAD OCCURS 0.

INCLUDE STRUCTURE THEAD.

DATA: END OF HEAD.

DATA: BEGIN OF I_LINE OCCURS 0.

INCLUDE STRUCTURE TLINE.

DATA: END OF I_LINE.

DATA: BEGIN OF HEAD1 OCCURS 0.

INCLUDE STRUCTURE THEAD.

DATA: END OF HEAD1.

DATA: KEY LIKE THEAD-TDNAME,

LANG LIKE THEAD-TDSPRAS,

ID LIKE THEAD-TDID,

OBJ_NAME LIKE THEAD-TDOBJECT.

KEY = 'TKEY'.

LANG = 'EN'.

ID = 'ST'.

OBJ_NAME = 'TEXT'.

MOVE 'TKEY' TO HEAD-TDNAME.

MOVE 'EN' TO HEAD-TDSPRAS.

MOVE 'ST' TO HEAD-TDID.

MOVE 'TEXT' TO HEAD-TDOBJECT.

APPEND HEAD.

call screen 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'MAIN100'.

  • SET TITLEBAR 'xxx'.

if g_0011_cntl_body is initial.

  • create control container

create object g_0011_custom_container_body

exporting

container_name = 'GRID1'

exceptions

others = 1.

create object g_0011_cntl_body

exporting

parent = g_0011_custom_container_body

wordwrap_mode =

cl_gui_textedit=>wordwrap_at_windowborder

wordwrap_to_linebreak_mode = cl_gui_textedit=>false

exceptions

others = 1.

call method g_0011_cntl_body->set_toolbar_mode

exporting

toolbar_mode = cl_gui_textedit=>false.

endif.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'SAVE'.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

HEADER = HEAD

  • INSERT = ' '

  • SAVEMODE_DIRECT = ' '

  • OWNER_SPECIFIED = ' '

  • LOCAL_CAT = ' '

  • IMPORTING

  • FUNCTION =

  • NEWHEADER =

TABLES

LINES = I_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.

*ENDIF.

WHEN 'DISPLAY'.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = ID

LANGUAGE = LANG

NAME = KEY

OBJECT = OBJ_NAME

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

HEADER = HEAD1

TABLES

LINES = I_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.

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

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

ENDIF.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

but its giving dump

the error is FM read_text is called incorrectly