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

passing internal table to global memory

Former Member
0 Likes
2,476

hi,

How to pass internal table to global memory and how to retrieve internal table from global memory.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,406

You can use the EXPORT and IMPORT Commands.


* How to pass 
export I_TAB1 to memory id 'ZTAB1'.
* how to retrieve 
import I_TAB1 from memory id 'ZTAB1'.

Regards

Kathirvel

5 REPLIES 5
Read only

Former Member
0 Likes
1,407

You can use the EXPORT and IMPORT Commands.


* How to pass 
export I_TAB1 to memory id 'ZTAB1'.
* how to retrieve 
import I_TAB1 from memory id 'ZTAB1'.

Regards

Kathirvel

Read only

0 Likes
1,406

For this u have to have the declare the internal table with the same name and structure at both the places from where ur EXPORTING and where ur IMPORTING the internal table.

use the commands

EXPORT <itab> TO MEMORY ID <id>.

IMPORT <itab> FROM MEMORY ID <id>.

Thanks

Elan

Read only

Former Member
0 Likes
1,406

Hi Peter ,

You can use the EXPORT to memory and IMPORT.. command.

Here is the standrard help given for the same

TYPES: BEGIN OF OBJ_LINE, 
         CLUSTERNAME(30), 
         PROGRAMNAME(10), 
       END OF OBJ_LINE. 

DATA: OBJ_TAB TYPE STANDARD TABLE OF OBJ_LINE, 

      OBJ_WA  TYPE OBJ_LINE. 

TYPES: BEGIN OF B_LINE, 
         FIELD_1    TYPE I, 
         FIELD_2(1) TYPE N, 
       END OF B_LINE. 

DATA: B_PROG TYPE STANDARD TABLE OF B_LINE. 

DATA: A(10), 
      C_PROG LIKE SYST. 

MOVE:  'A'      TO OBJ_WA-CLUSTERNAME. 
APPEND OBJ_WA TO OBJ_TAB. CLEAR OBJ_WA. 

MOVE:  'B'      TO OBJ_WA-CLUSTERNAME, 
       'B_PROG' TO OBJ_WA-PROGRAMNAME. 
APPEND OBJ_WA TO OBJ_TAB. CLEAR OBJ_WA. 

MOVE:  'C'      TO OBJ_WA-CLUSTERNAME, 
       'C_PROG' TO OBJ_WA-PROGRAMNAME. 
APPEND OBJ_WA TO OBJ_TAB. CLEAR OBJ_WA. 

EXPORT (OBJ_TAB) TO MEMORY ID 'ABCD'.

In the same way the import command would be

IMPORT (OBJ_TAB) FROM MEMORY ID 'ABCD'.

Regards

Arun

Read only

Former Member
0 Likes
1,406

Hi Peter

As you were asking for Global, please go through the below info from documentaion.

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

Extras:

1. ... = f (for each field to be exported)

2. ... FROM f (for each field to be exported)

3. ... CLIENT g (before ID key )

4. ... USING form

5. ... FROM wa (after ID key or dbtab(ar))

6. ... COMPRESSION ON/OFF (as the last addition)

7. ... CODE PAGE HINT g (for internal use only) )

The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Implicit Field Names in Clusters and Cannot Use Table Work Areas.

Effect

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

The database table dbtab specified must have a standardized structure.

The database table dbtab is divided into different logically related areas (ar, 2-character name).

You can export collections of data objects (known as data clusters) under a freely definable key (field key) to an area of this database.

IMPORT allows you to import individual data objects from this cluster.

Notes

You must enter an explicit name for the exported data objects in classes - that is, either addition 1 or addition 2 is mandatory.

You must also enter the work area explicitly in classes - that is, addition 5 is mandatory.

The table dbtab specified after DATABASE must be declared under TABLES (except in addition 5).

The header lines of internal tables cannot be exported because specifying the name of an internal table with a header line always exports the actual table data.

Data is stored in the database. The operation is only irrevocable after a database commit (see LUW). Prior to this, any database update can be reversed by a database rollback (see Programming Transactions).

The key must be a character-type data object (but not a string).

Example

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

TYPES: BEGIN OF ITAB3_TYPE,

CONT(4),

END OF ITAB3_TYPE.

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

ITAB3 TYPE STANDARD TABLE OF ITAB3_TYPE WITH NON-UNIQUE

DEFAULT KEY INITIAL SIZE 2,

WA_INDX TYPE INDX.

  • Before the export, fill the data

  • fields before CLUSTR.

WA_INDX-AEDAT = SY-DATUM.

WA_INDX-USERA = SY-UNAME.

  • Export data.

EXPORT F1 FROM F1

F2 FROM F2

ITAB3 FROM ITAB3

TO DATABASE INDX(ST) FROM WA_INDX ID INDXKEY.

DATABASE INDX(ST) ID INDXKEY.

Addition 1

... = f (for each object to be exported)

Effect

Exports the contents of the field f and stores them under the specified name in the database.

Addition 2

... FROM f (for each object to be exported)

Effect

Exports the contents of the field f and stores them under the specified name in the database.

Addition 3

... CLIENT g (after dbtab(ar))

Effect

Stores the data objects in the client g (if the import/export database table dbtab is client-specific). The client g must be a character-type data object (but not a string).

Addition 4

... USING form

Note

This statement is for internal use only.

Incompatible changes or further developments may occur at any time without warning or notice.

Effect

Does not export the data to the database table. Instead, calls the FORM routine form for every record written to the database without this addition. The name of the routine has the format <name of database table>_<name of form>. The routine can take the data from the work area of the database table; it has a parameter, which describes the operation mode (READ, UPDATE or INSERT). The routine must set the field SY-SUBRC in order to show whether the function was successfully performed.

Kind Regards

Eswar

Read only

Former Member
0 Likes
1,406

Hello,

export <internal table> to memory id <id>.

import <internal table> from memory id <id>.

Regards,

Shehryar Dahar