
@EndUserText.label : 'Product details'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zproduct_details {
key client : abap.clnt not null;
key p_id : sysuuid_x16 not null;
p_name : abap.char(50);
p_cat : abap.char(30);
supplier : abap.char(10);
rating : abap.int1;
cuky_field : abap.cuky;
@Semantics.amount.currencyCode : 'zproduct_details.cuky_field'
price : abap.curr(10,2);
available_p : abap.int1;
}
@EndUserText.label : 'Media Details'
@AbapCatalog.enhancementCategory : #NOT_CLASSIFIED
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #DISPLAY
define table zfile {
key mandt : mandt not null;
@EndUserText.label : 'Filename'
key filename : abap.char(100) not null;
@EndUserText.label : 'Date'
sdate : abap.dats;
@EndUserText.label : 'Time'
stime : abap.tims;
@EndUserText.label : 'Extension'
mime_type : abap.char(20);
value : xstringval;
}
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Product details'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}
@Metadata.allowExtensions: true
@Search.searchable: true
define root view entity zi_product_details
as select from zproduct_details
{
key p_id as PId,
@Search:{ defaultSearchElement: true,
fuzzinessThreshold: 0.9,
ranking: #MEDIUM}
p_name as PName,
@Search:{ defaultSearchElement: true,
fuzzinessThreshold: 0.9,
ranking: #MEDIUM}
p_cat as PCat,
supplier as Supplier,
rating as Rating,
cuky_field as CukyField,
@Semantics.amount.currencyCode: 'CukyField'
price as Price,
available_p as Available,
@Semantics.imageUrl: true
cast(concat( concat('https://<<System>>:<<PORT>>/sap/opu/odata/SAP/ZSTREAM_OPERATION_SRV/zfileSet
(Mandt=''500'',Filename=',''),concat('''',concat(p_name,''')/$value') ) )
as abap.char( 256 ) ) as P_Image_URL
@Metadata.layer: #CORE
@UI: {
headerInfo: {
typeName: 'Product Details',
typeNamePlural: 'Products',
title: { value: 'PName'}}}
annotate view zi_product_details with
{
@UI.facet: [
{ id: 'Colleact',type: #COLLECTION,position: 10,purpose: #STANDARD,label: 'Product details' },
{ id: 'ID1',parentId: 'Colleact',type: #IDENTIFICATION_REFERENCE,position: 20,purpose: #STANDARD },
{ id: 'HeaderIno' ,type: #DATAPOINT_REFERENCE,purpose: #HEADER,targetQualifier: 'Rating' }]
@UI.hidden: true
PId;
@UI:{lineItem: [{ position: 10,label: ' ',cssDefault.width: '15rem'}],
identification: [{ position: 10,label: 'Product Image' }]}
P_Image_URL;
@UI:{lineItem: [{ position: 20,label: 'Product'}],
identification: [{ position: 20,label: 'Product' }]}
PName;
@UI:{lineItem: [{ position: 30,label: 'Category'}],
selectionField: [{ position: 20 }],
identification: [{ position: 30,label: 'Category' }]}
@EndUserText.label: 'Category'
PCat;
@UI:{lineItem: [{ position: 40,label: 'Supplier'}],
selectionField: [{ position: 30 }],
identification: [{ position: 40,label: 'Supplier' }]}
@EndUserText.label: 'Supplier'
Supplier;
@UI:{lineItem: [{ position: 50,label: 'Average Ratings', type: #AS_DATAPOINT}],
selectionField: [{ position: 40}],
identification: [{ position: 50,label: 'Ratings' ,type: #AS_DATAPOINT}]}
@UI.dataPoint:{ visualization: #RATING }
@UI.selectionField: [{qualifier: 'Rating1'}]
Rating;
@UI:{identification: [{ position: 60,label: 'Currency' }]}
CukyField;
@UI:{lineItem: [{ position: 60,label: 'Product Price' }],
identification:[{ position: 70,label: 'Product Price' }]}
Price;
@UI:{lineItem: [{ position: 70,label: 'Available Product' }]}
Available;
}
@UI.identification.type : #AS_DATAPOINT is used to display in the object page
method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_STREAM.
data : ls_file type ZCL_ZSTREAM_OPERATION_mPC_EXT=>ts_zfile." Data Provider Secondary Class
ls_file-filename = iv_slug.
ls_file-mandt = sy-mandt.
ls_file-sdate = sy-datum.
ls_file-stime = sy-uzeit.
ls_file-mime_type = is_media_resource-mime_type.
ls_file-value = is_media_resource-value.
INSERT INTO zfile VALUES ls_file.
IF sy-subrc = 0.
copy_data_to_ref(
EXPORTING
is_data = ls_file
CHANGING
cr_data = er_entity
).
ENDIF.
endmethod.
METHOD /iwbep/if_mgw_appl_srv_runtime~get_stream.
DATA : ls_file TYPE zcl_zstream_operation_mpc_ext=>ts_zfile.
DATA : ls_stream TYPE ty_s_media_resource.
ASSIGN it_key_tab[ name = 'Filename' ] TO FIELD-SYMBOL(<lfs>).
IF <lfs> IS ASSIGNED.
SELECT SINGLE * FROM zfile INTO ls_file WHERE filename = <lfs>-value.
IF sy-subrc = 0.
ls_stream-mime_type = ls_file-mime_type.
ls_stream-value = ls_file-value.
copy_data_to_ref(
EXPORTING
is_data = ls_stream
CHANGING
cr_data = er_stream
).
ENDIF.
ENDIF.
ENDMETHOD.
managed implementation in class zbp_i_product_details unique;
strict ( 2 );
define behavior for zi_product_details //alias <alias_name>
persistent table zproduct_details
lock master
authorization master ( instance )
//etag master <field_name>
{
create;
update;
delete;
field ( numbering : managed, readonly ) PId;
mapping for zproduct_details
{
PId = p_id;
PName = p_name;
PCat = p_cat;
Supplier = supplier;
Rating = rating;
CukyField = cuky_field;
Price = price;
Available = available_p;
}
}
CLASS lhc_zi_product_details DEFINITION INHERITING FROM cl_abap_behavior_handler.
PRIVATE SECTION.
METHODS get_instance_authorizations FOR INSTANCE AUTHORIZATION
IMPORTING keys REQUEST requested_authorizations FOR zi_product_details RESULT result.
ENDCLASS.
CLASS lhc_zi_product_details IMPLEMENTATION.
METHOD get_instance_authorizations.
ENDMETHOD.
ENDCLASS.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |