@EndUserText.label : 'calculation example'
@AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #ALLOWED
define table zcalc {
key client : abap.clnt not null;
key example : numc2 not null;
summand_1 : int4;
summand_2 : int4;
}
@AbapCatalog.sqlViewName: 'ZCDSCALCEXAMPLE'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'calculation example'
define view ZCDSCALC
as select from zcalc
{
key example,
summand_1,
summand_2,
summand_1 + summand_2 as addition_result
}
REPORT zcalculation_example.
START-OF-SELECTION.
" ABAP based
TYPES: BEGIN OF calculation,
example TYPE numc2,
summand_1 TYPE int4,
summand_2 TYPE int4,
addition_result TYPE int4,
END OF calculation.
TYPES calculations TYPE TABLE OF calculation WITH KEY example.
DATA abap_based_result TYPE calculations.
SELECT * FROM zcalc
INTO CORRESPONDING FIELDS OF TABLE abap_based_result.
LOOP AT abap_based_result ASSIGNING FIELD-SYMBOL(<row>).
<row>-addition_result = <row>-summand_1 + <row>-summand_2.
ENDLOOP.
" Open SQL based
SELECT example,
summand_1,
summand_2,
summand_1 + summand_2 AS addition_result
FROM zcalc
INTO TABLE @DATA(open_sql_based_result).
" CDS based
SELECT * FROM zcdscalc
INTO TABLE @DATA(cds_based_result).
IF abap_based_result = open_sql_based_result AND
open_sql_based_result = cds_based_result.
cl_demo_output=>display( abap_based_result ).
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |