SAP Cloud Platform, ABAP Environment is the SAP Platform-as-a-Service (PaaS) offering for ABAP development that enables developers to leverage their traditional on-premise ABAP know-how to develop and run ABAP applications in the SAP Cloud Platform, either as extension to SAP software or as standalone applications.
ZLOCAL
and select ABAP Package.ZREPORT_PO
PO Report Package
PO Report
" and optionally you can add this package to favorite packages to access it easily by (Right-click on Favorite Packages and select Add Package and choose the created one .ZREPORT_PO
, select New > Other ABAP Repository Object.ZPOHEAD
PO HEAD
@EndUserText.label : 'POHEAD'
@AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #LIMITED
define table zpohead {
key client : abap.clnt not null;
key po_order : abap.char(10) not null;
comp_code : abap.char(4);
doc_type : abap.char(4);
vendor : abap.numc(10);
status : abap.char(4);
created_by : syuname;
created_at : timestampl;
}
ZPOITEMS
PO ITEMS
@EndUserText.label : 'POITEMS'
@AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #LIMITED
define table zpoitems {
key client : abap.clnt not null;
key po_order : abap.char(10) not null;
key order_item : abap.numc(4) not null;
unit : abap.unit(3);
@Semantics.quantity.unitOfMeasure : 'zpoitems.unit'
quantity : abap.quan(10,3);
}
ZREPORT_PO
, select New > ABAP Class.zcl_po_generate_data
Class for generating PO data
CLASS zcl_po_generate_data DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_po_generate_data IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DATA:itab TYPE TABLE OF zpohead,
itab2 TYPE TABLE OF ZPOITEMS.
* read current timestamp
GET TIME STAMP FIELD DATA(ztime).
* fill internal PO Header internal table (itab)
itab = VALUE #(
( po_order = '0000000001' comp_code = 'test' doc_type ='ZMM1' vendor = '0010000000' status = 'P' created_by = 'user1' created_at = ztime )
( po_order = '0000000002' comp_code = 'test' doc_type ='ZMM2' vendor = '0010000001' status = 'C' created_by = 'user2' created_at = ztime )
( po_order = '0000000003' comp_code = 'test' doc_type ='ZMM3' vendor = '0010000002' status = 'D' created_by = 'user2' created_at = ztime )
) .
* fill internal PO Items internal table (itab2)
itab2 = VALUE #(
( po_order = '0000000001' order_item = '10' unit = 'PC' quantity = '5' )
( po_order = '0000000002' order_item = '10' unit = 'KG' quantity = '30.1' )
( po_order = '0000000002' order_item = '20' unit = 'KG' quantity = '20.2' )
) .
* insert the table entries
INSERT zpohead FROM TABLE @itab.
INSERT zpoitems FROM TABLE @itab2.
out->write( 'PO data inserted successfully!').
ENDMETHOD.
ENDCLASS.
F9
to run your ABAP class.F8
to see your data.ZREPORT_PO
, select New > Other ABAP Repository Object.Z_R_ITEMS
PO Items Data Model
@AbapCatalog.sqlViewName: 'ZVRI_MODEL'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'PO Items Data Model'
define view Z_R_ITEMS as select from zpoitems {
@UI: {lineItem: [{ position: 10 }]}
@EndUserText.label: 'Purchasing Document'
key po_order,
@UI: {lineItem: [{ position: 20 }]}
@EndUserText.label: 'Item'
key order_item,
@UI: {lineItem: [{ position: 30 }]}
@EndUserText.label: 'Unit'
unit,
@UI: {lineItem: [{ position: 40 }]}
@EndUserText.label: 'Quantity'
quantity
}
Z_R_MODEL
PO Items Data Model
@AbapCatalog.sqlViewName: 'ZVR_MODEL'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'PO Data Model'
define root view Z_R_MODEL as select from zpohead
association [1..*] to Z_R_ITEMS as items on $projection.po_order = items.po_order {
//zpohead
key po_order,
comp_code,
doc_type,
vendor,
status,
created_by,
created_at,
items
}
ZREPORT_PO
, select New > Other ABAP Repository Object.ZPR_VIEW
PO Projection View
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'PO Projection View'
@UI: {
headerInfo: { typeName: 'Purchasing Order Details', typeNamePlural: 'Purchasing Orders' }
}
define root view entity ZPR_VIEW as projection on Z_R_MODEL {
@UI.facet: [ { id: 'POHeader',
type: #IDENTIFICATION_REFERENCE,
label: 'PO Header',
position: 10,
purpose: #STANDARD
},
{ id: 'Item',
purpose: #STANDARD,
type: #LINEITEM_REFERENCE,
label: 'Items',
targetElement: 'items',
position: 20
}
]
@UI: {
lineItem: [ { position: 10, importance: #HIGH } ] , selectionField: [ { position: 10 }] , identification: [ { position: 10} ]}
@Search.defaultSearchElement: true
@EndUserText.label: 'Purchasing Document'
key po_order,
@UI: {
lineItem: [ { position: 20, importance: #HIGH } ] , selectionField: [ { position: 20 }], identification: [ { position: 20} ] }
@EndUserText.label: 'Company Code'
@Search.defaultSearchElement: true
comp_code,
@UI: {
lineItem: [ { position: 30, importance: #HIGH } ] , selectionField: [ { position: 30 }], identification: [ { position: 30} ]}
@EndUserText.label: 'Document Type'
@Search.defaultSearchElement: true
doc_type,
@UI: {
lineItem: [ { position: 40, importance: #HIGH } ]}
@EndUserText.label: 'Vendor'
vendor,
@UI: {
lineItem: [ { position: 50, importance: #HIGH } ]}
@EndUserText.label: 'Status'
status,
@UI: {
lineItem: [ { position: 60, importance: #HIGH } ]}
@EndUserText.label: 'Created By'
created_by,
@UI: {
lineItem: [ { position: 70, importance: #HIGH } ]}
@EndUserText.label: 'Created At'
created_at ,
items
}
ZPR_VIEW
and select New Service Definition.ZR_SERV
PO Report Service Definiton
@EndUserText.label: 'PO Report Service Definiton'
define service ZR_SERV {
expose ZPR_VIEW;
expose Z_R_ITEMS;
}
ZR_SERV
and select New Service Binding.ZR_SERV_B
PO Report Service Binding
ODATA V2 - UI
ZPR_VIEW
to see our SAP Fiori Elements Application on the UI.You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |