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: 

select distinct from CDS ends with ORA-01791

attila_laczko
Explorer
0 Kudos

Hi,

I consume a CDS in a program with the following construct:

open cursor lv_cursor for

select distinct partner from z_my_cds_dima

where partner in @l_rng_partner " by default is initial to simulate no restrictions

order by partner.

    

fetch next cursor lv_cursor into table @data(lt_partner) package size @lv_package. " set to 100

close cursor lv_cursor.

cl_demo_output=>write_data( lt_partner ).

cl_demo_output=>display( ).

When I run the Program, I become a short dump with the message ORA-01791.

Changing the CDS entity name with the DB view in the select statement works!

Changing to another field in the selection list and in the ORDER BY works!

Undoing everything to its original causes a crash!


what ist wrong with the original definition?

any help would be appreciated.

many thanks in advance

Attila

1 ACCEPTED SOLUTION

attila_laczko
Explorer
0 Kudos

Hi,

after digging for more information, I have found a SAP Note that describes a pretty close problem, that a SELECT DISTINCT from a CDS can cause a SQL Error. The reason is the CLIENT field.

After a closer look into the DDL file of the CDS entity, I have noticed that

the generated annotation from the ADT wizard @ClientDependent was from me commented.

Reviewing again the help for it, this time with a closer look at the default values, has brought me the light: the CLIENT field was automatically in the select list included, due to commented annotation.

The solution came naturally to me: removing the comments to the annotation and setting his value to False like this

@ClientDependent: false

Regards,

Attila

P.S: as usual, every solution to a problem stays in details

2 REPLIES 2

christian_seitel
Participant
0 Kudos

Hi,

one needs to figure out what ABAP sens to the DB.

In the short dump there is something like

    Work process number.. 10

Note this number, here it is 10.

Then in transaction SM50 select this work process and in the menu select "Administration -> trace -> Display File -> Current"

In the trace there should be some info about this SQL error and probably the SQL statement.

E.g. the division-by-zero error of the ABAP statement

  select DIV( 1, 0 ) as a from svers into table @data(lt_result).

is traced as follows (in a HANA system)

C  *** ERROR =>   readFda() of C_0984, rc=1, rcSQL=304

...

C  SELECT /* FDA READ */ CAST( CAST( 1 AS INTEGER ) / CAST( ? AS INTEGER ) AS INTEGER ) "A" FROM "SVERS\

For further analysis the trace info around ORA-01791 would be helpful.

Regards, Christian

attila_laczko
Explorer
0 Kudos

Hi,

after digging for more information, I have found a SAP Note that describes a pretty close problem, that a SELECT DISTINCT from a CDS can cause a SQL Error. The reason is the CLIENT field.

After a closer look into the DDL file of the CDS entity, I have noticed that

the generated annotation from the ADT wizard @ClientDependent was from me commented.

Reviewing again the help for it, this time with a closer look at the default values, has brought me the light: the CLIENT field was automatically in the select list included, due to commented annotation.

The solution came naturally to me: removing the comments to the annotation and setting his value to False like this

@ClientDependent: false

Regards,

Attila

P.S: as usual, every solution to a problem stays in details