@AbapCatalog.sqlViewName: 'ATO_V_CV'
@ClientHandling:{ type: #INHERITED, algorithm: #SESSION_VARIABLE }
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Collection Version'
define view ATOV_COL_VER
// Usage only for Export => now it is not performance optimizied for 0 version;
// Any Chnge with Memory Consumption Impact have to be measured
as
select from ATOV_COL_VER_BASE as Collection_Version_Key
association [*] to ATOV_EXPORT_LOG as Effective_Export_Logs on Effective_Export_Logs.collection_id = Collection_Version_Key.collection_id
and Effective_Export_Logs.collection_version = Collection_Version_Key.collection_version
association [0..1] to ATOV_COL_VER_COUNT_CHANGE as Change_and_Delete_Count on Change_and_Delete_Count.collection_id = Collection_Version_Key.collection_id
and Collection_Version_Key.is_latest_version = #ABAP_BOOLEAN.'X'
association [0..1] to ATOV_COL_EXP_NUM_CURRENT_ITEMS as Current_Item_Count on Current_Item_Count.collection_id = Collection_Version_Key.collection_id
and Collection_Version_Key.is_latest_version = #ABAP_BOOLEAN.'X'
association [1] to ATOV_COL_VER_EXP_COUNT_LOGS as Effective_Export_Log_Counter on Effective_Export_Log_Counter.collection_id = Collection_Version_Key.collection_id
and Effective_Export_Log_Counter.collection_version = Collection_Version_Key.collection_version
association [0..1] to ATOV_Cl as Latest_Change_List on Latest_Change_List.collection_id = Collection_Version_Key.collection_id
and Latest_Change_List.collection_version = Collection_Version_Key.collection_version
and Latest_Change_List.is_latest_change_list = 'X'
association [1] to ATOV_COL as Collection on Collection.collection_id = Collection_Version_Key.collection_id
association [*] to ATOV_COL_VER as Collection_Version_Siblings on Collection_Version_Siblings.collection_id = Collection_Version_Key.collection_id
association [0..1] to Atov_Col_Cart_Count_Items as Cart_Item_Count on Cart_Item_Count.collection_id = Collection_Version_Key.collection_id
association [*] to ATOV_TEXT_COLLECTION_STATUS as Status_Texts on Status_Texts.code = status
association [*] to ATOV_TEXT_ACTION as Latest_Action_Texts on Latest_Action_Texts.code = latest_action
association [*] to ATOV_TEXT_ACTION_STATUS as Latest_Action_Status_Texts on Latest_Action_Status_Texts.code = latest_action_status
association [1] to ATOV_USER as Changed_By_Description on Changed_By_Description.name = changed_by
association [*] to ATOV_COL_MERGE as Collection_Merge on Collection_Version_Key.collection_id = Collection_Merge.CollectionId
and Collection_Version_Key.collection_version = Collection_Merge.CollectionVersion
association [*] to ATOV_COL_NOTES as Notes on Notes.collection_id = Collection_Version_Key.collection_id
and Notes.collection_version = Collection_Version_Key.collection_version
association [1] to ATOV_COL_VER_COUNT_NOTES as Notes_Counter on Notes_Counter.collection_id = Collection_Version_Key.collection_id
and Notes_Counter.collection_version = Collection_Version_Key.collection_version
association [1] to ATOV_COL_VER_EXP_ITEM_COUNTER as Exported_Items_Counter on Exported_Items_Counter.collection_id = Collection_Version_Key.collection_id
and Exported_Items_Counter.collection_version = Collection_Version_Key.collection_version
{
key Collection_Version_Key.collection_id,
key Collection_Version_Key.collection_version,
Collection_Version_Key.timestamp, //Currently timestamp is always 0 => to be removed
Collection_Version_Key.is_latest_version,
case
//calculate "scheduled" status
when Collection_Version_Key.action_status = 'P' then
case Collection_Version_Key.action
when 'I' then 'S' //Import Scheduled
when 'C' then 'X'
when 'A' then 'Y'
else Collection_Version_Key.status
end
else
//calculate "running" status
case when Collection_Version_Key.action_status = 'R' then
case Collection_Version_Key.action
when 'C' then 'X'
when 'A' then 'Y'
when 'I' then 'Z'
else Collection_Version_Key.status
end
else
//calculate "changes exist" status is only relevant for current in Development Version
case when Collection_Version_Key.status = 'D' then
case coalesce(Change_and_Delete_Count.number_of_changes,0)
when 0 then 'N'
else 'C'
end
else
Collection_Version_Key.status
end
end
end as status,
Effective_Export_Logs.ballog_handle as latest_ballog_handle,
//Calculate "latest action"
case Collection_Version_Key.change_type
when 'item_assignment' then 'X'
when 'action' then Collection_Version_Key.action
else case Collection_Version_Key.status
when 'R' then 'R'
when 'O' then 'O'
else 'N'
end
end as latest_action,
//Calculate "latest action variant"
case when Collection_Version_Key.change_type = 'action'
then Collection_Version_Key.action_variant
else ''
end as latest_action_variant,
//Calculate "latest action status"
case when Collection_Version_Key.change_type = 'action'
then Collection_Version_Key.action_status
else 'S'
end as latest_action_status,
//Calculate "latest action duration"
case when Collection_Version_Key.change_type = 'action'
then Collection_Version_Key.action_duration
else 0
end as latest_action_duration,
//Calculate "changed by"
case when Collection_Version_Key.change_type = 'item_assignment'
then Collection_Version_Key.item_assigned_by
else Collection_Version_Key.action_executed_by
end as changed_by,
//Calculate "changed at"
case when Collection_Version_Key.change_type = 'item_assignment'
then Collection_Version_Key.item_assigned_at
else Collection_Version_Key.action_executed_at
end as changed_at,
// Number of items in cart:
case Collection_Version_Key.is_latest_version
when 'X' then coalesce(Cart_Item_Count.num_items, 0)
else 0
end as num_cart_items,
case Collection_Version_Key.is_latest_version
// only for the latest version (in development or Checked) this is calculated via Current View
when 'X' then coalesce(Current_Item_Count.changed_items_count , 0)
// at export the count of all items which are in the collection is stored
else coalesce(Exported_Items_Counter.number_of_items , 0)
end as num_col_items,
case
when Collection.collection_type is not null and
Collection.collection_type != ''
then Collection.collection_type
else
case Collection.category when 'B'
then cast('B' as ato_collection_type preserving type)
else cast('E' as ato_collection_type preserving type)
end
end as collection_type,
/* Associations */
Collection,
Collection_Version_Siblings,
Effective_Export_Logs,
Effective_Export_Log_Counter,
Latest_Change_List,
Status_Texts,
Changed_By_Description,
Latest_Action_Texts,
Latest_Action_Status_Texts,
Collection_Merge,
Notes,
coalesce(Notes_Counter.no_of_notes , 0) as num_col_notes
}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"ATOV_COL",
"ATOV_COL_CART_COUNT_ITEMS",
"ATOV_COL_EXP_NUM_CURRENT_ITEMS",
"ATOV_COL_VER_BASE",
"ATOV_COL_VER_COUNT_CHANGE",
"ATOV_COL_VER_COUNT_NOTES",
"ATOV_COL_VER_EXP_ITEM_COUNTER",
"ATOV_EXPORT_LOG"
],
"ASSOCIATED":
[
"ATOV_CL",
"ATOV_COL",
"ATOV_COL_CART_COUNT_ITEMS",
"ATOV_COL_EXP_NUM_CURRENT_ITEMS",
"ATOV_COL_MERGE",
"ATOV_COL_NOTES",
"ATOV_COL_VER_COUNT_CHANGE",
"ATOV_COL_VER_COUNT_NOTES",
"ATOV_COL_VER_EXP_COUNT_LOGS",
"ATOV_COL_VER_EXP_ITEM_COUNTER",
"ATOV_EXPORT_LOG",
"ATOV_TEXT_ACTION",
"ATOV_TEXT_ACTION_STATUS",
"ATOV_TEXT_COLLECTION_STATUS",
"ATOV_USER"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/