Skip to content

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

Closed
wants to merge 0 commits into from
Closed

feat: calculate virtual elements for CDS Views #13

wants to merge 0 commits into from

Conversation

reichr-dev
Copy link
Contributor

No description provided.

@reichr-dev
Copy link
Contributor Author

Resolves Issue #12

@stockbal stockbal linked an issue Mar 21, 2021 that may be closed by this pull request
@stockbal stockbal self-assigned this Mar 21, 2021
@stockbal stockbal self-requested a review March 21, 2021 20:32
Copy link
Member

@stockbal stockbal left a 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.
Copy link
Member

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

Comment on lines 614 to 640
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.
Copy link
Member

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

Comment on lines 623 to 624
CREATE DATA lr_t_calc_data TYPE HANDLE lo_table_type.
ASSIGN lr_t_calc_data->* TO <lt_calculated_data>.
Copy link
Member

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?

@reichr-dev reichr-dev closed this Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CDS View -Virtual Elements empty
2 participants