Skip to Content

IMPORT ... FROM MEMORY

Hi,

I would like to know if there is a way to <b>generically</b> import an object stored into memory.

Indeed, IMPORT.. FROM MEMORY doesn't seem to accept any reference of field-symbols or anything of that sort.

The class CL_ABAP_EXPIMP_MEM looks like it only provides description of the content.

Thanks in advance.

Best regards,

Guillaume

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 03, 2006 at 01:21 PM

    Hai

    Check the following Code

    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.

    IMPORT DYNPRO - Import a screen

    Basic form

    IMPORT DYNPRO h f e m ID id.

    Effect

    Imports the screen specified in the field id . Loads the screen information into the structure h (screen header, structure D020S ) and into the internal tables f (field list, structure D021S ), e (flow logic, structure D022S ) and m (matchcode information, structure D023S ).

    The return code value is set as follows:

    SY-SUBRC = 0 The screen was successfully imported.

    SY_SUBRC = 4 The screen does not exist.

    Thanks & regards

    Sreeni

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 03, 2006 at 01:28 PM

    Sure you can use field symbols. Check the example program below.

    Program 1

    
    report  zrich_0001.
    
    data: itab type table of string with header line.
    
    field-symbols: <fs> type table.
    
    
    itab = 'This is the line 1'.  append itab.
    itab = 'This is the line 2'.  append itab.
    
    assign itab[] to <fs>.
    
    export <fs> to memory id 'ZRICHTEST'.
    
    submit zrich_0002 and return.
    
    

    Program 2

    
    REPORT ZRICH_0002 .
    
    data: itab type table of string with header line.
    
    field-symbols: <fs> type table.
    data: wa type string.
    
    assign itab[] to <fs>.
    
    import <fs> from memory id 'ZRICHTEST'.
    
    
    loop at <fs> into wa.
    write:/ wa.
    endloop.
    
    

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      I would like to know if there is a way to import an object stored into memory supported in OO context.

      I look the class CL_ABAP_EXPIMP_MEM , but i don't understand how to use it.

      Can we help me.

      Thanks in advance.

      Best regards,

      Francesco

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.