Sap Abap On Hana-2
Sap Abap On Hana-2
Sap Abap On Hana-2
Revolutionizing Inventory Management Integrating SAP ABAP RAP for Enhanced Efficiency
Revolutionizing Inventory Management Integrating SAP ABAP RAP for Enhanced Efficiency
-----------------------------------------------------------------------------------------------------------------------------------
Following steps for implementing inventory management using SAP ABAP RAP:
1. Database Table Creation: Create tables for products (zproduct_01), suppliers (zsuppliers_01),
purchase orders (zpurchase_01), and stock levels (zstocklevel_01). Each table includes essential
fields like client, product_id, supplier_id, and more, with appropriate data types.
2. Data Generation: Implement an ABAP class (zcl_populate_inventory) to populate these tables
with initial data, with methods for creating products, stock levels, suppliers, and purchase
orders.
3. Define CDS Views: Develop CDS views to join and filter data from multiple tables, enabling
efficient data retrieval and analysis.
4. Create Projection View with UI Annotation: Develop a projection view (ZC_INVENTORY_01)
with UI annotations to enhance data representation in SAP Fiori apps.
5. Create Service Definition and Bindings: Develop a service definition for the business objects
and create service bindings to expose them as OData services.
For tracking stock levels, product details, supplier information, and managing purchase orders.
The document provides detailed instructions for creating database tables in SAP ABAP RAP
1. ZTABLE_PRODUCT_DETAILS (zproduct_01):
o Fields: client (key), product_id (key), name, description, category.
o Annotations and properties are specified, such as @EndUserText.label,
@AbapCatalog.tableCategory, and field definitions.
2. ZTABLE_SUPPLIER_INFO (zsuppliers_01):
o Fields: client (key), supplier_id (key), name, contact_info.
o Includes similar annotations and field definitions as the product table.
3. ZTABLE_PURCHASE_ORDERS (zpurchase_01):
o Fields: client (key), order_id (key), product_id, supplier_id, order_quantity, order_date,
status.
o Follows the same structure with specific fields for purchase order management.
4. ZTABLE_STOCK_LEVELS (zstocklevel_01):
o Fields: client (key), product_id (key), quantity.
o Designed for tracking stock levels, with a simple structure focusing on quantity.
Prepared by [email protected]
Each table has its fields and types defined according to its purpose, adhering to SAP ABAP RAP
standards for database design.
○ product details,
○ stock levels,
○ supplier information, and
○ purchase orders.
For example, the product table might include fields for product ID, name, description, and category.
For tracking stock levels, product details, supplier information, and managing purchase orders.
○ product details,
○ stock levels,
○ supplier information, and
○ purchase orders.
For example, the product table might include fields for product ID, name, description, and category.
Prepared by [email protected]
Step 1 :DataBase table Creation
Prepared by [email protected]
Create a Transport Request and Click ‘Finish’.
In alignment with the previous step, I kindly request the creation of three additional tables. The
necessary code is provided below for your reference
@EndUserText.label : 'Product'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zproduct_01 {
key client : abap.clnt not null;
key product_id : abap.char(10) not null;
name : abap.char(40);
description : abap.char(80);
category : abap.char(20);
}
Prepared by [email protected]
Source Code for Table 2
Prepared by [email protected]
Step 2 :Data Generation
Create ABAP class to populate the tables product, stock levels, suppliers, and purchase orders with
initial data.
Prepared by [email protected]
DATA(lt_purchase) = VALUE tt_purchase(
( order_id = '01001' product_id = 'P1001'
supplier_id = 'S1001' order_quantity = 10
order_date = '20230301' status = 'Ordered' )
( order_id = '01002' product_id = 'P1002'
supplier_id = 'S1002' order_quantity = 5
order_date = '20230305' status = 'Delivered' ) ).
DELETE FROM zpurchase_01.
INSERT zpurchase_01 FROM TABLE @lt_purchase.
CLEAR lt_purchase.
ENDMETHOD.
METHOD create_stock_levels.
TYPES:tt_stocklevel TYPE STANDARD TABLE OF zstocklevel_01
WITH EMPTY KEY.
DATA(lt_stocklevel) = VALUE tt_stocklevel(
( product_id = 'P1001' quantiy = 50 )
( product_id = 'P1002' quantiy = 30 ) ).
DELETE FROM zstocklevel_01.
INSERT zstocklevel_01 FROM TABLE @lt_stocklevel.
ENDMETHOD.
METHOD create_suppliers.
TYPES:tt_supplier TYPE STANDARD TABLE OF zsuppliers_01
WITH EMPTY KEY.
DATA(lt_suppliers) = VALUE tt_supplier(
( supplier_id = 'S1001' name = 'TECHSourceA01'
contact_info = '[email protected]' )
( supplier_id = 'S1002' name = 'OfficeSourceA01'
contact_info = '[email protected]' ) ).
DELETE FROM zsuppliers_01.
INSERT zsuppliers_01 FROM TABLE @lt_suppliers.
CLEAR lt_suppliers.
ENDMETHOD.
METHOD load_inventory_data.
create_products( ).
create_stock_levels( ).
create_suppliers( ).
create_purchase_orders( ).
ENDMETHOD.
ENDCLASS.
This class contains methods to insert initial data into each of the defined tables. Modify the data as
necessary to fit your specific requirements or scenarios.
Prepared by [email protected]
To gain an overview of the data contained in the tables listed above, please select the respective table,
right-click, and choose the option to preview the table records
Product Table
Supplier Table
Prepared by [email protected]
Stock Table
Prepared by [email protected]
Prepared by [email protected]
and Click ‘Finish’.
@AbapCatalog.sqlViewName: 'ZVINVENT01'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Stock Level Inventory'
define root view ZI_INVENTORY_01
as select from zproduct_01
left outer join zstocklevel_01 on zproduct_01.product_id = zstocklevel_01.product_id
left outer join zpurchase_01 on zproduct_01.product_id = zpurchase_01.product_id
left outer join zsuppliers_01 on zpurchase_01.supplier_id = zsuppliers_01.supplier_id
{
key zproduct_01.product_id as ProductId,
zproduct_01.name as Name,
zproduct_01.description as Description,
zproduct_01.category as Category,
zstocklevel_01.quantiy as Quantiy,
Prepared by [email protected]
zsuppliers_01.supplier_id as SupplierId,
zsuppliers_01.name as supplier_name,
zpurchase_01.order_id as OrderId,
zpurchase_01.order_quantity as OrderQuantity,
zpurchase_01.status as Status
}
Please find the below output after activating the CDS View.Please run with ‘ABAP Application’
Output
Prepared by [email protected]
Prepared by [email protected]
Click ‘Finish’ and Copy the below code.
Prepared by [email protected]
{
@UI.facet:
[{ id : 'Product',
purpose : #STANDARD,
type : #IDENTIFICATION_REFERENCE,
label : 'Product',
position: 10
}]
@UI:{
lineItem:[ { position :10, importance: #HIGH }],
identification:[ { position:10,label: 'Product ID' }]
}
@Search.defaultSearchElement: true
key ProductId,
@UI:{
lineItem :[{ position:20, importance: #HIGH}],
identification:[{ position:20 }],
selectionField:[{ position:20 }]
}
Name,
@UI:{
lineItem :[{ position:30, importance: #MEDIUM}],
identification:[{ position:30 }]
}
Description,
@UI:{
lineItem:[{ position:40, importance: #MEDIUM}],
identification:[{ position:40 }]
}
Category,
@UI:{
lineItem:[{ position:50,importance: #HIGH}],
identification:[{ position:50 }]
}
Quantiy,
@UI:{
lineItem:[{ position:60,importance: #HIGH}],
identification:[{ position:60 }]
}
SupplierId,
@UI:{
lineItem:[{ position:70,importance: #HIGH}],
Prepared by [email protected]
identification:[{ position:70 }]
}
supplier_name,
@UI:{
lineItem:[{ position:80,importance: #HIGH}],
identification:[{ position:80 }]
}
OrderId,
@UI:{
lineItem:[{ position:90,importance: #HIGH}],
identification:[{ position:90 }]
}
OrderQuantity,
@UI:{
lineItem:[{ position:100,importance: #HIGH}],
identification:[{ position:100 }]
}
Status
}
Prepared by [email protected]
and Click ‘Finish’.Now We can create ‘Service Binding’.
Prepared by [email protected]
Prepared by [email protected]
Activate the service binding and publish it.
Output 1
Prepared by [email protected]
Enhance the Projection View with more annotations:
● Added an additional facet for 'Order Information' to further segment the data.
● Utilized @UI.fieldGroup to logically group fields under the 'Supplier Details' and 'Order
Information' facets. This creates a more structured layout in the Fiori app.
● Enhanced the @UI.lineItem and @UI.identification annotations with more detailed labels and
importance levels to improve data representation in list reports and object pages.
● Included @UI.criticalityLabels to add visual indicators in the UI for critical fields like 'Product
Quantity'.
Prepared by [email protected]
typeNamePlural: 'Products',
title : { type : #STANDARD,
value: 'ProductId'
}
}
}
@Search.searchable: true
define root view entity ZC_INVENTORY_01
as projection on ZI_INVENTORY_01
{
@UI.facet:
[{ id : 'ProductDetails',
purpose : #STANDARD,
type : #IDENTIFICATION_REFERENCE,
label : 'Product Details',
position: 10
},
{ id :'SupplierDetails',
purpose : #STANDARD,
type :#FIELDGROUP_REFERENCE,
label :'Supplier Details',
position:20
},
{
id :'OrderInfo',
purpose : #STANDARD,
type : #FIELDGROUP_REFERENCE,
label :'Order Information',
position : 30
}
]
@UI:{
lineItem:[ { position :10, importance: #HIGH ,label: 'Product ID'}],
identification:[ { position:10 }]
}
@Search.defaultSearchElement: true
key ProductId,
@UI:{
lineItem :[{ position:20, importance: #HIGH,label:'Product Name'}],
identification:[{ position:20 }],
selectionField:[{ position:20 }]
}
Name,
Prepared by [email protected]
@UI:{
lineItem :[{ position:30, importance: #MEDIUM,label:'Product Description'}],
identification:[{ position:30 }]
}
Description,
@UI:{
lineItem:[{ position:40, importance: #MEDIUM,label:'Product Category'}],
identification:[{ position:40 }]
}
Category,
@UI:{
lineItem:[{ position:50,importance: #HIGH,label:'Product Quantity'}],
identification:[{ position:50 }],
criticalityLabels: [{criticality: #CRITICAL}]
}
Quantiy,
@UI:{
lineItem:[{ position:60,importance: #HIGH,label:'Supplier ID'}],
identification:[{ position:60 }],
fieldGroup:[{ qualifier: 'SupplierDetails',label:'Supplier ID'}]
}
SupplierId,
@UI:{
lineItem:[{ position:70,importance: #HIGH,label:'Supplier Name'}],
identification:[{ position:70 }],
fieldGroup: [{ qualifier: 'SupplierDetails',label:'Supplier Name' }]
}
supplier_name,
@UI:{
lineItem:[{ position:80,importance: #HIGH,label:'Order ID' }],
identification:[{ position:80 }],
fieldGroup:[{ qualifier: 'OrderInfo',label:'Order ID'}]
}
OrderId,
@UI:{
lineItem:[{ position:90,importance: #HIGH,label: 'Order Quantity'}],
identification:[{ position:90 }],
fieldGroup:[{ qualifier:'OrderInfo',label:'Order Quantity'}]
}
OrderQuantity,
@UI:{
lineItem:[{ position:100,importance: #HIGH,label: 'Order Status'}],
Prepared by [email protected]
identification:[{ position:100 }],
fieldGroup:[{ qualifier:'OrderInfo',label:'Order Status'}]
}
Status
}
Customizes the
@UI.dataField: [{ @UI.dataField: [{
@UI.dataField representation of a
label: <String> }] label: 'Name' }]
data field.
@UI.fieldGroup: [{
@UI.fieldGroup: [{ qualifier: Groups related
@UI.fieldGroup qualifier: <String>, 'CategoryGroup', fields under a
label: <String> }] label: 'Category common label.
Details' }]
Prepared by [email protected]
@UI.dataFieldFor: @UI.dataFieldFor:
Assigns fields to a
@UI.dataFieldFor ['<Qualifier>', ['CategoryGroup',
specific group.
'<Field>'] 'Category']
Denotes the
@UI.criticality:
@UI.criticality @UI.criticality: #HIGH importance or
#<Enum>
criticality of a field.
Determines
whether
@AccessControl.a @AccessControl.auth @AccessControl.autho
authorization
uthorizationChec orizationCheck: rizationCheck:
checks are required
k #<Enum> #NOT_REQUIRED
for accessing the
data.
@UI.headerInfo: {
Defines the header
typeName: 'Product',
@UI.headerInfo: information of the
typeNamePlural:
@UI.headerInfo {<Header Info view, including the
'Products', title: { type:
Attributes>} type name and title
#STANDARD, value:
field.
'ProductId' } }
Prepared by [email protected]