Overview
In this post you will learn, how we can use ‘READ_TEXT’ function for Fiori elements application. Consumption CDS is generating the Fiori elements application but sometimes we need Abap Logic calculation. (Calculate field values using Abap resources one of them read text belongs to material or orders etc.).
In this case, we can use the CDS with Virtual Element.
What are the Virtual Elements and Why we use that?
Sometimes when we make a report, we need calculations for fields and we can not easily make calculations with CDS so that their values can be calculated directly on SAP HANA. Virtual elements represent temporary fields in applications. They are defined consumption CDS view with annotations within the SELECT list. However, the field calculations display by Abap classes that implement the specific code exit interfaces provided for this purpose.
The code exit class for virtual elements. We should implement suitable interfaces according to the use case;
- Interface IF_SADL_EXIT_CALC_ELEMENT_READ
- Interface IF_SADL_EXIT_FILTER_TRANSFORM
- Interface IF_SADL_EXIT_SORT_TRANSFORM
You can find more information about Virtual Element with Sap standard documents link.
Implementation Steps:
- Use Eclipse for creating CDS View. Use Virtual element in CDS with annotations.
You can find more information about create the CDS View for beginners.
CDS View;
@AbapCatalog.sqlViewName: 'ZI_V_GOODPACK' @AbapCatalog.compiler.compareFilter: true @AbapCatalog.preserveKey: true @AccessControl.authorizationCheck: #CHECK @EndUserText.label: 'Goodpack Series No - Basic View' @OData: { publish: true } @UI.headerInfo:{ typeNamePlural: 'GoodPack'} define view ZI_GOODPACK as select from likp as l1 inner join lips as l2 on l2.vbeln = l1.vbeln and l2.pstyv = 'ZPAC' left outer join kna1 as k1 on k1.kunnr = l1.kunnr left outer join vbfa as v1 on v1.vbelv = l1.vbeln and v1.vbtyp_n = '8' left outer join vttk as v2 on v2.tknum = l1.vbeln left outer join /scdl/db_proch_o as t1 on t1.docno = l1.vbeln left outer join /scwm/huref as t2 on t2.docid = t1.docid left outer join /scwm/hu_ident as t3 on t3.guid_hu = t2.guid_hu and t3.idart = 'Y' left outer join lips as l3 on l3.vbeln = l1.vbeln left outer join vbrp as v4 on v4.vgbel = l1.vbeln and v4.vgpos = l3.posnr left outer join vbrk as v5 on v5.vbeln = v4.vbeln and sfakn = '' { @UI: { lineItem: [ { position: 10, label: 'Delivery'} ]} key l1.vbeln, @UI.hidden: false @UI.selectionField: [{ position: 10 }] @Consumption.valueHelpDefinition:[{entity:{name:'ZI_VKORGSH',element:'vkorg'}}] @Consumption.filter : { selectionType : #RANGE, multipleSelections : true, defaultValue : '1250'} l1.vkorg, @UI.hidden: false @UI.selectionField: [{ position: 20 }] @Consumption.valueHelpDefinition:[{entity:{name:'ZI_WERKSSH',element:'werks'}}] l1.werks, @UI: { lineItem: [ { position: 20, label: 'Customer'} ]} @UI.selectionField: [{ position: 30 }] @Consumption.valueHelpDefinition:[{entity:{name:'ZI_KUNNRSH',element:'kunnr'}}] l1.kunnr, @UI: { lineItem: [ { position: 30, label: 'Customer Name'} ]} concat( concat( k1.name1, ' '), k1.name2 ) as name1, @UI: { lineItem: [ { position: 40, label: 'Delivery Note'} ]} l1.xblnr, @UI: { lineItem: [ { position: 40, label: 'Container ID'} ]} v2.signi, @UI: { lineItem: [ { position: 50, label: 'Actual Goods Movement Date'} ]} l1.wadat_ist, @UI: { lineItem: [ { position: 60, label: 'Material Number'} ]} l2.matnr, @UI: { lineItem: [ { position: 70, label: 'Short text for sales order item'} ]} l2.arktx, @UI: { lineItem: [ { position: 80} ]} v1.vbeln as vbfa_vbeln, @UI: { lineItem: [ { position: 90} ]} t4.konsimento_tarih, @UI: { lineItem: [ { position: 100} ]} t4.konsimento_no, @UI: { lineItem: [ { position: 110, label: 'Virtual Element'} ]} @ObjectModel.virtualElement: true @ObjectModel.virtualElementCalculatedBy: 'ZCL_DEMO_CDS_CALC' cast( '' as abap.char(255)) as note } group by l1.vbeln, l1.vkorg, l1.werks, l1.kunnr, k1.name1, k1.name2, l1.xblnr, l1.wadat_ist, l2.matnr, l2.arktx, v1.vbeln, v2.signi, t2.guid_hu, t3.huident, t4.konsimento_tarih, t4.konsimento_no
Define relationship with CDS, ODATA and Custom Class.
2. Create custom class and implement intarface ‘IF_SADL_EXIT_CALC_ELEMENT_READ’. Implement both methods ‘GET_CALCULATE_INFO’ and ‘CALCULATE’.
- Method GET_CALCULATION_INFO is used to provide the list of fields which is required for the calculation.
- Method CALCULATE is actual method where we implement the custom logic.
- Implementation Step 1 : We called custom class in CDS view.
@ObjectModel.virtualElement: true @ObjectModel.virtualElementCalculatedBy: 'ZCL_DEMO_CDS_CALC' cast( '' as abap.char(255)) as note
Use the CALCULATE method for utilizing ABAP resource.
3. Use SAP Web IDE for creating List Reporting App.
You can find detail information about List Reporting App.
Output
Conclusion
In this blog, we learn how we can utilize the CDS virtual elements. I welcome all suggestions for improvement or questions. Thanks for reading.
Boa tarde!
ResponderExcluirSaberia me informar qual transação eu posso usar para extrair um relatório das baixas realizadas.