-
Notifications
You must be signed in to change notification settings - Fork 8
feat: calculate virtual elements for CDS Views #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Resolves Issue #12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess all in all the coding assumes that there is only one calculated field in the view. Then it would work
CATCH cx_sy_create_object_error | ||
cx_sy_ref_is_initial | ||
cx_sy_dyn_call_error | ||
cx_sadl_exit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the exception cx_sadl_exit
does not exist in v7.50 so I gues we have to use cx_root
in this case to also catch any exception that happen in the calculate
call
LOOP AT lt_virtual_elems ASSIGNING FIELD-SYMBOL(<ls_virtual_elem>). | ||
|
||
TRY. | ||
CREATE OBJECT lo_calculated_by TYPE (<ls_virtual_elem>-value+5). | ||
|
||
create_virtual_elem_table_type( | ||
EXPORTING iv_virtual_elem = <ls_virtual_elem>-fieldname | ||
IMPORTING eo_table_type = DATA(lo_table_type) ). | ||
|
||
CREATE DATA lr_t_calc_data TYPE HANDLE lo_table_type. | ||
ASSIGN lr_t_calc_data->* TO <lt_calculated_data>. | ||
|
||
CALL METHOD lo_calculated_by->('IF_SADL_EXIT_CALC_ELEMENT_READ~CALCULATE') | ||
EXPORTING | ||
it_original_data = <lt_selected_data> | ||
it_requested_calc_elements = VALUE if_sadl_exit_calc_element_read=>tt_elements( ( CONV #( <ls_virtual_elem>-fieldname ) ) ) | ||
CHANGING | ||
ct_calculated_data = <lt_calculated_data>. | ||
|
||
CATCH cx_sy_create_object_error | ||
cx_sy_ref_is_initial | ||
cx_sy_dyn_call_error | ||
cx_sadl_exit. | ||
RETURN. | ||
ENDTRY. | ||
|
||
ENDLOOP. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not quite sure how the SADL
engine is handling this, but wouldn't it be better to group the calculcation by exit-class?
Example:
...
@ObjectModel.virtualElementCalculatedBy: 'ABAP:CL_EXIT'
cast( '' as ztype ) as VirtualField1,
@ObjectModel.virtualElementCalculatedBy: 'ABAP:CL_EXIT'
cast( '' as ztype2 ) as VirtualField2,
@ObjectModel.virtualElementCalculatedBy: 'ABAP:CL_EXIT2'
cast( '' as ztype3 ) as VirtualField3,
...
So in this example there would be one call to CL_EXIT
where the fields VirtualField1
and VirtualField2
are filled and one call to CL_EXIT2
where the field VirtualField3
is filled
CREATE DATA lr_t_calc_data TYPE HANDLE lo_table_type. | ||
ASSIGN lr_t_calc_data->* TO <lt_calculated_data>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this automatically override the calculated data from the previous iteration?
No description provided.