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: 

acessing BSEG by import/export method

Former Member
0 Kudos

hi !

anyone please gexpalin me or give me links to how to access the BSEG TABLE by IMPORT EXPORT OR macros method! o

reward points will be given to best answer

1 ACCEPTED SOLUTION

Former Member
0 Kudos

IMPORT - Get data

Variants

1. IMPORT f itab FROM MEMORY.

2. IMPORT f itab FROM DATABASE dbtab(ar) ID key.

3. IMPORT DIRECTORY INTO itab FROM DATABASE dbtab(ar) ID key.

4. IMPORT f itab FROM DATASET dsn(ar) ID key.

Variant 1

IMPORT f itab FROM MEMORY.

Additions

1. ... TO g (for each field f to be imported)

2. ... ID key

Effect

Imports data objects (fields or tables) from the ABAP/4 memory (see EXPORT ). Reads in all data without an ID that was exported to memory with "EXPORT ... TO MEMORY." . In contrast to the variant IMPORT FROM DATABASE , it does not check that the structure matches in EXPORT and IMPORT .

The return code value is set as follows:

SY-SUBRC = 0 The data objects were successfully imported.

SY_SUBRC = 4 The data objects could not be imported, probably

because the ABAP/4 memory was empty.

The contents of all objects remain unchanged.

Addition 1

... TO g (for each field f to be imported)

Effect

Takes the field contents stored under f from the global ABAP/4 memory and places them in the field g .

Addition 2

... ID key

Effect

Imports only data stored in ABAP/4 memory under the ID key .

The return code value is set as follows:

SY-SUBRC = 0 The data objects were successfully imported.

SY_SUBRC = 4 The data objects could not be imported, probably

because an incorrect ID was used.

The contents of all objects remain unchanged.

Variant 2

IMPORT f itab FROM DATABASE dbtab(ar) ID key.

Additions

1. ... TO g (for each field f to be imported)

2. ... MAJOR-ID maid (instead of ID key )

3. ... MINOR-ID miid (together with MAJOR-ID maid )

4. ... CLIENT h (after dbtab(ar) )

5. ... USING form

Effect

Imports data objects (fields, field strings or internal tables) with the ID key from the area ar of the database dbtab (see also EXPORT )

The return code value is set as follows:

SY-SUBRC = 0 The data objects were successfully imported.

SY_SUBRC = 4 The data objects could not be imported, probably

because an incorrect ID was used.

The contents of all objects remain unchanged.

Example

Import two fields and an internal table:

TABLES INDX.

DATA: INDXKEY LIKE INDX-SRTFD,

F1(4), F2 TYPE P,

BEGIN OF TAB3 OCCURS 10,

CONT(4),

END OF TAB3.

INDXKEY = 'INDXKEY'.

IMPORT F1 F2 TAB3 FROM DATABASE INDX(ST) ID INDXKEY.

Notes

The structure of fields, field strings and internal tables to be imported must match the structure of the objects exported to the dataset. In addition, the objects must be imported under the same name used to export them. If this is not the case, either a runtime error occurs or no import takes place.

Exception: You can lengthen or shorten the last field if it is of type CHAR , or add/omit CHAR fields at the end of the structure.

Addition 1

... TO g (for each field f to be imported)

Effect

Takes the field contents stored under the name f from the database and places them in g .

Addition 2

... MAJOR-ID maid (instead of ID key )

Addition 3

... MINOR-ID miid (together with MAJOR-ID maid )

Effect

Searches for a record with an ID that matches maid in the first part (length of maid ) and - if MINOR-ID miid is also specified - is greater than or equal to miid in the second part.

Addition 4

... CLIENT h (after dbtab(ar) )

Effect

Takes the data from the client h (only with client-specific import/export databases).

Example

TABLES INDX.

DATA F1.

IMPORT F1 FROM DATABASE INDX(AR) CLIENT '002' ID 'TEST'.

Addition 5

... USING form

Effect

Does not read the data from the database. Instead, calls the FORM routine form for each record read from the database without this addition. This routine can take the data key of the data to be retrieved from the database table work area and write the retrieved data to this work area schreiben; it therefore has no parameters.

Note

Runtime errors

Depending on the operands or the datsets to be imported, various runtime errors may occur.

Variant 3

IMPORT DIRECTORY INTO itab FROM DATABASE dbtab(ar) ID key.

Additions

1. ... CLIENT h (after dbtab(ar) )

Effect

Imports an object directory stored under the specified ID with EXPORT into the table itab .

The return code value is set as follows:

SY-SUBRC = 0 The directory was successfully imported.

SY_SUBRC = 4 The directory could not be imported, probably because an incorrect ID was used.

The internal table itab must have the same structure as the Dictionary structure CDIR (INCLUDE STRUCTURE ).

Addition 1

... CLIENT h (after dbtab(ar) )

Effect

Takes data from the client h (only with client-specific import/export databases).

Example

Directory of a cluster consisting of two fields and an internal table:

TABLES INDX.

DATA: INDXKEY LIKE INDX-SRTFD,

F1(4), F2 TYPE P,

BEGIN OF TAB3 OCCURS 10,

CONT(4),

END OF TAB3,

BEGIN OF DIRTAB OCCURS 10.

INCLUDE STRUCTURE CDIR.

DATA END OF DIRTAB.

INDXKEY = 'INDXKEY'.

EXPORT F1 F2 TAB3 TO

DATABASE INDX(ST) ID INDXKEY. " TAB3 has 17 entries

...

IMPORT DIRECTORY INTO DIRTAB FROM DATABASE INDX(ST) ID INDXKEY.

Then, the table DIRTAB contains the following:

NAME OTYPE FTYPE TFILL FLENG

-


F1 F C 0 4

F2 F P 0 8

TAB3 T C 17 4

The meaning of the individual fields is as follows:

NAME : Name of stored object OTYPE : Object type ( F : Field, R : Field string / Dictionary structure, T : Internal table) FTYPE : Field type ( C : Character, P : Packed, ...)

Field strings and internal tables have the type C. TFILL : Number of internal table lines filled FLENG : Length of field in bytes

With internal tables: Length of header line.

Variant 4

IMPORT f itab ... FROM DATASET dsn(ar) ID key.

Note

This variant is not to be used at present.

Regards,

Jagadish

3 REPLIES 3

Former Member
0 Kudos

Hi,

Program A :

SELECT-OPTIONS: S_BELNR FOR BKPF-BELNR.

EXPORT S_BELNR TO MEMORY ID 'ZXC9'.

Program B :

DATA: BEGIN OF S_BELNR OCCURS 10.

INCLUDE STRUCTURE STRUC1.

DATA: LOW LIKE BKPF-BELNR,

HIGH LIKE BKPF-BELNR.

DATA: END OF S_BELNR.

IMPORT S_BELNR FROM MEMORY ID 'ZXC9'.

For EXPORT: http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/export01.htm

For IMPORT: http://www.geocities.com/siliconvalley/campus/6345/import01.htm

Regards,

Raj.

Former Member
0 Kudos

EXPORT - Export data

Variants

1. EXPORT obj1 ... objn TO MEMORY.

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

3. EXPORT obj1 ... objn TO DATASET dsn(ar) ID key.

Variant 1

EXPORT obj1 ... objn TO MEMORY.

Additions

1. ... FROM g (for each field to be exported)

2. ... ID key

Effect

Exports the objects obj1 ... objn (fields, structures or tables) as a data cluster to ABAP/4 memory .

If you call a transaction, report or dialog module (with CALL TRANSACTION , SUBMIT or CALL DIALOG ), the contents of ABAP/4 memory are retained, even across several levels. The called transaction can then retrieve the data from there using IMPORT ... FROM MEMORY . Each new EXPORT ... TO MEMORY statement overwrites any old data, so no data is appended.

If the processing leaves the deepest level of the call chain, the ABAP/4 memory is released.

Note

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.

Addition 1

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

Effect

Exports the contents of the data object g and stores them under the name specified before FROM .

Addition 2

... ID key

Effect

Stores the exported data under the ID key in ABAP/4 memory . You can then use the ID to read it in again (with IMPORT ). The ID can be up to 32 characters long.

Note

If you store data both with and without an ID , the data stored without an ID remains separate and you can re-import it (using IMPORT without ID ).

Note

Runtime errors

EXPORT_NO_CONTAINER : SAP paging exhausted

Variant 2

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

Additions

1. ... FROM g (for each field to be exported)

2. ... CLIENT h (after dbtab(ar) )

3. ... USING form

Effect

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

The database table dbtab 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

The table dbtab specified after DATABASE must be declared under TABLES .

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.

Example

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

TABLES INDX.

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

F1(4), F2 TYPE P,

BEGIN OF ITAB3 OCCURS 2,

CONT(4),

END OF ITAB3.

  • Before the export, the data fields in

  • front of CLUSTR are filled.

INDX-AEDAT = SY-DATUM.

INDX-USERA = SY-UNAME.

  • Export der Daten.

EXPORT F1 F2 ITAB3 TO

DATABASE INDX(ST) ID INDXKEY.

Addition 1

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

Effect

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

Addition 2

... CLIENT h (after dbtab(ar) )

Effect

Stores the data objects in the client h (if the import/export database table dbtab is client-specific).

Addition 3

... USING form

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. This routine can take the data from the database table work area and therefore has no parameters.

Note

Runtime errors

Errors in the structure of the EXPORT / IMPORT database can cause runtime errors .

Variant 3

EXPORT obj1 ... objn TO DATASET dsn(ar) ID key.

Note

This variant is not to be used at present.

Note

Runtime errors

EXPORT_DATASET_CANNOT_OPEN : Unable to describe file.

EXPORT_DATASET_WRITE_ERROR : File write error.

Former Member
0 Kudos

IMPORT - Get data

Variants

1. IMPORT f itab FROM MEMORY.

2. IMPORT f itab FROM DATABASE dbtab(ar) ID key.

3. IMPORT DIRECTORY INTO itab FROM DATABASE dbtab(ar) ID key.

4. IMPORT f itab FROM DATASET dsn(ar) ID key.

Variant 1

IMPORT f itab FROM MEMORY.

Additions

1. ... TO g (for each field f to be imported)

2. ... ID key

Effect

Imports data objects (fields or tables) from the ABAP/4 memory (see EXPORT ). Reads in all data without an ID that was exported to memory with "EXPORT ... TO MEMORY." . In contrast to the variant IMPORT FROM DATABASE , it does not check that the structure matches in EXPORT and IMPORT .

The return code value is set as follows:

SY-SUBRC = 0 The data objects were successfully imported.

SY_SUBRC = 4 The data objects could not be imported, probably

because the ABAP/4 memory was empty.

The contents of all objects remain unchanged.

Addition 1

... TO g (for each field f to be imported)

Effect

Takes the field contents stored under f from the global ABAP/4 memory and places them in the field g .

Addition 2

... ID key

Effect

Imports only data stored in ABAP/4 memory under the ID key .

The return code value is set as follows:

SY-SUBRC = 0 The data objects were successfully imported.

SY_SUBRC = 4 The data objects could not be imported, probably

because an incorrect ID was used.

The contents of all objects remain unchanged.

Variant 2

IMPORT f itab FROM DATABASE dbtab(ar) ID key.

Additions

1. ... TO g (for each field f to be imported)

2. ... MAJOR-ID maid (instead of ID key )

3. ... MINOR-ID miid (together with MAJOR-ID maid )

4. ... CLIENT h (after dbtab(ar) )

5. ... USING form

Effect

Imports data objects (fields, field strings or internal tables) with the ID key from the area ar of the database dbtab (see also EXPORT )

The return code value is set as follows:

SY-SUBRC = 0 The data objects were successfully imported.

SY_SUBRC = 4 The data objects could not be imported, probably

because an incorrect ID was used.

The contents of all objects remain unchanged.

Example

Import two fields and an internal table:

TABLES INDX.

DATA: INDXKEY LIKE INDX-SRTFD,

F1(4), F2 TYPE P,

BEGIN OF TAB3 OCCURS 10,

CONT(4),

END OF TAB3.

INDXKEY = 'INDXKEY'.

IMPORT F1 F2 TAB3 FROM DATABASE INDX(ST) ID INDXKEY.

Notes

The structure of fields, field strings and internal tables to be imported must match the structure of the objects exported to the dataset. In addition, the objects must be imported under the same name used to export them. If this is not the case, either a runtime error occurs or no import takes place.

Exception: You can lengthen or shorten the last field if it is of type CHAR , or add/omit CHAR fields at the end of the structure.

Addition 1

... TO g (for each field f to be imported)

Effect

Takes the field contents stored under the name f from the database and places them in g .

Addition 2

... MAJOR-ID maid (instead of ID key )

Addition 3

... MINOR-ID miid (together with MAJOR-ID maid )

Effect

Searches for a record with an ID that matches maid in the first part (length of maid ) and - if MINOR-ID miid is also specified - is greater than or equal to miid in the second part.

Addition 4

... CLIENT h (after dbtab(ar) )

Effect

Takes the data from the client h (only with client-specific import/export databases).

Example

TABLES INDX.

DATA F1.

IMPORT F1 FROM DATABASE INDX(AR) CLIENT '002' ID 'TEST'.

Addition 5

... USING form

Effect

Does not read the data from the database. Instead, calls the FORM routine form for each record read from the database without this addition. This routine can take the data key of the data to be retrieved from the database table work area and write the retrieved data to this work area schreiben; it therefore has no parameters.

Note

Runtime errors

Depending on the operands or the datsets to be imported, various runtime errors may occur.

Variant 3

IMPORT DIRECTORY INTO itab FROM DATABASE dbtab(ar) ID key.

Additions

1. ... CLIENT h (after dbtab(ar) )

Effect

Imports an object directory stored under the specified ID with EXPORT into the table itab .

The return code value is set as follows:

SY-SUBRC = 0 The directory was successfully imported.

SY_SUBRC = 4 The directory could not be imported, probably because an incorrect ID was used.

The internal table itab must have the same structure as the Dictionary structure CDIR (INCLUDE STRUCTURE ).

Addition 1

... CLIENT h (after dbtab(ar) )

Effect

Takes data from the client h (only with client-specific import/export databases).

Example

Directory of a cluster consisting of two fields and an internal table:

TABLES INDX.

DATA: INDXKEY LIKE INDX-SRTFD,

F1(4), F2 TYPE P,

BEGIN OF TAB3 OCCURS 10,

CONT(4),

END OF TAB3,

BEGIN OF DIRTAB OCCURS 10.

INCLUDE STRUCTURE CDIR.

DATA END OF DIRTAB.

INDXKEY = 'INDXKEY'.

EXPORT F1 F2 TAB3 TO

DATABASE INDX(ST) ID INDXKEY. " TAB3 has 17 entries

...

IMPORT DIRECTORY INTO DIRTAB FROM DATABASE INDX(ST) ID INDXKEY.

Then, the table DIRTAB contains the following:

NAME OTYPE FTYPE TFILL FLENG

-


F1 F C 0 4

F2 F P 0 8

TAB3 T C 17 4

The meaning of the individual fields is as follows:

NAME : Name of stored object OTYPE : Object type ( F : Field, R : Field string / Dictionary structure, T : Internal table) FTYPE : Field type ( C : Character, P : Packed, ...)

Field strings and internal tables have the type C. TFILL : Number of internal table lines filled FLENG : Length of field in bytes

With internal tables: Length of header line.

Variant 4

IMPORT f itab ... FROM DATASET dsn(ar) ID key.

Note

This variant is not to be used at present.

Regards,

Jagadish