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: 

Internal table with Import and Export

Former Member
0 Kudos

Hi All,

Hi all

Please let me know the use of <b>Internal table with Import and Export parameters and SET/GET parameters</b>, on what type of cases we can use these? Plese give me the syntax with some examples.

Please give me detailed analysis on the above.

Regards,

Prabhu

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

SAP memory

The SAP memory, otherwise known as the global memory, is available to a user during the entire duration of a terminal session. Its contents are retained across transaction boundaries as well as external and internal sessions. The SET PARAMETER and GET PARAMETER statements allow you to write to, or read from, the SAP memory.

ABAP/4 memory

The contents of the ABAP/4 memory are retained only during the lifetime of an external session (see also Organization of Modularization Units). You can retain or pass data across internal sessions. The EXPORT TO MEMORY and IMPORT FROM MEMORY statements allow you to write data to, or read data from, the ABAP memory.

<i>Hope This Info Helps YOU.</i>

Regards,

Raghav

6 REPLIES 6

former_member181962
Active Contributor
0 Kudos

See sap provided help:

<b>SET PARAMETER

Basic form 5

SET PARAMETER ID pid FIELD f.

In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See ABAP Unicode - Other Changes

Effect

Writes the contents of the field f to the global user-specific SAP memory and the local transaction-specific SAP memory under the ID pid. Any existing values under the same ID are overwritten.

Parameter IDs can be up to 20 characters long. They cannot consist entirely of spaces. The SAP system description contains an overview of parameter IDs. You can also produce a list using the ABAP Workbench.

Notes

The global, user-specific SAP memory is available to a user for the duration of a single terminal session. Values written to it are retained even when the user exits a program.

Do not use SAP memory as a temporary storage area, since parallel sessions belonging to the same user all use the same memory area.

Only store data of the types C, N, D, and T, as well as structures that consist of these types, in the SAP Memory.

You can create new parameter IDs using the ABAP Workbench.

Parameter IDs may have a namespace prefix.

Example

DATA REPID like sy-repid VALUE 'RSPFPAR'.

SET PARAMETER ID 'RID' FIELD REPID.

Sets the program name so it can be passed to other programs.

GET PARAMETER

Basic form 3

GET PARAMETER ID pid FIELD f.

In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See ABAP Unicode - Other Changes

Effect

First, the value stored under the key pid is transferred from the local SAP memory into the field f. If this key is not available in the local SAP memory, the value stored under the same key pid is transferred from the global user-related SAP memory to the field f.

A parameter ID can have up to 20 characters. You can find an overview of the keys (parameters) used in the SAP system description or the appropriate function in the ABAP Workbench.

The Return Code is set as follows:

SY-SUBRC = 0: A value was read from SAP memory. SY-SUBRC = 4: No value was found in SAP memory under the specified key.

Notes

The global user-related SAP memory is available to each user for the entire duration of a terminal session. For this reason, set values are retained when you leave a program.

You should not use SAP memory for temporary storage because a user's parallel sessions use the same global memory.

Example

Read the program name from SAP memory:

DATA : REPID LIKE SY-REPID.

GET PARAMETER ID 'RID' FIELD REPID.

</b>

Former Member
0 Kudos

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.

SAP memory

The SAP memory, otherwise known as the global memory, is available to a user during the entire duration of a terminal session. Its contents are retained across transaction boundaries as well as external and internal sessions. The SET PARAMETER and GET PARAMETER statements allow you to write to, or read from, the SAP memory.

ABAP/4 memory

The contents of the ABAP/4 memory are retained only during the lifetime of an external session (see also Organization of Modularization Units). You can retain or pass data across internal sessions. The EXPORT TO MEMORY and IMPORT FROM MEMORY statements allow you to write data to, or read data from, the ABAP memory.

<i>Hope This Info Helps YOU.</i>

Regards,

Raghav

former_member181962
Active Contributor
0 Kudos

Go to se38 and click on the 'I' button on the application toolbar.

Type export memory, import memory in the key words field.

Then the help will be diplayed in a separate window.

Refer the following links:

Regards,

Ravi

Former Member
0 Kudos

Hi Prabhakar,

ABAP programs can access the parameters using the SET PARAMETER and GET PARAMETER statements.

To fill one, use:

SET PARAMETER ID <pid> FIELD <f>.

This statement saves the contents of field <f> under the ID <pid> in the SAP memory. The code <pid> can be up to 20 characters long. If there was already a value stored under <pid>, this statement overwrites it. If the ID <pid> does not exist, double-click <pid> in the ABAP Editor to create a new parameter object.

To read an SPA/GPA parameter, use:

GET PARAMETER ID <pid> FIELD <f>.

This statement fills the value stored under the ID <pid> into the variable <f>. If the system does not find a value for <pid> in the SAP memory, it sets SY-SUBRC to 4, otherwise to 0.

check this link for info. on import and export parameters:

http://help.sap.com/saphelp_nw04/helpdata/en/d1/801ece454211d189710000e8322d00/content.htm

regards,

keerthi.

former_member184569
Active Contributor
0 Kudos

Hi Prabhakar,

There are three types of memories.

1. ABAP MEMORY

2. SAP MEMORY

3. EXTERNAL MEMORY.

1.we will use EXPORT/ IMPORT TO/ FROM MEMORY-ID when we want to transfer between ABAP memory

2. we will use GET PARAMETER ID/ SET PARAMETER ID to transfer between SAP MEMORY

3. we will use EXPORT/IMPORT TO/FROM SHARED BUFFER to transfer between external memory.

ABAP MEMORY : we can say that two reports in the same session will be in ABAP MEMORY

SAP MEMORY: TWO DIFFERENT SESSIONS WILL BE IN SAP MEMORY.

for ex: IF WE CALL TWO DIFFERENT TRANSACTIONS SE38, SE11

then they both are in SAP MEMORY.

EXTERNAL MEMORY: TWO different logons will be in EXTERNAL MEMORY.

<b>Syntax</b>

To fill the input fields of a called transaction with data from the calling program, you can use the SPA/GPA technique. SPA/GPA parameters are values that the system stores in the global, user-specific SAP memory. SAP memory allows you to pass values between programs. A user can access the values stored in the SAP memory during one terminal session for all parallel sessions. Each SPA/GPA parameter is identified by a 20-character code. You can maintain them in the Repository Browser in the ABAP Workbench. The values in SPA/GPA parameters are user-specific.

ABAP programs can access the parameters using the SET PARAMETER and GET PARAMETER statements.

To fill one, use:

SET PARAMETER ID <pid> FIELD <f>.

This statement saves the contents of field <f> under the ID <pid> in the SAP memory. The code <pid> can be up to 20 characters long. If there was already a value stored under <pid>, this statement overwrites it. If the ID <pid> does not exist, double-click <pid> in the ABAP Editor to create a new parameter object.

To read an SPA/GPA parameter, use:

GET PARAMETER ID <pid> FIELD <f>.

This statement fills the value stored under the ID <pid> into the variable <f>. If the system does not find a value for <pid> in the SAP memory, it sets SY-SUBRC to 4, otherwise to 0.

To fill the initial screen of a program using SPA/GPA parameters, you normally only need the SET PARAMETER statement.

The relevant fields must each be linked to an SPA/GPA parameter.

On a selection screen, you link fields to parameters using the MEMORY ID addition in the PARAMETERS or SELECT-OPTIONS statement. If you specify an SPA/GPA parameter ID when you declare a parameter or selection option, the corresponding input field is linked to that input field.

On a screen, you link fields to parameters in the Screen Painter. When you define the field attributes of an input field, you can enter the name of an SPA/GPA parameter in the Parameter ID field in the screen attributes. The SET parameter and GET parameter checkboxes allow you to specify whether the field should be filled from the corresponding SPA/GPA parameter in the PBO event, and whether the SPA/GPA parameter should be filled with the value from the screen in the PAI event.

When an input field is linked to an SPA/GPA parameter, it is initialized with the current value of the parameter each time the screen is displayed. This is the reason why fields on screens in the R/3 System often already contain values when you call them more than once.

When you call programs, you can use SPA/GPA parameters with no additional programming overhead if, for example, you need to fill obligatory fields on the initial screen of the called program. The system simply transfers the values from the parameters into the input fields of the called program.

However, you can control the contents of the parameters from your program by using the SET PARAMETER statement before the actual program call. This technique is particularly useful if you want to skip the initial screen of the called program and that screen contains obligatory fields.

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.

Saving Data Objects in Memory

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

Syntax

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

This statement stores the data objects specified in the list as a cluster in memory. If you do not use the option FROM <f i >, the data object <f i > is saved under its own name. If you use the FROM <g i > option, the data objet <g i > is saved under the name <f i >. The name <key> identifies the cluster in memory. It may be up to 32 characters long.

Check this link.

http://www.sap-img.com/abap/difference-between-sap-and-abap-memory.htm

Thanks,

Susmitha.

Reward points for helpful answers.

Former Member
0 Kudos

If the data neets to be accessed in same transaction then you can use <b>IMPORT/EXPORT.</b>

Eg:

In source pgm:

EXPORT myvar TO MEMORY ID 'INDX'.

In target pgm:

IMPORT myvar FROM MEMORY ID 'INDX'.

Where myvar should be of same type and can be any type.

Where as in <b>SET and GET</b> the value is buffered to SAP user memory, wherein the user can access the SET value any where in the same login.

For more info, check the link:

http://www.sap-img.com/abap/difference-between-sap-and-abap-memory.htm

Regards,

Thomas.