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

Storing Text Editor data to database table.

Former Member
0 Likes
1,160

Hi,

frnds

I created one text editor and i want to store the data enetered in text

editor into database table my program working fine but it store only first

line into table field but i wants to store the large amount of data

which i enterd in text editor into table field.

my code is given for your review.

DATA T1 LIKE ZMYTAB OCCURS 0 WITH HEADER LINE.

EDITOR-CALL FOR T1 TITLE 'Editor for internal tables'.

*APPEND T1.

LOOP AT T1.

T1-NUM1 = '104'.

T1-NUM = '2005'.

WRITE: / T1-NUM1,T1-NUM,T1-MYTABLE.

INSERT INTO ZMYTAB CLIENT SPECIFIED VALUES T1.

ENDLOOP.

database table field of zmytab is.

num type numc 10,

num1 type int2 5,

mytable type lchr 8100.

plz give me sol'n so that data entered in text editor is store in table field mytable.

regds

Vinod

3 REPLIES 3
Read only

Rashid_Javed
Contributor
0 Likes
648

Hi

Two possible solutions.

1: you can define text object, ID etc and use the sap function modules SAVE_TEXT, READ_TEXT to save these texts just like any other long text in the system for example the sales order or purchase order long texts.

2: You can use a cluster table to store your text. In this case you will be using EXPORT to database/ IMPORT from Database statements instead of insert or update. For this you can check the structure of standard table INDX and if you check its where used list, you will find some examples also on how to use this.

Hope this is helpful.

Regards

RJv
Read only

Former Member
0 Likes
648

Hi Vinod,

The problem is that the key duplication is happening while you are inserting inside the loop. Hence only the first record in the loop is being inserted. You can add another key field in the table and pass a unique serial number to this field each time in the loop (say sy-tabix) and try inserting again.

Read only

Former Member
0 Likes
648

check this :

INSERT - Insert text elements 


Basic form 
INSERT TEXTPOOL prog ...FROM itab ...LANGUAGE lg. 



Parts marked with " ..." are interchangeable 



Addition: 
... STATE state 

Effect 
Assigns the text elements in the internal table itab to the program prog and the language lg and inserts them in the library. The line structure of the table itab is described in the section Text elements. 



Example 
The following program uses the internal table TAB to set the text elements of the program PROGNAME. 



DATA: PROGRAM(8) VALUE 'PROGNAME', 
      TAB TYPE STANDARD TABLE OF TEXTPOOL WITH 
               NON-UNIQUE DEFAULT KEY INITIAL SIZE 50, 
      WA_TAB TYPE TEXTPOOL. 
APPEND TAB. 
WA_TAB-ID = 'T'. WA_TAB-KEY = SPACE. 
WA_TAB-ENTRY = 'Sales'. 
APPEND WA_TAB TO TAB. 
WA_TAB-ID = 'H'. WA_TAB-KEY = '001'. 
WA_TAB-ENTRY = 'Name   Age'. 
APPEND WA_TAB TO TAB. 
WA_TAB-ID = 'S'. WA_TAB-KEY = 'CUST'. 
WA_TAB-ENTRY = '        Customer'. 
APPEND WA_TAB TO TAB. 
WA_TAB-ID = 'R'. WA_TAB-KEY = SPACE. 
WA_TAB-ENTRY = 'Test program'. 
APPEND WA_TAB TO TAB. 

SORT TAB BY ID KEY. 
INSERT TEXTPOOL PROGRAM FROM TAB LANGUAGE SY-LANGU. 



Note 
To ensure compatibility with previous releases, you must insert 8 spaces before the actual text in the ENTRY component when using selection texts ID = 'S') (see example above). 

Before you call INSERT TEXTPOOL you must carry out the necessary authorization and system checks. See Security: Notes. 

This statement completely overwrites existing text elements 



Addition 
... STATE state 


Note 
This addition is for internal use only. 
Changes and further developments, which may be incompatible, are possible at any time, and without notice or warning. 



Effect 
Determines the state in whcih the text elements in itab are stored in the library. State may be either A (for active) or I (for inactive). Inactive text elements are only visible to the user currently editing them, All other users work with the active version. 



In the ABAP Workbench, you can define a set of objects being edited for each user (for example, text elements). These objects are saved as inactive until they are activated. If you omit the STATE addition, the system uses the "inactive" state for these objecs, and t the "active" state for all other objects. 

This set is only ever available for a short time within transactions in the ABAP development environment, which ensures that all other programs that use the INSERT TEXTPOOL command without the STATE addition always insert "active" text elements. 



Notes 
As in the example, the internal table should be sorted by the components ID and KEY to enable faster access to the text elements at runtime. However, this is not obligatory. 


The component LENGTH (see text elements) for the length of a text element does not have to be set explicitly. In this case - as in the example - the actual length of the text element is used. 


The value of LENGTH cannot be smaller than the text to which it applies. If your length specification is too short, it is ignored by INSERT and the actual length is used instead. 
On the other hand, larger values are allowed and can be used to reserve space for texts that may be longer when translated into other languages. 



Exceptions 
Non-Catchable Exceptions 



Cause: state has a value other than A or I. 
Runtime Error: INSERT_REPORT_ILLEGAL_STATE 



Related 
DELETE TEXTPOOL, READ TEXTPOOL

regards

Prabhu