'CDS View parameters in-line syntax form or not?

During a select from CDS with parameters, the into table does it always have to be in-line declaration??

MRP:

@AbapCatalog.sqlViewName: 'ZCDS_PARAM1' 
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Test parameters'
define view ZCDS_PARAM
  with parameters
    part_number : matnr // Input parameter
  as select from mara
{
  key matnr as material,
      mtart as material_type,
      matkl as material_group
}
where
  matnr = :part_number

ABAP Program:

SELECT *
    FROM zcds_param( part_number = '000000001000001234' )
    INTO TABLE @DATA(lt_material).  -->should it always be in-line here??

IF sy-subrc IS INITIAL .
  WRITE : 'Material Exists!'.
ENDIF.


Solution 1:[1]

Inline declarations are not mandatory, but the new syntax is

So you need the @ sign, and commas between field names.

(source: I tried it in a 7.53 system)

Solution 2:[2]

No, not necessarily.

You can also declare the variable explicitly as TYPE TABLE OF zcds_param (or alternatively a local structure type which has all the fields you want with the correct name and type) and then use INTO CORRESPONDING FIELDS OF TABLE:

DATA lt_material TYPE TABLE OF zcds_param.

SELECT *
  FROM zcds_param( part_number = '000000001000001234' )
  INTO CORRESPONDING FIELDS OF TABLE @lt_material.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AndrĂ¡s
Solution 2 Philipp