CDS View entity with join and literals Part 6 ABAP on HANA Course


*&---------------------------------------------------------------------*
*& Report z_cds_cunsumption
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT z_cds_cunsumption.


SELECT *
 FROM zcds_sample_01
 INTO TABLE @DATA(it_result).
IF sy-subrc IS INITIAL.
  cl_demo_output=>display( it_result ).
ENDIF.









*cl_salv_gui_table_ida=>create_for_cds_view(
*  EXPORTING
*    iv_cds_view_name      = 'ZDDLS_SAMPLE_04'
**    io_gui_container      =
**    io_calc_field_handler =
**  RECEIVING
**    ro_alv_gui_table_ida  =
*)->fullscreen( )->display( ).
*CATCH cx_salv_ida_contract_violation..
*CATCH cx_salv_db_connection.
*CATCH cx_salv_db_table_not_supported.
*CATCH cx_salv_ida_contract_violation.
*CATCH cx_salv_function_not_supported.

*cl_dd_ddl_annotation_service=>get_annos(
*  EXPORTING
*    entityname         =  'ZDDLS_SAMPLE_04'
**    variant            = ''
**    language           = SY-LANGU
**    extend             = abap_false
**    metadata_extension = abap_true
**    translation        = abap_true
**    null_values        = abap_false
*  IMPORTING
*    entity_annos       = DATA(ls_anno)
*    element_annos      = DATA(ls_ele_annos)
**    parameter_annos    =
**    annos_tstmp        =
*).
*cl_demo_output=>write( ls_anno ).
*cl_demo_output=>display( ls_ele_annos ).
*SELECT
*  FROM zddls_sample_04
*  FIELDS *
*  INTO TABLE @DATA(it_tab).
*IF sy-subrc IS INITIAL.
*  cl_demo_output=>display( it_tab ).
*ENDIF.






























*First Access association in form as a source so inner join
*Access association in field list so left outer join
*So we can't use path expression at on condition try to get matdesc
*With default filter association

*
*ABAP SQL - Path Expressions,
*... [source~]\_assoc1[sql_para][attributes]
*            [\_assoc2[sql_para][attributes]]
*            [\...] ...



* Attributes Additions:
* 1. ... (n|*)
* 2. ... INNER|{LEFT|RIGHT OUTER}
*The join type can only be specified together with the cardinality.
*
* 3. ... [WHERE] sql_cond  -->using WITH DEFAULT FILTER

*************************************************
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Define view entity'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
    serviceQuality: #X,
    sizeCategory: #S,
    dataClass: #MIXED
}
define view entity ZDDLS_SAMPLE_02
  //with parameters
  //                @Environment.systemField: #SYSTEM_DATE
  //                 p_date : abap.dats
  as select from vbak as head
  association [1..*] to vbap as _item on head.vbeln = _item.vbeln
{
  key head.vbeln as so,
      head.vkorg as sales__org,
      head.vkgrp,
      head.vbtyp as doc_type,
      head.erdat,
      head.bstnk,
      @Semantics.amount.currencyCode: 'waerk'
      head.netwr,
      head.waerk,
      _item,
      //      head.ernam,
      //        item.posnr,
      //        item.matnr,
      @EndUserText.label: 'Numerical'
      0.23       as num_lit,      
      'cds'      as char_lit
      //        $parameters.p_date as syst_date
}
//where
//  head.ernam = 'GABAP3'
//operator  = <> > < <= >= ?=
//[not] between a and b
// like % _
//not null not initial
//user condition  => show session variable we can't use right side
//Create define poicy define aspectfor 09 and use to filter 02
//True /flase
//hodt expression parameter session usee literal









//• Default value can be assigned with annotation – @Environment.systemField: #SYSTEM_DATE
//Parameters are optional only when default value is assigned. We can only use system fields such as #SYSTEM_DATE. Possible values are as below.
//DEMO_CDS_SYSTEM_FIELDS_VE











//define view entity ZDDLS_SAMPLE_02
//  with parameters
//    p_vben : vbeln,
//    @Environment.systemField: #SYSTEM_DATE
//    p_date : abap.dats
//  as select from vbak as head
//    inner join   vbap as item on head.vbeln = item.vbeln
//{
//  key head.vbeln as so,
//      head.vkorg as sales__org,
//      head.vkgrp,
//      item.posnr,
//      item.matnr,
//      0.23       as num_lit,
//      'cds'      as char_lit,
//      head.erdat
//}
//where
//      head.vbeln = $parameters.p_vben
//  and head.erdat = $parameters.p_date



/*
A:
 The CDS view entity can be used for high volume transactions or for background transactions.
  -> Maximum No of DDIC database tables 3,
  -> must not call any functions,
  -> must not aggregate a large number of table rows for direct access,
  -> must not access DDIC database tables with mixed data categories.
  -> If the underlying tables are buffered, the CDS view entity should be buffered too.
  -> The runtime for reading a single line with a fully specified key must be less than 1 ms
     for selecting fields from a field list or 2 ms for selecting all fields with
#B:
 The CDS view entity can be used for transactions or for background transactions.
  -> Maximum No of DDIC database tables 5,
  -> must not call any functions,
  -> must not aggregate a large number of table rows for direct access,
  -> must not access DDIC database tables with mixed data categories.
  -> If the underlying tables are buffered, the CDS view entity should be buffered too.
  -> The runtime for reading a single line with a fully specified key must be less than 2 ms
     for selecting fields from a field list or 5 ms for selecting all fields with

#C:
 The CDS view entity can be used to query individual objects in transactions.
  -> Maximum No of DDIC database tables 15,
  -> must not aggregate a large number of table rows for direct access,
  -> must not access DDIC database tables with mixed data categories.
  -> If the underlying tables are buffered, the CDS view entity should be buffered too.
  -> The runtime for reading a single line with a fully specified key must be less than 10 ms
     for selecting fields from a field list or 20 ms for selecting all fields with


#D:
 The CDS view entity can be used for analytical queries.
 -> Maximum No of DDIC database tables 100,
 -> The performance should be checked and monitored with realistic data by a test framework.

#X:
 The CDS view entity is designed for special application cases, such as data migration.
 -> Maximum No of DDIC database tables more than 100,
#P:
 The CDS view entity is used to structure hierarchies of CDS entities and must not be used outside of such a hierarchy.
 -> A CDS view entity with the quality category P is not intended for usage in business applications.
 -> Performance checks by a test framework are not required.

 */

Comments

Popular posts from this blog

AMDP ( ABAP Managed Database Procedure ) Part - 1

Backup all ADT Objects & Other queries RAP Part 10.1

SAP CDS Introduction Part 2 - ABAP on HANA Course