12-27-2017 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.
12-29-2017 9:14 AM
Seems that there is a replacement object defined in SE11 for MARD.
12-28-2017 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'
12-28-2017 9:29 AM
12-28-2017 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?
12-28-2017 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.
12-28-2017 4:02 PM
Strange. Could you please also show the view annotations?
What happens if you access the CDS DB view?
12-28-2017 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.
12-28-2017 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.
12-28-2017 6:31 PM
12-29-2017 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.
12-29-2017 9:14 AM
Seems that there is a replacement object defined in SE11 for MARD.
12-29-2017 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.
01-22-2018 8:06 AM
Shukria!
We were facing exactly same issue and resolved it exactly as above.
Cheers.
04-07-2021 5:13 PM
Go to SE11--> Extras--> Replacement Objects
Replace table as nsdm_e_mard in view