Skip to Content
0

ABAP CDS VIEW - Data Inconsistency

Dec 27, 2017 at 06:01 PM

203

avatar image

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.

cds.png (5.4 kB)
cds-output.png (6.6 kB)
se16n-data.png (15.4 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Horst Keller
Dec 29, 2017 at 09:14 AM
0

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

Show 2 Share
10 |10000 characters needed characters left characters exceeded

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

Shukria!

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

Cheers.

0
Umar Abdullah Dec 28, 2017 at 08:58 AM
-1

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'

Show 1 Share
10 |10000 characters needed characters left characters exceeded

What should that change?

0
Horst Keller
Dec 28, 2017 at 09:28 AM
0

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?

Show 6 Share
10 |10000 characters needed characters left characters exceeded

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.

mard.jpg (18.5 kB)
mard-cds.jpg (20.8 kB)
0
Aashrith H. Govindraj

Strange. Could you please also show the view annotations?

What happens if you access the CDS DB view?

0

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.

0
Aashrith H. Govindraj

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

0

Hi Horst,

ST05 trace is as below.

st05.png (64.0 kB)
0
Aashrith H. Govindraj

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

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

0