To create an additional field, proceed as follows:
Double-click on a data source and choose the function Extras.
Another dialog box appears where you must first choose to define either an additional table, an additional field, an additional structure or code.
Choose Additional field and enter a field name. The field name must begin with a letter. The field name HEADER is reserved.
You can enter field definitions in the additional field maintenance screen. If required, you can also change the proposed sequence of the ABAP code for the additional field within the section of code for GET of the logical database table in the generated query report. This sequence could be important, for example, if you need the value of another additional field of the same logical database table for a calculation.
Finally, you must specify how you want to determine the value of the additional field. To maintain codes for this, choose Codes for Extras in the Extras tabstrip. All commands normally available in ABAP editors are also available here.
Note the editor function Check, which checks your code for syntax errors. Otherwise it can only be corrected when you use the functions Check and Generate for the InfoSet area as a whole.
You should check carefully that the fields used in the code all contain valid values at the time the ABAP code is executed. The system helps you to do this by allowing the following fields:
Parameters (see Defining Parameters)
Data from the DATA code (see Further Code).
Fields of the data source table, to which the additional field is assigned and fields of superior logical database tables. In the case of the latter, any additional fields and additional table fields assigned there are also allowed.
If, for example, you have assigned the additional field to the SFLIGHT table of the logical database F1S, fields of the SPFLI and SFLIGHT tables are allowed. It is also possible to access the fields of additional tables as well as additional fields assigned to the table SPFLI.
Other additional fields assigned to the same data source table.
In this case, you must ensure that the additional fields are processed in the correct sequence.
Fields of a linked additional table assigned to the same data source table.
Here, you must ensure that the additional table is accessed before the additional field is processed.
Whenever you are on the screen for editing additional fields, you can change the following:
the sequence of the ABAP code within the processing of data from the logical database table,
description and header texts,
Check box field Generate text field using like-reference.An attempt is made here to generate a text, used for reports, using the like-reference for the field.
However, you cannot change the assignment to a logical database table. To assign the additional table to a different data source table, you must delete the field and recreate it.
The example below shows the meaning of sequence numbers.
The value of the additional field SEATSFREE_PERCENTAGE is calculated with the predefined additional field SEATSFREE. This is why SEATSFREE_PERCENTAGE must have a higher number (2) than SEATSFREE (1), so that the correct value is in SEATSFREE when calculation takes place. In the ABAP Editor the calculation looks like this:
seatsfree_percentage = seatsfree /sflight-seatsmax *100.
If you were to access fields of a linked additional table when performing calculations, the procedure would be similar.
To ensure that query reports can be generated without problems, it is important that it is clear which fields are accessed in every piece of code. If some code contains ABAP statements that access certain fields implicitly, then an ABAP FIELDS statement must also be used in the code to ensure that all fields used are explicitly named. You can find an example of this and further information in Access Optimization in Queries.