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: 

ABAP CDS VIEW - Data Inconsistency

0 Kudos

Hello All,

I have created a simple CDS view with a select on MARD.

define view zmat_stk_view
  as select from mard
{
  matnr      as material_no,
  werks      as plant,
  lgort      as sloc,
  labst      as un_stk
}
where
  matnr = 'X00088337'

When I execute this CDS, the data I get is as following. Please see the highlighted unrestricted stock(un_stk) for storage location(sloc) = 1000.

When I see in se16n, labst value = 100 for for sloc = 100.

Has any one else face this issue? Any suggestions/guidance is much appreciated.

1 ACCEPTED SOLUTION

horst_keller
Product and Topic Expert
Product and Topic Expert

Seems that there is a replacement object defined in SE11 for MARD.

13 REPLIES 13

Former Member
0 Kudos

Try below.

define view zmat_stk_view

as select from mard {

Key matnr as material_no,

Key werks as plant,

Key lgort as sloc,

labst as un_stk

}

where matnr ='X00088337'

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

What should that change?

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

Are you sure that you work with the same client?

What is the result when you access the CDS view with Open SQL and the table with an equivalent Open SQL SELECT in an ABAP program?

0 Kudos

Hi Horst,

I can confirm that I am working on the same client.

SELECT matnr,
werks,
lgort,
labst
FROM mard
INTO TABLE @DATA(lt_mard_data)
WHERE matnr = 'X00088337'.

SELECT *
INTO TABLE @DATA(lt_mard_data_cds)
 FROM zmat_stk_view.

I wrote the above select statements in a program.

The select on MARD works correctly but the one on CDS is still returning incorrect value.

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

Strange. Could you please also show the view annotations?

What happens if you access the CDS DB view?

0 Kudos

Annotations are :-

@AbapCatalog.sqlViewName: 'ZMAT_STK' 
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Material Stock'

The data is incorrect in the cds db view also.

I got the same incorrect data when I tried accessing the cds view from the SQL Console.

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

Now, we have to compare the ST05 traces of the above SELECT statements of your ABAP program. There must be a difference.

0 Kudos

Hi Horst,

ST05 trace is as below.

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

Uh-huh, see the object names. The first SELECT doesn't access MARD.

There must be a replacement object defined in SE11 for MARD.

horst_keller
Product and Topic Expert
Product and Topic Expert

Seems that there is a replacement object defined in SE11 for MARD.

0 Kudos

Thank you Horst!

I changed it from MARD to the replacement object in my cds view and it worked like a charm.

Happy New Year!

Best,

Aashrith.

0 Kudos

Shukria!

We were facing exactly same issue and resolved it exactly as above.

Cheers.

former_member579519
Participant
0 Kudos

Go to SE11--> Extras--> Replacement Objects

Replace table as nsdm_e_mard in view