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

ABAP / SAP memory

Former Member
0 Likes
865

Hi Friends,

Kindly give me sample programs, for ABAP Memory and SAP memory.

TIA.

Regards,

MARK K

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
836

Hi,

DATA TEXT1(10) VALUE 'Exporting'.

DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.

DO 5 TIMES.

ITAB-BOOKID = 100 + SY-INDEX.

APPEND ITAB.

ENDDO.

EXPORT TEXT1

TEXT2 FROM 'Literal'

TO MEMORY ID 'text'.

EXPORT ITAB

TO MEMORY ID 'table'.

In this example, the text fields TEXT1 and TEXT2 are stored in the ABAP memory of program SAPMZTS1 under the name "text". The internal table ITAB is stored under the name "table".

DATA TEXT1(10) VALUE 'Exporting'.

DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.

DO 5 TIMES.

ITAB-BOOKID = 100 + SY-INDEX.

APPEND ITAB.

ENDDO.

EXPORT TEXT1

TEXT2 FROM 'Literal'

TO MEMORY ID 'text'.

EXPORT ITAB

TO MEMORY ID 'table'.

SUBMIT SAPMZTS2 AND RETURN.

SUBMIT SAPMZTS3.

The first part of this program is the same as the example in the section Saving Data Objects in Memory. In the example, the programs SAPMZTS1 and SAPMZTS2 are called using SUBMIT. You can create and maintain the programs called using the SUBMIT statement by double-clicking their names in the statement. For further information about the SUBMIT statement, refer to Calling Executable Programs (Reports)

Example for SAPMZTS2:

PROGRAM SAPMZTS2.

DATA: TEXT1(10),

TEXT3 LIKE TEXT1 VALUE 'Initial'.

IMPORT TEXT3 FROM MEMORY ID 'text'.

WRITE: / SY-SUBRC, TEXT3.

IMPORT TEXT2 TO TEXT1 FROM MEMORY ID 'text'.

WRITE: / SY-SUBRC, TEXT1.

Example for SAPMZTS3:

PROGRAM SAPMZTS3.

DATA JTAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.

IMPORT ITAB TO JTAB FROM MEMORY ID 'table'.

LOOP AT JTAB.

WRITE / JTAB-BOOKID.

ENDLOOP.

DATA: TEXT(10) VALUE '0123456789',

IDEN(3) VALUE 'XYZ'.

EXPORT TEXT TO MEMORY ID IDEN.

TEXT = 'xxxxxxxxxx'.

IMPORT TEXT FROM MEMORY ID IDEN.

WRITE: / SY-SUBRC, TEXT.

FREE MEMORY.

TEXT = 'xxxxxxxxxx'.

IMPORT TEXT FROM MEMORY ID IDEN.

WRITE: / SY-SUBRC, TEXT.

The output is

0 0123456789

4 xxxxxxxxxx

The FREE MEMORY statement deletes the data cluster "XYZ". Consequently, SY-SUBRC is 4 after the following IMPORT statement, and the target field remains unchanged.

sap memory

TABLES SBOOK.

START-OF-SELECTION.

WRITE: 'Select a booking',

/ '----


'.

SKIP.

GET SBOOK.

WRITE: SBOOK-CARRID, SBOOK-CONNID,

SBOOK-FLDATE, SBOOK-BOOKID.

HIDE: SBOOK-CARRID, SBOOK-CONNID,

SBOOK-FLDATE, SBOOK-BOOKID.

AT LINE-SELECTION.

SET PARAMETER ID: 'CAR' FIELD SBOOK-CARRID,

'CON' FIELD SBOOK-CONNID,

'DAY' FIELD SBOOK-FLDATE,

'BOK' FIELD SBOOK-BOOKID.

CALL TRANSACTION 'BOOK'.

Thanks,

Das............

7 REPLIES 7
Read only

matt
Active Contributor
0 Likes
836

Kindly clarify. Your question makes no sense to me.

Read only

Former Member
0 Likes
836

This message was moderated.

Read only

Former Member
0 Likes
837

Hi,

DATA TEXT1(10) VALUE 'Exporting'.

DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.

DO 5 TIMES.

ITAB-BOOKID = 100 + SY-INDEX.

APPEND ITAB.

ENDDO.

EXPORT TEXT1

TEXT2 FROM 'Literal'

TO MEMORY ID 'text'.

EXPORT ITAB

TO MEMORY ID 'table'.

In this example, the text fields TEXT1 and TEXT2 are stored in the ABAP memory of program SAPMZTS1 under the name "text". The internal table ITAB is stored under the name "table".

DATA TEXT1(10) VALUE 'Exporting'.

DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.

DO 5 TIMES.

ITAB-BOOKID = 100 + SY-INDEX.

APPEND ITAB.

ENDDO.

EXPORT TEXT1

TEXT2 FROM 'Literal'

TO MEMORY ID 'text'.

EXPORT ITAB

TO MEMORY ID 'table'.

SUBMIT SAPMZTS2 AND RETURN.

SUBMIT SAPMZTS3.

The first part of this program is the same as the example in the section Saving Data Objects in Memory. In the example, the programs SAPMZTS1 and SAPMZTS2 are called using SUBMIT. You can create and maintain the programs called using the SUBMIT statement by double-clicking their names in the statement. For further information about the SUBMIT statement, refer to Calling Executable Programs (Reports)

Example for SAPMZTS2:

PROGRAM SAPMZTS2.

DATA: TEXT1(10),

TEXT3 LIKE TEXT1 VALUE 'Initial'.

IMPORT TEXT3 FROM MEMORY ID 'text'.

WRITE: / SY-SUBRC, TEXT3.

IMPORT TEXT2 TO TEXT1 FROM MEMORY ID 'text'.

WRITE: / SY-SUBRC, TEXT1.

Example for SAPMZTS3:

PROGRAM SAPMZTS3.

DATA JTAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.

IMPORT ITAB TO JTAB FROM MEMORY ID 'table'.

LOOP AT JTAB.

WRITE / JTAB-BOOKID.

ENDLOOP.

DATA: TEXT(10) VALUE '0123456789',

IDEN(3) VALUE 'XYZ'.

EXPORT TEXT TO MEMORY ID IDEN.

TEXT = 'xxxxxxxxxx'.

IMPORT TEXT FROM MEMORY ID IDEN.

WRITE: / SY-SUBRC, TEXT.

FREE MEMORY.

TEXT = 'xxxxxxxxxx'.

IMPORT TEXT FROM MEMORY ID IDEN.

WRITE: / SY-SUBRC, TEXT.

The output is

0 0123456789

4 xxxxxxxxxx

The FREE MEMORY statement deletes the data cluster "XYZ". Consequently, SY-SUBRC is 4 after the following IMPORT statement, and the target field remains unchanged.

sap memory

TABLES SBOOK.

START-OF-SELECTION.

WRITE: 'Select a booking',

/ '----


'.

SKIP.

GET SBOOK.

WRITE: SBOOK-CARRID, SBOOK-CONNID,

SBOOK-FLDATE, SBOOK-BOOKID.

HIDE: SBOOK-CARRID, SBOOK-CONNID,

SBOOK-FLDATE, SBOOK-BOOKID.

AT LINE-SELECTION.

SET PARAMETER ID: 'CAR' FIELD SBOOK-CARRID,

'CON' FIELD SBOOK-CONNID,

'DAY' FIELD SBOOK-FLDATE,

'BOK' FIELD SBOOK-BOOKID.

CALL TRANSACTION 'BOOK'.

Thanks,

Das............

Read only

sachin_mathapati
Contributor
0 Likes
836

[http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb2d40358411d1829f0000e829fbfe/content.htm]

Read only

Former Member
0 Likes
836
Read only

Former Member
0 Likes
836

Hi,

SAP Memory

SAP memory is a memory area to which all main sessions within a SAPgui have access.

You can use SAP memory either to pass data from one program to another within a session,

or to pass data from one session to another.

Application programs that use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters).

These parameters can be set either for a particular user or for a particular program using the SET PARAMETER statement.

Other ABAP programs can then retrieve the set parameters using the GET PARAMETER statement.

The most frequent use of SPA/GPA parameters is to fill input fields on screens (see below).

ABAP Memory

ABAP memory is a memory area that all ABAP programs within the same internal session can access using the EXPORT and IMPORT statements.

Data within this area remains intact during a whole sequence of program calls.

To pass data to a program which you are calling, the data needs to be placed in ABAP memory before the call is made.

The internal session of the called program then replaces that of the calling program.

The program called can then read from the ABAP memory.

If control is then returned to the program which made the initial call, the same process operates in reverse.

Regards,

Priyanka.

Read only

Former Member