ABAP Keyword Documentation → ABAP - Reference → Program Parameters
Parameters in the SAP Memory
Other versions: 7.31 | 7.40 | 7.54
SPA/GPA Parameters
The SAP Memory is a user-specific memory area of the current application server, which is accessed by all main sessions of a user session at once. ABAP programs have access to SPA/GPA parameters stored in the SAP Memory (also called SET/GET parameters).
Each SPA/GPA parameter is identified by an ID of up to 20 characters. SPA/GPA parameters can either
be created explicitly using the statement SET PARAMETER
, or implicitly in a
PAI event. Once they have been
saved in the SAP Memory, they are available to any programs and any sessions throughout the whole duration
of a user session. SPA/GPA parameters are usually evaluated by the ABAP runtime environment. In ABAP
programs, the parameters can be read using the statement GET PARAMETER
.
Example
One example of a program that uses SPA/GPA parameters is user maintenance (transaction SU01). In this transaction, on the Parameters tab page, you can enter user-specific parameters, which are then set when the user logs on to the AS ABAP, and are evaluated by other programs.
SPA/GPA Parameters and ABAP Programs
The statements SET PARAMETER
and GET PARAMETER
of a program do not directly access the SPA/GPA parameters of the SAP Memorys. Instead:
- As soon as an ABAP program is rolled in to the memory, all of the SPA/GPA parameters of the SAP Memory are copied to the
roll area. The statements
SET PARAMETER
andGET PARAMETER
of a program work with the local SPA/GPA parameters of the roll area.
- As soon as a program is rolled out of the memory, all the local SPA/GPA parameters are copied to the cross-session SAP memory, where they replace all SPA/GPA parameters. Any SPA/GPA parameters that do not exist in the roll area will not exist in the SAP Memory afterwards. A roll out is performed for various reasons, such as:
- When quitting a program.
- When calling a new program using
SUBMIT
,CALL TRANSACTION
orLEAVE TO TRANSACTION
.
- During any work process change A work process change results from the same situations that cause an implicit database commit.
- With the
COMMIT WORK
statement.
Note
ABAP programs cannot access the SAP memory directly.Instead, all SPA/GPA parameters have to be imported or exported implicitly at given times like a file. This has consequences for programs that one and the same user can run in parallel sessions:
- If a program sets a SPA/GPA parameter with SET PARAMETER, a program in a parallel main session cannot be started until rolling out the setting program has been started if it should have access to the changed parameter.
- If a program sets a SPA/GPA parameter with SET PARAMETER while another program in a parallel main session is active, and the latter has been running longer than the setting program, these changes will be overwritten when the program that has been running longer is rolled out.
Whereas premature rolling out can be enforced by statements such as WAIT UP TO, the fact that the status of the SAP Memory is always determined by the program that was last rolled out creates a serious obstacle for cross-session use of SPA/GPA parameters in programs that are running in parallel. This type of programming is therefore not recommended.
Managing SPA/GPA Parameters
The names of SPA/GPA parameters are maintained in database table TPARA. In the Object Navigator in ABAP Workbench, the names of SPA/GPA parameters are created in uppercase in database table TPARA and are linked to packages. Database table TPARA acts as a reservation table for SPA/GPA parameters. If you use SPA/GPA parameters in a program, you should ensure that the name of the parameter is contained in the PARAMID column in database table TPARA. Be careful not to overwrite SPA/GPA parameters from other applications.
Note
If a name exists in database table TPARA, this does not automatically mean that the corresponding parameter also exists in the SAP Memory. SPA/GPA parameters are exclusively created during execution of an ABAP program.
SPA/GPA parameters and screen errors
When defining input fields, you can link
screen fields to SPA/GPA parameters by entering the name of an SPA/GPA parameter from the database table TPARA as an attribute PARAMETER ID. If the corresponding parameter
GET PARAMETER is set and no other value is assigned to the input field, the input field is filled with the value of the SPA/GPA parameter when the
screen is sent. If the corresponding
attribute SET PARAMETER is set, the content of the input field is assigned
to the SPA/GPA parameter at the PAI event. If the parameter does not yet exist in the SAP Memory, it is implicitly created at the PAI event. In
selection screens,
you can create this link by using the MEMORY ID
addition to the
PARAMETERS
and SELECT-OPTIONS
statements.
Notes
- A data transport between a screen field and an SPA/GPA parameter in the SAP Memory only takes place if a global data object with the same name as the screen field is declared in the corresponding ABAP program.
- If the PAI event is triggered using a function of type "E", no values are assigned to the SPA/GPA parameters that are linked with the screen, and no parameters are created in the SAP Memory.