- In this post will create Manage Scenario complete application for Create, Modify and Delete Records.
- Step 1: Create Custom Header and Item table:
- Custom Header Table
- Step 2: Create Iinterface view for the Header and Item CDS View and establish a connection between the header and item CDS View. Please refer to RAP 1 and RAP 2 for guidance on creating the interface view:
- Header Interface CDS view:
- Header Interface view Code:
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Root View for Sales order Head'
@Metadata.ignorePropagatedAnnotations: true
define root view entity ZR_SALESORDER_HEAD_M
as select from zms_sales_head as Head
composition [0..*] of ZI_SALESORDER_ITEM_M as _Item
{
key vbeln as SalesOrder,
audat as DocumentDate,
auart as OrderType,
vkorg as SalesOrganization,
vtweg as DistributionChannel,
spart as Division ,
erdat as Erdat,
erzet as Erzet,
ernam as Ernam,
_Item
}
- Item Interface view Code:
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Interface View for Sales order Item'
@Metadata.ignorePropagatedAnnotations: true
define view entity ZI_SALESORDER_ITEM_M
as select from zms_sales_item as Item
association to parent ZR_SALESORDER_HEAD_M as _Head on $projection.SalesOrder = _Head.SalesOrder
{
key vbeln as SalesOrder,
key posnr as Item,
matnr as Material,
arktx as MaterialDescription,
@Semantics.quantity.unitOfMeasure: 'Unit'
kwmeng as Quantity,
vrkme as Unit,
@Semantics.amount.currencyCode: 'Price'
netpr as Netpr,
waerk as Price,
_Head
}
- Step 3: Create Behavior definition on the Interafce Root view, Right Click on Interface Root View and select Behavior definition
- Step 5: We can see the Behavior definition is created as below, Activate Behavior definition
- Step 6: Implement the Behavior definition, Click on Information and click on "Create behavior implementation class"
- Step 7: Provide the Behavior implementation description and click on Next
- Step 8: Activate Behavior Implementation
- Step 9: Create Projection view for Sales Order Header CDS view and Sales order Item CDS view. Also define the relation between header and item in projection view.
- Note: If you want to know how to create Projection view, Kindly refer the link from Step 5 to Step 7.
- Projection view for Sales Order Header code
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'ProjectionView for Sales order Header'
@Metadata.ignorePropagatedAnnotations: true
define root view entity ZC_SALESORDER_HEAD_M
as projection on ZR_SALESORDER_HEAD_M
{
key SalesOrder,
DocumentDate,
OrderType,
SalesOrganization,
DistributionChannel,
Division,
Erdat,
Erzet,
Ernam,
_Item : redirected to composition child ZC_SALESORDER_ITEM_M
}
- Projection View for Sales order Item Code
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'ProjectionView for Sales order Item'
@Metadata.ignorePropagatedAnnotations: true
define view entity ZC_SALESORDER_ITEM_M
as projection on ZI_SALESORDER_ITEM_M
{
key SalesOrder,
key Item,
Material,
MaterialDescription,
@Semantics.quantity.unitOfMeasure: 'Unit'
Quantity,
Unit,
@Semantics.amount.currencyCode: 'Price'
Netpr,
Price,
_Head : redirected to parent ZC_SALESORDER_HEAD_M
}
- Step 10: Create Behavior Definition on the Projection view, Right click on Sales order Header Projection view and click on the Behavior definition, provide the Description and select the Implementation Type as "Projection". Click on Next and finish.
- Step 11: Behavior Definition is created for Projection view as below:
- Step 12: Create Metadata Extension on the Projection View
- First add the annotation @Metadata.allowExtensions: true in bothe Sales order Header and Sales order Item Projection view
- Note: If you want to know how to create Metadata Extension, Kindly refer the link and follow the after Step 15 process.
- Sales Order Header Extension view code:
@Metadata.layer: #CORE
@UI.headerInfo: { typeName: 'Sales Order Manage',
typeNamePlural: 'Sales Order Manage Application' }
annotate entity ZC_SALESORDER_HEAD_M with
{
@UI.facet: [{ id: 'SalesHeader',
purpose: #STANDARD,
position: 10,
label: 'Sales Order Header',
type: #IDENTIFICATION_REFERENCE },
{ id: 'SalesItem',
purpose: #STANDARD,
position: 20,
label: 'Sales Order Item',
type: #LINEITEM_REFERENCE,
targetElement: '_Item' } ]
@UI: { lineItem: [{ position: 10, label: 'Sales Order Number' }],
selectionField: [{ position: 10 }],
identification: [{ position: 10, label: 'Sales Order Number' }] }
SalesOrder;
@UI: { lineItem: [{ position: 20, label: 'Document Date' }],
selectionField: [{ position: 20 }],
identification: [{ position: 20, label: 'Document Date' }] }
DocumentDate;
@UI: { lineItem: [{ position: 30, label: 'Order Type' }],
selectionField: [{ position: 30 }],
identification: [{ position: 30, label: 'Order Type' }] }
OrderType;
@UI: { lineItem: [{ position: 40, label: 'Sales Organization' }],
selectionField: [{ position: 40 }],
identification: [{ position: 40, label: 'Sales Organization' }] }
SalesOrganization;
@UI: { lineItem: [{ position: 50, label: 'Distribution Channel' }],
selectionField: [{ position: 50 }],
identification: [{ position: 50, label: 'Distribution Channel' }] }
DistributionChannel;
@UI: { lineItem: [{ position: 60, label: 'Division' }],
selectionField: [{ position: 60 }],
identification: [{ position: 60, label: 'Division' }] }
Division;
@UI.hidden: true
Erdat;
@UI.hidden: true
Erzet;
@UI.hidden: true
Ernam;
}
- Sales Order Item Extension view code:
@Metadata.layer: #CORE
annotate entity ZC_SALESORDER_ITEM_M with
{
@UI.facet: [{ id: 'SalesItem',
purpose: #STANDARD,
position: 10,
label: 'Sales Order Itemr',
type: #IDENTIFICATION_REFERENCE }]
@UI: { lineItem: [{ position: 10, label: 'Sales order Number' }],
identification: [{ position: 10 }] }
SalesOrder;
@UI: { lineItem: [{ position: 20, label: 'Order Item' }],
identification: [{ position: 20, label: 'Sales Order Item' }] }
Item;
@UI: { lineItem: [{ position: 30, label: 'Material' }],
identification: [{ position: 30, label: 'Material' }] }
Material;
@UI: { lineItem: [{ position: 40, label: 'Material Description' }],
identification: [{ position: 40, label: 'Material Description' }] }
MaterialDescription;
@UI: { lineItem: [{ position: 50, label: 'Quantity' }],
identification: [{ position: 50, label: 'Quantity' }] }
Quantity;
@UI: { identification: [{ position: 60, label: 'Unit' }] }
Unit;
@UI: { lineItem: [{ position: 60, label: 'Amount' }],
identification: [{ position: 70, label: 'Amount' }] }
Netpr;
@UI: { identification: [{ position: 80, label: 'Currency' }] }
Currency;
}
- Step 13: Create Service Definition, Right click on Sales Order Header Projection view (Consumption view) and select the Service Definition
- Step 14: Provide Service Definition Name and Description
- Step 15: Also expose the Sales Order Item consuption view
- Step 16: Create Service Binding, Right click on Service Definition and Select Service Binding
- Step 17: Provide Service Binding Name, Description and Select Binding Type as OData V2, (as we have not created Draf functionality so OData V4 is not working)
- Step 18: Service Binding is created as below, Kinldy Publish the service and activate service again.
- Step 19: Kinldy See the Result in UI
No comments:
Post a Comment