Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

convert non-performant ABAP code to CDS View

jan_dahl
Participant
0 Likes
1,575

I would like to convert this low performant ABAP code into a performant CDS view.

Actually the SQL-Query below is running in a loop for each partner/contract.

I would like to replace it by a CDS view but fail on the "if not this, try next" part. The view should have one line for each partner/contract from the first where condition that works. Any idea? We are running on non-Hana 7.50.

*   laufende ZMOD Stundung oder Mindestbeitrag suchen
select single *
from zcd_zmod
into ls_zmod
where insobject eq i_vtref and
partner eq i_partner and
zzzmod_zeitr_von le sy-datum and
zzzmod_zeitr_bis ge sy-datum and
( zzzmod_stat eq 'B' or
zzzmod_stat eq 'E' ).

if sy-subrc ne 0.
* zukünftig anlaufende ZMOD suchen
select single *
from zcd_zmod
into ls_zmod
where insobject eq i_vtref and
partner eq i_partner and
zzzmod_zeitr_von ge sy-datum and
zzzmod_zeitr_bis ge sy-datum and
zzzmod_stat eq 'B'.

if sy-subrc ne 0.
* Angebot suchen
select *
from zcd_zmod
into ls_zmod
where insobject eq i_vtref and
partner eq i_partner and
zzzmod_zeitr_bis ge sy-datum and
zzzmod_stat eq 'A'
order by zzzmod_zeitr_bis descending.
exit.
endselect.
endif.
endif.

I would like to convert this low performant ABAP code into a performant CDS view.

Actually the SQL-Query below is running in a loop for each partner/contract.

I would like to replace it by a CDS view but fail on the "if not this, try next" part. The view should have one line for each partner/contract from the first where condition that works. Any idea? We are running on non-Hana 7.50.

*   laufende ZMOD Stundung oder Mindestbeitrag suchen
select single *
from zcd_zmod
into ls_zmod
where insobject eq i_vtref and
partner eq i_partner and
zzzmod_zeitr_von le sy-datum and
zzzmod_zeitr_bis ge sy-datum and
( zzzmod_stat eq 'B' or
zzzmod_stat eq 'E' ).

if sy-subrc ne 0.
* zukünftig anlaufende ZMOD suchen
select single *
from zcd_zmod
into ls_zmod
where insobject eq i_vtref and
partner eq i_partner and
zzzmod_zeitr_von ge sy-datum and
zzzmod_zeitr_bis ge sy-datum and
zzzmod_stat eq 'B'.

if sy-subrc ne 0.
* Angebot suchen
select *
from zcd_zmod
into ls_zmod
where insobject eq i_vtref and
partner eq i_partner and
zzzmod_zeitr_bis ge sy-datum and
zzzmod_stat eq 'A'
order by zzzmod_zeitr_bis descending.
exit.
endselect.
endif.
endif.
0 REPLIES 0