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: 

Sintax EXPORT TO MEMORY in AbapObjects ?

former_member425121
Participant
0 Kudos

Hi

I need to save a value in memory in a BADI (Abap Objects), for example to save a flag variable; but it sends a sintax error.

For example:

Data: flag(1) type c.

flag = '1' or '0'.

EXPORT flag TO MEMORY ID 'ZTEST'.

Wich is the sintax to set a value in memory in Abap Objects ??

Regards

Frank

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

The addition ID must be specified with the statements IMPORT/EXPORT/FREE ... MEMORY in ABAP Objects.

Error message in ABAP Objects if the following syntax is used:

EXPORT f TO MEMORY.

IMPORT f FROM MEMORY.

FREE MEMORY.

Correct syntax:

EXPORT f TO MEMORY ID key.

IMPORT f FROM MEMORY ID key.

FREE MEMORY ID key.

Reason:

If no identification is specified, all programs in a call chain use the same memory area. This may lead to unpredictable results especially with complex transactions.

Regards,

Rich Heilman

6 REPLIES 6

Former Member
0 Kudos

Hi Frank,

which is the error?

Bye enzo

Former Member
0 Kudos

Hi Frank,

Is this the exact statement you used?

<b>flag = '1' or '0'.</b>

There is no such statment with the use or 'or'.

If this is not the statement, then I apologize and I request the syntax error text.

Srinivas

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

The addition ID must be specified with the statements IMPORT/EXPORT/FREE ... MEMORY in ABAP Objects.

Error message in ABAP Objects if the following syntax is used:

EXPORT f TO MEMORY.

IMPORT f FROM MEMORY.

FREE MEMORY.

Correct syntax:

EXPORT f TO MEMORY ID key.

IMPORT f FROM MEMORY ID key.

FREE MEMORY ID key.

Reason:

If no identification is specified, all programs in a call chain use the same memory area. This may lead to unpredictable results especially with complex transactions.

Regards,

Rich Heilman

0 Kudos

Here is a example, this is passing the syntax checker.



report zrich_0001
       no standard page heading.


*---------------------------------------------------------------------*
*       CLASS lcl_test DEFINITION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
class lcl_test definition.

  public section.

    methods: constructor.

    data: flag type c.

endclass.


*---------------------------------------------------------------------*
*       CLASS lcl_test IMPLEMENTATION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
class lcl_test implementation.

  method constructor.

  EXPORT <b>flag = flag</b> TO MEMORY ID 'ZTEST'.


  endmethod.


endclass.

REgards,

Rich Heilman

Message was edited by: Rich Heilman

former_member181962
Active Contributor
0 Kudos

Hi Frank,

here is an example code.

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.

Regards,

Ravi

0 Kudos

Thanks for your responses.

I tried the Rich syntax and it works.

Thanks

Frank