Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Access →  ABAP SQL →  ABAP SQL - Reads →  WITH 

ENDWITH

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


ENDWITH. 

Effect

The ABAP SQL statement ENDWITH closes a loop started using WITH.


Example

The example shows a WITH statement, whose main query creates a tabular result set. As the data is written into work area wa rather than to an internal table, a SELECT loop is opened, which must be closed with ENDWITH.

WITH 
  +carriers AS ( SELECT FROM scarr 
                       FIELDS carrid, carrname ) 
  SELECT FROM spfli AS s 
           INNER JOIN +carriers AS c 
             ON s~carrid = c~carrid 
         FIELDS c~carrname, s~connid 
         WHERE s~carrid = 'UA' 
         INTO @DATA(wa) 
         UP TO 10 ROWS. 
  cl_demo_output=>write( wa ). 
ENDWITH. 
cl_demo_output=>display( ).