Select using work area inline declaration ABAP 7.4


How to declare work area inline in OPEN SQL Select ABAP 7.4 ? Work Area inline declaration with ABAP 7.4

A+ A-

In NetWeaver 7.4 version SAP has simplified OPEN SQL statements, now developers can use inline declarations in OPEN SQL select statements.

Example Select statement to read Single record from database table using ABAP 7.4 Open SQL.

Using work area in Select Statements before ABAP 7.4

DATA: WA_MARA TYPE MARA.
SELECT SINGLE *
  FROM MARA
  INTO WA_MARA WHERE MATNR = '0001'.
WRITE:/ wa_mara-matnr, wa_mara-mtart.

Work Area inline declaration in Select Open SQL in ABAP 7.4

We use @DATA() in select statement for inline declaration in ABAP 7.4

SELECT SINGLE * FROM MARA
  INTO @DATA(wa_MARA) WHERE MATNR = '0001'.
WRITE:/ wa_mara-matnr, wa_mara-mtart.

Below is the select statement to read single record with specific fields from database table using ABAP 7.4 .

Before ABAP 7.4

TYPES: BEGIN OF TY_MARA,
       MATNR TYPE MARA-MATNR,
       MTART TYPE MARA-MTART,
       END OF TY_MARA.

DATA: WA_MARA TYPE TY_MARA.
SELECT MATNR MTART 
  FROM MARA 
  INTO WA_MARA WHERE MATNR = '0001'.

WRITE:/ wa_mara-matnr, wa_mara-mtart.

Work Area with user defined fields in Select Open SQL in ABAP 7.4

Note: You need to use comma "," separator between fields in Select
SELECT SINGLE MATNR, MTART FROM MARA
  INTO @DATA(wa_MARA) WHERE MATNR = '0001'.

WRITE:/ wa_mara-matnr, wa_mara-mtart.

Learner Questions

No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question


    Was this lesson helpful to you? Yes No 0 People out of 0 think this lesson helpful

    Lesson Navigation

    Introduction to ABAP 7.4 and Inline Declarations ← Previous Lesson
    Next Chapter →