2017 Dec 27 6:01 PM
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.
2017 Dec 29 9:14 AM
Seems that there is a replacement object defined in SE11 for MARD.
2017 Dec 28 8:58 AM
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'
2017 Dec 28 9:29 AM
2017 Dec 28 9:28 AM
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?
2017 Dec 28 12:16 PM
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.
2017 Dec 28 4:02 PM
Strange. Could you please also show the view annotations?
What happens if you access the CDS DB view?
2017 Dec 28 4:13 PM
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.
2017 Dec 28 4:46 PM
Now, we have to compare the ST05 traces of the above SELECT statements of your ABAP program. There must be a difference.
2017 Dec 28 6:31 PM
2017 Dec 29 9:09 AM
Uh-huh, see the object names. The first SELECT doesn't access MARD.
There must be a replacement object defined in SE11 for MARD.
2017 Dec 29 9:14 AM
Seems that there is a replacement object defined in SE11 for MARD.
2017 Dec 29 3:46 PM
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.
2018 Jan 22 8:06 AM
Shukria!
We were facing exactly same issue and resolved it exactly as above.
Cheers.
2021 Apr 07 5:13 PM
Go to SE11--> Extras--> Replacement Objects
Replace table as nsdm_e_mard in view