1. PROVIDE
{ FIELDS {*|{compi}}
FROM
itabj INTO waj VALID flagj
BOUNDS
intlim1j AND intlim2j
[WHERE
log_expj] }
BETWEEN extlim1 AND extlim2
[INCLUDING GAPS].
2. PROVIDE
{ {*|{compi}}
FROM
itabj }
BETWEEN extlim1 AND extlim2.
Special join for internal tables. Variant 1 is the universally applicable form of the
PROVIDE statement. Variant 2 is a short form of variant 1 that is not permitted in ABAP Objects.
PROVIDE { FIELDS {*|{compi}}
FROM
itabj INTO waj VALID flagj
BOUNDS
intlim1j AND intlim2j
[WHERE
log_expj] }
BETWEEN extlim1 AND extlim2
[INCLUDING GAPS].
The statements PROVIDE and ENDPROVIDE define a loop through a statement block. In this loop, any number of internal tables itabj are processed together. A single table can appear several times. For every table itabj you must specify a FIELDS clause. After FIELDS you must specify the character * for all components or a list compi for specific components of the relevant table. The names of the components compi can only be specified directly.
To be able to process internal tables using PROVIDE, all tables itabj must be fully typed index tables and contain two special columns that have the same data type (d, i, n, or t) for all relevant tables. For every table you must specify the names intlim1 and intlim2 of these columns using the BOUNDS addition.
The columns intlim1 and intlim2 in every row of the relevant internal tables must contain values that can be interpreted as limits of closed intervals. Within a table, the intervals specified in these columns must not overlap and must be sorted in ascending order. The intervals therefore make up a unique key for every row.
For every table you must specify a work area waj compatible with the row type and a variable flagj, for which a character-type data type with length 1 is expected. In the PROVIDE loop, the components specified after FIELDS are filled with values in the relevant work areas waj for every specified internal table. The variable flagj is also filled. A single work area waj or variable flagj cannot be specified more than once.
With the BETWEEN addition you must specify an interval extlim1, extlim2. It must be possible to convert the data objects extlim1 and extlim2 into the data types of the respective columns intlim1 and intlim2 of the individual tables.
The interval limits intlim1j and intlim2j for every row of all relevant internal tables itabj that are within the closed interval made up by extlim1 and extlim2 divide the latter into new intervals and every interval limit closes one interval in the original direction. If, within a relevant table, a lower interval limit follows an upper interval limit with no space or gap between them and the components of the corresponding rows specified after FIELDS have the same content, the two interval limits are combined and the corresponding interval limits intlim2j and intlim1j are ignored for the new intervals.
For every interval that is created in such a way and overlaps with at least one of the intervals of a table involved, the PROVIDE loop is passed once. The components of every work area waj specified after FIELDS and the variable flagj are filled with values as follows:
The components intlim1 and intlim2 of every work area waj are filled with the interval limits of the current interval.
If the current interval overlaps with one of the intervals of an involved table, the remaining components of the corresponding work area are assigned the contents of the relevant components of this table row and the variable flagj is set to the value "X". Otherwise, the work area components and the variable flagj are set to their initial value.
Except for intlim1j and intlim2j, the components not specified after FIELDS are always set to their initial value. The components intlim1j and intlim2j are always assigned.
The ABAP runtime environment checks for every table involved, whether the condition of sorted and non-overlapping intervals is met within the interval made up by extlim1 and extlim2 and, if necessary, triggers an exception that can be handled.
If the INCLUDING GAPS addition is specified, the system passes the PROVIDE loop for every interval, that is also when the current interval does not overlap with at least one of the intervals of an involved table. In the latter case, the variable flagj is of initial value for every relevant table.
You can use the WHERE addition to specify a condition for every table involved. After WHERE, you can specify any logical expression log_exp; the first operand of every comparison must be a component of the relevant table. Here it is not possible to specify a component using character-type data objects in brackets. The table entries, for which the condition is not met are ignored by the PROVIDE loop.
DATA: BEGIN OF wa1,
col1 TYPE i,
col2
TYPE i,
col3 TYPE string,
END
OF wa1.
DATA: BEGIN OF wa2,
col1 TYPE i,
col2 TYPE i,
col3
TYPE string,
END OF wa2.
DATA: itab1 LIKE STANDARD
TABLE OF wa1,
itab2 LIKE STANDARD TABLE OF wa2.
DATA:
flag1(1) TYPE c,
flag2(1) TYPE c.
wa1-col1 = 1.
wa1-col2
= 6.
wa1-col3 = 'Itab1 Int1'.
APPEND wa1 TO itab1.
wa1-col1 = 9.
wa1-col2 = 12.
wa1-col3 = 'Itab1 Int2'.
APPEND wa1 TO itab1.
wa2-col1 = 4.
wa2-col2 = 11.
wa2-col3
= 'Itab2 Int1'.
APPEND wa2 TO itab2.
PROVIDE FIELDS col3
FROM
itab1
INTO wa1
VALID
flag1
BOUNDS col1 AND col2
FIELDS
col3
FROM itab2
INTO wa2
VALID flag2
BOUNDS col1 AND col2
BETWEEN 2 AND 14.
WRITE:
/ wa1-col1, wa1-col2, wa1-col3, flag1.
WRITE: / wa2-col1, wa2-col2, wa2-col3, flag2.
SKIP.
ENDPROVIDE.
In two tables itab1 and itab2, the respective columns col1 and col2 are interval limits of type i. The filling of the internal tables results in the following intervals (rows two and three):
-------------------------------------------
|01|02|03|04|05|06|07|08|09|10|11|12|13|14|
-------------------------------------------
| Itab1 Int1 |
|Itab1 Int2 | |
-------------------------------------------
| | Itab2
Int1 | |
-------------------------------------------
| | ... BETWEEN ...
|
-------------------------------------------
| | i1 | i2
| i3 | i4 |i5| |
-------------------------------------------
The interval specified in the AB>BETWEEN> addition to the PROVIDE statement is shown in the fourth row. It serves as a basis for the five intervals in the fifth row represented by i1 to i5. These can be processed in the PROVIDE loop.
Because each of the five intervals overlaps with one of the intervals from rows two and three, the PROVIDE loop is passed five times.
Only the component col3 of wa1 is filled in the first pass, only the component col3 of wa2 in the third pass, and the components col3 of both work areas in the second and fourth passes. The fields valid1 and valid2 are set accordingly.
The list is displayed as follows:
2 3 Itab1
Int1 X
2 3
4
6 Itab1 Int1 X
4 6 Itab2
Int1 X
7 8
7
8 Itab2 Int1 X
9 11 Itab1
Int2 X
9 11 Itab2 Int1 X
12 12 Itab1 Int2 X
12 12
Catchable Exceptions
CX_SY_PROVIDE_INTERVAL_OVERLAP
CX_SY_PROVIDE_TABLE_NOT_SORTED
PROVIDE { {*|{compi}}
FROM
itabj }
BETWEEN extlim1 AND extlim2.
This statement is not allowed in an ABAP Objects context. See Cannot Use Short Form of PROVIDE.
This form of the PROVIDE statement is a short form of variant 1. The compiler distinguishes the long and short forms by language elements FIELDS to be specified explicitly before the component specifications.
In principle, the short form of the PROVIDE statement works like variant 1. Unlike variant 1 however, fewer additions are allowed here. In the short form, you cannot specify a table several times The internal tables must have headers and the additions that have to be specified in the long form are added by the runtime environment, as described below.
For the PROVIDE loop to function correctly, the same conditions apply as in the long form. However, now exceptions are raised if one of the involved tables is not sorted or there are overlapping intervals.
Interval limits BOUNDS
The columns for interval limits to be specified in the long form as intlim1 and intlim2 using BOUNDS are attributes of the relevant tables in the short form and must be specified when they are declared.
This is done using the VALID BETWEEN addition that can be specified after DATA END OF if an internal table is declared with obsolete OCCURS addition to the DATA BEGIN OF statement. If an internal table is declared using the INFOTYPES statement, these are the BEGDA and ENDDA columns. If no columns are specified for the interval limits in the declaration, the short form of PROVIDE uses the first two columns of the internal table.
Work area INTO
In the short form, the headers of the internal table are implicitly used for the work areas that have to be specified as wa in the long form using the AB>INTO> addition.
VALID flag
The data objects that have to be speci