Entering content frame

Filling an Initial Screen Using SPA/GPA Parameters Locate the document in its SAP Library structure

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 PARAMETERstatements.

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 ID pid can be up to 20 characters long. If there was already a value stored under pid, this statement overwrites it. If you double-click pid in the ABAP Editor, parameters that do not exist can be created as a Repository object.

To read an SPA/GPA parameter, use:

GET PARAMETER ID pid FIELD f.

This statement places the value stored under the pid ID into the variable f. If the system does not find any value for pid in the SAP memory, sy-subrc is set to 4. Otherwise, it sets the value 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 SAP 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.

If you want to set SPA/GPA parameters before a program call, you need to know which parameters are linked to which fields on the initial screen. A simple way of doing this is to start the program that you want to call, place the cursor on the input fields, and choose F1 followed by Technical info. After you have done this, the Parameter ID field contains the name of the corresponding SPA/GPA parameter. Alternatively, you can look at the screen definition in the Screen Painter.

Example

The technical information for the first input field of the booking transaction TCG2 looks like this:

This graphic is explained in the accompanying text

The SPA/GPA parameter for the input field Company has the ID CAR. Use this method to find the IDs CON, DAY, and BOK for the other input fields.

The following executable program is connected to the logical database F1S and calls an update transaction:

REPORT bookings NO STANDARD PAGE HEADING.

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'.

The basic list of the program shows fields from the database table SBOOK according to the user entries on the selection screen. These data are also stored in the HIDE areas of each line.

This graphic is explained in the accompanying text

If the user selects a line of booking data by double-clicking, the system triggers the AT LINE-SELECTION event and takes the data stored in the HIDE area to fill them into the SPA/GPA parameters of the initial screen of the transaction. Then it calls the transaction. Since you do not suppress the initial screen using AND SKIP FIRST SCREEN, the initial screen may appear as follows:

This graphic is explained in the accompanying text

If you would use the AND SKIP FIRST SCREEN option with the CALL TRANSACTIONstatement, the second screen would appear immediately, since all obligatory fields of the first screen are filled.

 

 

Leaving content frame