cancel
Showing results for 
Search instead for 
Did you mean: 

Business scenario for AMDP and Association in CDS

shubham_banerjee
Participant

Dear Experts,

Please help me with understanding with a real time business scenario or a business use case, under which circumstances shall we use,

1. AMDP and not CDS view.

2. Association and not Join.

As I am struggling to understand a situation where I shall use them and not the other one, in a real time business environment.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

former_member1716
Active Contributor

Hi Shubham Banerjee,

I Can help you with few scenarios where AMDP can be used,

1) Displaying a Report where we display the material details along with its Current Valid Price. The trick here is you may have several condition records for the same material and UOM. You may even have multiple conditions records available for same period. You Need to bring out only the Latest One.

2) Displaying a report where i have select Option elements in the selection Screen.

It all depends on you, for practice you can take a simple report. Create it only through procedural Program, The create it through Normal CDS, then go for CDS with Table functions (using AMDP).

This will give you a good understanding!

shubham_banerjee
Participant
0 Kudos

Dear Satish,

Thank you so much for the Material Details scenario, absolutely what I was searching for all this time and to put my brain in finding out a solution of a situation where AMDP takes a leap than CDS.

One more thing, I have come across statements like, AMDP is such powerful to define a CDS source. Any inputs on that will be highly appreciable.

Thanks in advance.

Answers (2)

Answers (2)

former_member1716
Active Contributor

Hello Shubham Banerjee,

Let me try keeping it simple for you!

1. AMDP and not CDS view:

--> Well AMDP can Only be used where HANA is the database.

--> With respect to CDS views AMDP methods will account only for the CDS type "CDS with Table Functions".

--> In case of other CDS Views we only use a select query, we cannot write any other statements except one select query. In the same Select Query We have to accommodate all the possible calculations we wanted. But this cannot be achieved in call cases.For instance in AMDP methods you can write Select statements with Joins where your internal Table can be Joined with standard tables. With this we eliminate un-necessary processing of lot of entries in Database. There are lot of similar techniques available which is not with Normal CDS Views.

--> Another Advantage of using CDS with table functions or in other words AMDP methods is in normal CDS Views you cannot handle the Select Option elements that is used in your report, with CDS with table functions this can be achieved using Dynamic Select and Apply filter functions.

--> Please note you can also create AMDP methods and use it in your report, they need not necessarily be used via CDS views.

--> The above points can help you understand the difference at basic Level, But as you dig deep you will be enlightened with more information.

2. Association and not Join.

--> The main difference with Join and Association is, in case of Joins when you try Joining the two tables it will Join the tables irrespective of the fields in Select Query, But in case of Association the Join will be performed Only when your select Query has fields related to The tables that are joined.

--> In Other words a table will be Joined Only if its needed in case of Association. To be more precise , "All the tables whose fields are there in select Query will be Joined, if there no fields from a table then the Join will not be performed even though the table is part of the Query".

--> Now the why part? why do we need this associations? in case of Queries Created with Associations the fields which are not part of the initial query can be exposed later based on the business needs. This avoids the developments from the scratch.

--> Another case is, with associations we have the Luxury to play with the available fields during our O-DATA developments as well. Its basically the developer's choice to create a Association or to go with Joins. If he feels the tables involved may be needed for other fields which is not part of the initial Query then he should go for Association.

Hope you have a better understanding Now!

Cheers! 🙂

Thanks and Regards,

Satish

shubham_banerjee
Participant
0 Kudos

Dear Satish,

Thank you so much. I feel, you really explained it like never before and nowhere else. One more request would be, if you have worked on a Functional Specification where you used AMDP and not CDS will be a real help, if possible.

Thanks in advance.

maheshpalavalli
Active Contributor

Hi Shubham Banerjee,

For AMDP you can see this below answer.

https://answers.sap.com/questions/472321/guidelines-to-use-cdsamdpopensql.html

For Joins Vs Associations use cases check the below answer.

https://answers.sap.com/questions/12712350/association-on-multiple-tables-in-cds-views.html

Let me know if you still have any issues understanding them. 🙂

Br,
Mahesh

shubham_banerjee
Participant

Dear Mahesh,

Thanks for sharing the URLs, however they look more towards conceptual explanations. I am requesting for a real time use case as following,

for an example I am trying to create a BASIC CDS view to be exposed to OData which is intended to fetch Customer Master details from following tables based Company Codes,

T001-BUKRS -> KNB1-KUNNR -> KNA1-ADRNR -> ADR6-SMTP_ADDRESS

-> KNMT-MATNR -> MAKT-ARKTX

In such a situation, can you please guide me if I should use Association or JOIN and CDS or AMDP and why. For information I have already achieved the desired result using JOIN.

Thanks in advance.

maheshpalavalli
Active Contributor
0 Kudos

Shubham Banerjee, Those explanations in those answers are not just conceptual they actually talk about the way to use those concepts(practically).

Advanced HANA SQL functions are not supported in CDS view and if you want to write code similar to ABAP(not exactly but similar) in a procedural way then you can use AMDP. Basically not all can be done using cds views, it doesn't support many for example ranking. So you will go with that. All others normal scenarios you can go with the CDS views.

Now coming to the join vs cds. You need to use joins you want to expose all the data in one single view or odata service one single entiy. But when to use Associations is if you want to generate a OData service based on the CDS view, and if your odata service needs multiple entitysets with logical relationship between them, you use Associations in CDS views, which will be converted to multiple entitysets(if you autogenerate odata service from cds view) else you need to manually link the CDS view associations to OData service project entitysets.

Thanks,

Mahesh