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

How to pass data between two internal sessions using ABAP memory?

Former Member
0 Likes
5,204

Hi,

How to pass data between two internal sessions using ABAP memory?

It would be fine if you could explain with an example.

And also let me clear about the data passing between two main sessions and two external sessions with specific examples.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
2,404


Passing data from one ABAP program to another 
1. You have to define an internal table ITAB in program AAA.  

2. In the program AAA you export your ITAB to the memory.  
    EXPORT ITAB TO MEMORY ID 'TD' (ID is the name of memory, you don't need to create it ).  

3. In program BBB you have to declare The same table (same table's name and same fields).  

4. In BBB you can import ITAB :  
    IMPORT ITAB FROM MEMORY ID 'TD'  

5. Now you can export it to AAA after modifications.  
    EXPORT ITAB TO MEMORY ID 'TD' 

6. In AAA :  
    IMPORT ITAB FROM MEMORY ID 'TD' 

This solution is independant to SUBMIT.  


For external sessions
use Set Parameter ID is used to set values to the fields of the screens through the program.
Get Parameter ID is used to get the values into the program that are entered in the fields of the screens

SET PARAMETER ID <pid> FIELD <f>.
GET PARAMETER ID <pid> FIELD <f>.

check this link

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9e0435c111d1829f0000e829fbfe/content.htm


Hi,

How to pass data between two internal sessions using ABAP memory?

It would be fine if you could explain with an example.

And also let me clear about the data passing between two main sessions and two external sessions with specific examples.

Thanks.

5 REPLIES 5
Read only

Former Member
2,405


Passing data from one ABAP program to another 
1. You have to define an internal table ITAB in program AAA.  

2. In the program AAA you export your ITAB to the memory.  
    EXPORT ITAB TO MEMORY ID 'TD' (ID is the name of memory, you don't need to create it ).  

3. In program BBB you have to declare The same table (same table's name and same fields).  

4. In BBB you can import ITAB :  
    IMPORT ITAB FROM MEMORY ID 'TD'  

5. Now you can export it to AAA after modifications.  
    EXPORT ITAB TO MEMORY ID 'TD' 

6. In AAA :  
    IMPORT ITAB FROM MEMORY ID 'TD' 

This solution is independant to SUBMIT.  


For external sessions
use Set Parameter ID is used to set values to the fields of the screens through the program.
Get Parameter ID is used to get the values into the program that are entered in the fields of the screens

SET PARAMETER ID <pid> FIELD <f>.
GET PARAMETER ID <pid> FIELD <f>.

check this link

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9e0435c111d1829f0000e829fbfe/content.htm


Read only

Former Member
0 Likes
2,404

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

ABAP/4 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,

Swetha.

Read only

Former Member
0 Likes
2,404

Hi ,

check the example.

Reading Data Objects from Memory

To read data objects from ABAP memory into an ABAP program, use the following statement:

Syntax

IMPORT <f1> [TO <g 1>] <f 2> [TO <g 2>] ... FROM MEMORY ID <key>.

This statement reads the data objects specified in the list from a cluster in memory. If you do not use the TO <g i > option, the data object <f i > in memory is assigned to the data object in the program with the same name. If you do use the option, the data object <f i > is read from memory into the field <g i >. The name <key> identifies the cluster in memory. It may be up to 32 characters long.

You do not have to read all of the objects stored under a particular name <key>. You can restrict the number of objects by specifying their names. If the memory does not contain any objects under the name <key>, SY-SUBRC is set to 4. If, on the other hand, there is a data cluster in memory with the name <key>, SY-SUBRC is always 0, regardless of whether it contained the data object <f i >. If the cluster does not contain the data object <f i >, the target field remains unchanged.

In this statement, the system does not check whether the structure of the object in memory is compatible with the structure into which you are reading it. The data is transported bit by bit. If the structures are incompatible, the data in the target field may be incorrect.

PROGRAM SAPMZTS1.

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.

The output is displayed on two successive screens. It looks like this:

and

The program SAPMZTS2 attempts to read a data object TEXT3 from the data cluster "text", which does not exist. TEXT3 therefore remains unchanged. The existing data object TEXT2 is placed in TEXT1. In both cases, SY-SUBRC is 0, since the cluster "text" contains data.

The program SAPMZTS3 reads the internal table ITAB from the cluster "table" into the internal table JTAB. Both tables have the same structure, namely that of the ABAP Dictionary table SBOOK.

Pls. reward if useful.....

Read only

0 Likes
2,404

Hi,

Like the table TPARA for SAP memory, what is the table name in which ABAP memory resides?

Read only

Former Member
0 Likes
2,404

1) declare a structure like

TYPES:

BEGIN OF tab_type,

para TYPE string,

dobj TYPE string,

END OF tab_type.

2) define an internal table ITAB and Relevent Variable

DATA:

id(10) TYPE c VALUE 'TEXTS',

text1 TYPE string VALUE `IKE`,

text2 TYPE string VALUE `TINA`,

line TYPE tab_type,

itab TYPE STANDARD TABLE OF tab_type.

3) to pass data inbetween two programs,

a) in first program we will export data to the memory as given below

line-para = 'P1'.

line-dobj = 'TEXT1'.

APPEND line TO itab.

line-para = 'P2'.

line-dobj = 'TEXT2'.

APPEND line TO itab.

Here the data to be passed is stored in line-dobj and will append to the itab

if there is multiple lines to be passed , specify some indications like ' line-para = 'P1'. '

Then Export it into the memory by the statement

EXPORT (itab) TO MEMORY ID id.

Heare 'IKE' ,'TINA' are two texts stored in the memory with memory id 'TEXTS'

b) The second program will Recive data from memory by using import statement.

IMPORT p1 = text2

p2 = text1 FROM MEMORY ID id.

Heare 'IKE' ,'TINA' are two texts read from the memory with memory id 'TEXTS'

Thanks & Regards

Sarath p