Hello everyone,
@AbapCatalog.sqlViewName: 'ZDEMOPRODUCTION'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Production Place Products And Costs View'
define view ZDEMO_PRODUCTION_CDS
as select from zdm_producion_iy
{
key production_place_id as ProductionPlaceId,
key product_id as ProductId,
production_place_text as ProductionPlaceText
}
3. Creating AMDP
CLASS zdemo_products_cl IMPLEMENTATION.
METHOD get_products BY DATABASE FUNCTION FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING zdm_products_iy.
t_main = select z.mandt,
z.product_id,
z.product_name,
LTRIM( z.product_quantity, '0' ) as product_quantity,
LTRIM( z.purchase_price, '0' ) as purchase_price,
LTRIM( z.selling_price, '0' ) as selling_price,
z.production_start_date,
z.production_end_date
from zdm_products_iy as z
where z.mandt = clnt;
t_row_number = select
row_number( ) over ( order by t.product_quantity asc ) as row_number,
t.*
from :t_main as t;
return select mandt,
product_id,
product_name,
product_quantity,
purchase_price,
selling_price,
production_start_date,
production_end_date,
row_number
from :t_row_number;
endmethod.
ENDCLASS.
t_main = select z.mandt,
z.product_id,
z.product_name,
LTRIM( z.product_quantity, '0' ) as product_quantity,
LTRIM( z.purchase_price, '0' ) as purchase_price,
LTRIM( z.selling_price, '0' ) as selling_price,
z.production_start_date,
z.production_end_date,
ROW_NUMBER ( ) OVER( ORDER BY "PRODUCT_QUANTITY" asc ) AS "ROW_NUMBER"
from zdm_products_iy as z
where z.mandt = clnt;
return select mandt,
product_id,
product_name,
product_quantity,
purchase_price,
selling_price,
production_start_date,
production_end_date,
row_number
from :t_main;
t_row_number = select
row_number( ) over ( order by t.product_quantity asc , t.product_id asc ) as row_number,
t.*
from :t_main as t;
t_row_number = select
row_number( ) over ( PARTITION BY t.product_quantity ORDER BY t.product_id asc ) as row_number_partion_by,
t.*
from :t_main as t;
t_main = select z.mandt,
z.product_id,
z.product_name,
LTRIM( z.product_quantity, '0' ) as product_quantity,
LTRIM( z.purchase_price, '0' ) as purchase_price,
LTRIM( z.selling_price, '0' ) as selling_price,
z.production_start_date,
z.production_end_date,
ROW_NUMBER ( ) OVER( PARTITION BY "PRODUCT_QUANTITY" ) AS "ROW_NUMBER_PARTION_BY"
from zdm_products_iy as z
where z.mandt = clnt;
return select mandt,
product_id,
product_name,
product_quantity,
purchase_price,
selling_price,
production_start_date,
production_end_date,
row_number_partion_by
from :t_main;
t_row_number = select
row_number( ) over ( PARTITION BY t.product_quantity ORDER BY t.product_id asc ) as row_number_partion_by,
t.*
from :t_main as t;
return select mandt,
product_id,
product_name,
product_quantity,
purchase_price,
selling_price,
production_start_date,
production_end_date,
row_number_partion_by
from :t_row_number
where row_number_partion_by = 1;
t_main = select z.mandt,
z.product_id,
z.product_name,
LTRIM( z.product_quantity, '0' ) as product_quantity,
LTRIM( z.purchase_price, '0' ) as purchase_price,
LTRIM( z.selling_price, '0' ) as selling_price,
z.production_start_date,
z.production_end_date,
ROW_NUMBER ( ) OVER( PARTITION BY "PRODUCT_QUANTITY" ) AS "ROW_NUMBER_PARTION_BY"
from zdm_products_iy as z
where z.mandt = clnt;
return select mandt,
product_id,
product_name,
product_quantity,
purchase_price,
selling_price,
production_start_date,
production_end_date,
row_number_partion_by
from :t_main
where row_number_partion_by = 1;
t_row_number = select
RANK ( ) OVER( ORDER BY product_quantity asc ) as rank,
t.*
from :t_main as t;
t_main = select z.mandt,
z.product_id,
z.product_name,
LTRIM( z.product_quantity, '0' ) as product_quantity,
LTRIM( z.purchase_price, '0' ) as purchase_price,
LTRIM( z.selling_price, '0' ) as selling_price,
z.production_start_date,
z.production_end_date,
RANK( ) OVER( ORDER BY "PRODUCT_QUANTITY" asc ) AS "RANK",
from zdm_products_iy as z
where z.mandt = clnt;
return select mandt,
product_id,
product_name,
product_quantity,
purchase_price,
selling_price,
production_start_date,
production_end_date,
rank
from :t_main;
t_row_number = select
DENSE_RANK ( ) OVER( ORDER BY product_quantity asc ) as dense_rank,
t.*
from :t_main as t;
t_main = select z.mandt,
z.product_id,
z.product_name,
LTRIM( z.product_quantity, '0' ) as product_quantity,
LTRIM( z.purchase_price, '0' ) as purchase_price,
LTRIM( z.selling_price, '0' ) as selling_price,
z.production_start_date,
z.production_end_date,
DENSE_RANK ( ) OVER( ORDER BY "PRODUCT_QUANTITY" asc ) AS "DENSE_RANK"
from zdm_products_iy as z
where z.mandt = clnt;
return select mandt,
product_id,
product_name,
product_quantity,
purchase_price,
selling_price,
production_start_date,
production_end_date,
dense_rank
from :t_main;
CLASS zdemo_products_cl IMPLEMENTATION.
METHOD get_products BY DATABASE FUNCTION FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING zdm_products_iy.
t_main = select z.mandt,
z.product_id,
z.product_name,
LTRIM( z.product_quantity, '0' ) as product_quantity,
LTRIM( z.purchase_price, '0' ) as purchase_price,
LTRIM( z.selling_price, '0' ) as selling_price,
z.production_start_date,
z.production_end_date,
ROW_NUMBER ( ) OVER( ORDER BY "PRODUCT_QUANTITY" asc ) AS "ROW_NUMBER",
RANK( ) OVER( ORDER BY "PRODUCT_QUANTITY" asc ) AS "RANK",
DENSE_RANK ( ) OVER( ORDER BY "PRODUCT_QUANTITY" asc ) AS "DENSE_RANK"
from zdm_products_iy as z
where z.mandt = clnt;
return select mandt,
product_id,
product_name,
product_quantity,
purchase_price,
selling_price,
production_start_date,
production_end_date,
row_number,
rank,
dense_rank
from :t_main;
endmethod.
ENDCLASS.
@AbapCatalog.sqlViewName: 'ZDEMOPRODUCTION'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Production Place Products And Costs View'
define view ZDEMO_PRODUCTION_CDS
as select from zdm_producion_iy as m
inner join ZDEMO_PRODUCTS_TABLE_FUNCTION(clnt : $session.client) as t on m.product_id = t.product_id
{
key m.product_id as ProductId,
key m.production_place_id as ProductionPlaceId,
m.production_place_text as ProductionPlace,
t.product_name as ProductName,
t.product_quantity as ProductQuantity,
t.purchase_price as PurchasePrc,
t.selling_price as SellingPrc,
t.production_start_date as StartDate,
t.production_end_date as EndDate,
t.row_number,
t.rank,
t.dense_rank
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
4 | |
3 | |
3 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |