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: 

How to convert Internal Table to Cluster Table ?

Former Member
0 Kudos

How to convert Internal Table to Cluster Table ?

3 REPLIES 3

Former Member
0 Kudos

Humm,

Can you elaborate on why do you want to perform such a thing ?

( Do you want to talk about a DB table ? or relly an internal table ? )

Erwan

raymond_giuseppi
Active Contributor
0 Kudos

Use :

EXPORT itab TO DATABASE dbtab(ar) ID key. 

<i>EXPORT obj1 ... objn TO DATABASE dbtab(ar) ID key.

Additions:

1. ... = f (for each field you want to export)

2. ... FROM f (for each field you want to export)

3. ... CLIENT g before ID key )

4. ... USING form

5. ... FROM wa (as last addition or after dbtab(ar))

In an ABAP Objects context, a more severe syntax check is performed that in other ABAP areas. See Implicit field names not allowed with clusters and Table work areas not allowed.

Effect

Stores a data cluster in database table dbtab. The specified objects obj1 ... objn (fields, structures, or tables) are stored as a single cluster in the database table dbtab.

The specified database table dbtab must have a standard structure.

The database table dbtab is divided into various logically-related sections (ar, two-character name).

You can export a collection of data objects (a data cluster) to a part of the database using a key (field key).

You can import individual data objects from this collection using the IMPORT statement.

Notes

In classes, you must always assign explicit names to the data objects you want to export, that is, you must use either addition 1 or addition 2.

In classes, you must always specify the work area explicitly, that is, addition 5 is obligatory.

The table dbtab that appears after DATABAE must be declared under TABLES (except in addition 5).

You cannot export the header lines of internal tables. If you specify the name of an internal table with header line, the system always exports the body of the table.

You cannot export data, object, or interface references.

The data is stored in the database, and is consequently not actually stored until a database commit occurs (see LUW). Until this point, you can undo all of your changes using a database rollback (see Programming Transactions).

Example

Exporting two fields and an internal table to the database table INDX:

TABLES INDX.

TYPES: BEGIN OF ITAB3_TYPE,

CONT(4),

END OF ITAB3_TYPE.

DATA: INDXKEY LIKE INDX-SRTFD VALUE 'KEYVALUE',

F1(4), F2 TYPE P,

ITAB3 TYPE STANDARD TABLE OF ITAB3_TYPE WITH NON-UNIQUE

DEFAULT KEY INITIAL SIZE 2,

WA_INDX TYPE INDX.

  • Fill the data fields before CLUSTR

  • before the actual export

INDX-AEDAT = SY-DATUM.

INDX-USERA = SY-UNAME.

  • Export der Daten.

EXPORT F1 FROM F1

F2 FROM F2

ITAB3 FROM ITAB3

TO DATABASE INDX(ST) FROM WA_INDX ID INDXKEY.

</i>

Regards

Former Member
0 Kudos

hi

good

An internal table exists only during the runtime.. You cannot 'convert' it into anything.. the data in it can be sent to a Cluster table using the EXPORT statement. PL read the F1/online help for additional info on the EXPORT keyword.

thanks

mrutyun^