SAP WITH MAINQUERY ABAP Statements



Get Example source ABAP code based on a different SAP table
  



WITH, mainquery_clauses

ABAP_SYNTAX
... $[SINGLE $[FOR UPDATE$]$]
${ FROM source
FIELDS select_clause $}
$| ${ select_clause
FROM source $}
$[WHERE sql_cond$]
$[GROUP BY group$] $[ HAVING group_cond$]
$[ORDER BY sort_key$]
$[db_hints$] ...

What does it do?
Possible clauses and additions of the main query of a WITH statement. All clauses are possible as in a standalone SELECT statement except for FOR ALL ENTRIES, and they have the same effect. In particular, a SELECT loop is opened under the same circumstances as in the standalone SELECT statement. In this case, this loop must be closed with ENDWITH.
The result set of a common table expression does not have a client column, which means that the FROM clause of the main query cannot contain the addition USING for switching
BEGIN_SECTION VERSION 5 OUT or the obsolete addition CLIENT SPECIFIED
END_SECTION VERSION 5 OUT for disabling implicit client handling .
If an internal table @itab with elementary row type is accessed in the FROM clause of a common table expression, the SELECT list cannot be * or contain data_source~* .

ABAP_EXAMPLE_VX5
The example shows a WITH statement whose main query creates a tabular result set. Since the example writes to an internal table itab, no SELECT loop is opened.
ABEXA 00775
ABAP_EXAMPLE_END

Return to menu