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

store raw data in DB table?

Former Member
0 Likes
2,227

Hi all,

is it possible (probably is) to store data from an itab in a DB table raw?

I have an itab ZITAB with linetype ZLT containing some datafields and one table (making it a sort of a 'deep' table).

Now i quickly want to store the data in a Db table, only to retreive it later and put it back into itab ZITAB. I cant define a 'deep' table type in DDIC, right?

so i would like to store the itab line-by-line in a Dtable as raw data, and later retreive this raw data and yank it back into a itab ZITAB.

is this possible? and how to do this best & easiliest ?

thanks alot!

Joris Bots

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,592

Use EXPORT TO and IMPORT FROM DATABASE.

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

</i>Regards

Hi all,

is it possible (probably is) to store data from an itab in a DB table raw?

I have an itab ZITAB with linetype ZLT containing some datafields and one table (making it a sort of a 'deep' table).

Now i quickly want to store the data in a Db table, only to retreive it later and put it back into itab ZITAB. I cant define a 'deep' table type in DDIC, right?

so i would like to store the itab line-by-line in a Dtable as raw data, and later retreive this raw data and yank it back into a itab ZITAB.

is this possible? and how to do this best & easiliest ?

thanks alot!

Joris Bots

8 REPLIES 8
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,593

Use EXPORT TO and IMPORT FROM DATABASE.

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

</i>Regards

Read only

0 Likes
1,592

hi Raymond,

thanks for the very fast reply!

I read in your reply that the dbtab needs to be of the same type as the data you want to store. my data is a 'deep' table (tables in table) and this can not be done in ddic, so how to do this?

maybe a simple example?

thanks again!

Joris

Read only

0 Likes
1,592

Hi Raymond,

i'm not able to figure out how to apply your solution, sorry.

maybe you can shed some extra light?

Thanks!

Joris

Read only

0 Likes
1,592

re Joris,

<b>Data Clusters in the Database</b>

You can import and export very complicated structures via the instruction EXPORT TO DATABASE and read them later via IMPORT FROM DATABASE.

You create the value for the "Key" of the record and an Id to regroup these types of records.

- Id is two-character area for the cluster in the database

- Key is what you want (concatenate in a structure)

The cluster table contains the previous fields, plus standards fields

AEDAT: Date changed

USERA: User name

PGMID: Program name

Two fields for index of the following records and length, then your structure is cut into records of 2886 bytes. IMPORT and EXPORT mae the work to fill these fields.

EXPORT <f1> [FROM <g1>] <f2> [FROM <g2>] ...
       TO DATABASE <dbtab>(<ar>) [CLIENT <cli>] ID <key>.

For example HR use such cluster in "Cluster" tables.

<b>First </b>: Create a Data Cluster. or decide to use SAP INDX look at <a href="http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3c1f358411d1829f0000e829fbfe/content.htm">Example of an INDX-Type Database</a>

<b>Second</b> Save data in cluster: look at <a href="http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3c2c358411d1829f0000e829fbfe/content.htm">Saving Data Objects in INDX-Type Databases</a>

<b>Third</b> Read data stored in database cluster : look at x[url=http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3c46358411d1829f0000e829fbfe/content.htm]Reading Data Objects From INDX-Type Databases[/url]

Read only

0 Likes
1,592

Raymond,

excellent explanation, it solved my problem AND i gained new knowledge! Thanks alot. Full points rewarded

all,

Thanks for the help. it is much appreciated. some points rewarded

regards,

Joris Bots

Read only

Former Member
0 Likes
1,592

Hi,

You can use MOVE command.

Chech the following link:

http://www.sapbrain.com/PROJECTS/TECHNICAL/ABAP%20Source%20codes/Reading%20database%20tables%20-%20l...

Regards,

Bhaskar

Read only

0 Likes
1,592

hi Bhaskar,

Thansks for the reply.

how do i get the RAW data into the DB in the first place? remember: the table i want to store contains also tables amoungst other fields

Thanks for the help

Joris

Read only

Former Member
0 Likes
1,592

Hi,

Look at FMs: table_compress and table_decompress and table: PCL4.

Regards,

Bhaskar