Application Development 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: 

Is there a mass syntax check for CDS Views?

sap_cohort
Active Contributor

Hi all,
We just did an upgrade and found a few CDS Views that have syntax errors and generate an error when called.
I'm sure it's due to more strict syntax checking.
I'm looking if anyone knows of a way to do a mass syntax check on CDS Views after an upgrade?

Thanks!

1 ACCEPTED SOLUTION

sap_cohort
Active Contributor
0 Kudos

Hi Team,

Found out this is due to stricter syntax checking and the upgrade phases do not take the source code errors into account. They do get activated but still show error in the DDLS in editor.

ATC and SDDLAR do not report the CDS DDLS Errors as well.

The reason the report fails during runtime is that BI runtime (Analytical Mgr) has higher requirements than the upgrade phase currently does.

SAP is working on a fix for this. Thanks for your support and ideas.

11 REPLIES 11

Sandra_Rossi
Active Contributor
0 Kudos

If you're lucky, maybe there is a utility program with name prefixed with RUTDDLS, because I used 2 of them which were very useful to force activation and deletion, so maybe there's one for mass check.

In case RUTDDLSACT can just do a check (?), you might create your own program to call it repeatedly for all CDS views you want.

EDIT: RUTDDLSSTATISTICS_INT runs the syntax check on CDS views and works well in my system (7.52).

Or use CL_DD_DDL_HANDLER_FACTORY=>CREATE, you have the method IF_DD_DDL_HANDLER~CHECK (no idea if it's a syntax check). EDIT: yes, CHECK does a syntax check, see code snippet in comment.

The list of CDS views can be queried by using select * from cds_views_info.

Short code to identify erroneous CDS views, display them through RUTDDLSSHOW, whose check button can be used to see the errors (one CDS view at a time).

REPORT.
DATA(dummy_ddl_name) = VALUE ddlname( ).
SELECT-OPTIONS ddlnames FOR dummy_ddl_name DEFAULT 'Z*' OPTION CP.
TYPES ty_range_ddl_names TYPE RANGE OF ddlname.
SELECT obj_name
    FROM tadir
    WHERE pgmid = 'R3TR'
      AND object = 'DDLS'
      AND obj_name IN @ddlnames[]
    INTO TABLE @DATA(tadir_lines).
DATA(range_ddl_names_with_error) = VALUE ty_range_ddl_names( ).
LOOP AT tadir_lines REFERENCE INTO DATA(tadir_line).
  DATA(ddl_name) = EXACT ddlname( tadir_line->obj_name ).
  DATA(ddls) = cl_dd_ddl_handler_factory=>create( ).
  TRY.
      ddls->check( name = ddl_name ).
    CATCH cx_dd_ddl_check INTO DATA(lx_check).
      range_ddl_names_with_error = VALUE #( BASE range_ddl_names_with_error ( sign = 'I' option = 'EQ' low = ddl_name ) ).
* DATA(errors) = lx_check->get_errors( ). " <=== you may complete that code to display all errors
  ENDTRY.
ENDLOOP.
IF range_ddl_names_with_error IS NOT INITIAL.
  SUBMIT rutddlsshow WITH sn IN range_ddl_names_with_error AND RETURN. " <=== display has button to show errors
ENDIF.

sap_cohort
Active Contributor
0 Kudos

Thanks for the info.

Checked RUTDDLSACT and only provides activate.
I did find some DDLS Check method in Class cl_dd_ddl_handler as you mention and this would work for a new check program we could write.

I'm wondering why SAP would not provide a tool like this for checking DDLS after upgrades?
Any thoughts on this?


Without a tool for this it seems we would have to check every provider/report for a runtime error.
Are we supposed to just go out and manually check all reports for runtime errors?

Just curious anyones thoughts on why there wouldn't be a tool.
Is there a post process after upgrade that already does this an Basis didn't pick up on this?
> Thanks for any input. Greatly appreciated!

BTW: I found the issue in our upgraded system was having a space before a Parameter/Entity name in one of our annotations. This worked before the upgrade. See example below:

@Consumption.derivation.binding: [{targetParameter: ' P_FISCYEAR'... 
vs
@Consumption.derivation.binding: [{targetParameter: 'P_FISCYEAR'...

0 Kudos

Thanks for the feedback.

keremkoseoglu
Contributor

If you want to check your custom CDS views, you can simply right-click your Z-packages in Eclipse and select Run As - ABAP Test Cockpit. This will run an ATC check on all objects within - including CDS views - and catch syntax errors too.

larshp
Active Contributor

sap_cohort
Active Contributor
0 Kudos

Thanks all for the responses. Greatly appreciated!
I'll review Kerem's response to review the Z Packages with ATC Cockpit Run as...

Still would like someones opinion on why SAP wouldn't make this part of the upgrade process?
If it is documented somewhere to check all CDS Views that would be great to know....

Thanks again all!

Are you saying that you didn't test Kerem response, but anyway you have accepted it/marked it as best answer?

When I ask questions and I get an answer, I first test it, and if it works I accept it as best answer with confirmation that I could (+ I add any additional information).

If I don't test an answer, I don't mark it as accepted/best answer so that to not mislead people in case the answer is incorrect.

sap_cohort
Active Contributor

Hi Sandra and fellow cohorts, Thanks all for your help and continued support here. Greatly appreciated!

I had incorrectly assumed that the ATC approach would have given me a thorough DDLS check and pick up my errorand yes I should have tested first. I have unaccepted and will update.

*** Current problem is it seems that the ATC Cockpit Checks do not pick up on my specific CDS View Error!
For now I'm going to try your recommended approach with CL_DD_DDL_HANDLER_FACTORY=>CREATE

Question:
Can anyone verify that ATC does not catch this error or if I need to configure ATC somehow to catch it?

@Consumption.derivation.binding: [{targetParameter: ' P_FISCYEAR'...
vs
@Consumption.derivation.binding: [{targetParameter: 'P_FISCYEAR'...

0 Kudos

Hi Team, I have tried every ATC CDS Check I could find and none of them are picking up my CDS Error!!
Let me know if you have any other thoughts on why ATC wouldn't pick up this error? Thanks!

sap_cohort
Active Contributor
0 Kudos

Hi Team,

Found out this is due to stricter syntax checking and the upgrade phases do not take the source code errors into account. They do get activated but still show error in the DDLS in editor.

ATC and SDDLAR do not report the CDS DDLS Errors as well.

The reason the report fails during runtime is that BI runtime (Analytical Mgr) has higher requirements than the upgrade phase currently does.

SAP is working on a fix for this. Thanks for your support and ideas.