hello friends this is ganesh and video number 14 on auditor in this uh video i'm going to explain about multi-level deep entity set and we're going to use get method so we're going to get the information from the back end and pass the information to ui with multi-level deep entity set okay hope you might have gone through the previous video about deep entity set it may be a our post method so now you have an a basic idea about what is deep entity so here this is the extension of the deep entity so the basic
is very same and very simple uh only the internal table we need to form in the deep entity level and that table needs to be fulfilled with a method called get expanded entity set so the same way we're going to do it here for the multi-level deep entity as well okay let me get into the system excuse me so this is uh deep entity which we have seen in the last previous sorry not last previous videos about deep entity set so this is entity set and followed by i have uh the first level of deep
entity i can mention the first level because we have multi-level so first level of deep entity set which we already seen so we have to create an association between this and we have a navigation property name and through navigation property name we are fulfilling the data for this particular first level of deep entity so here uh now what are you gonna do is i'm going to introduce or extend my deep energy to the second level as well so this is a multi-level so further you can proceed further like one more multi-level like third level of
uh deep entity and you can extend it for other first level dependency as well so here i'm going to use only the middle description for as a second level of deep entity set okay so entity first level of deep entity and second level of deep entity set which we are going to design it so same thing uh now the association is happening between uh material plan details and middle description and this has it own navigation property and this is for the first deep entity first level of deep entity we have done these things we created
our association navigation path and we created a deep entities that internal table in mpc underscore ext class and we redefine the get expanded entity set and the ur i for deep entity with the help of expand is equal to navigation path suppose if you want to both first level of deep entity you have to use comma and then navigation but suppose this navigation or expand will get the information only for the plant if you need a storage you can use comma and what is the navigation but between orders and material storage location dependency you have
to use it okay separated by comma the same thing we are going to follow for the multi-level as well but there's few changes same association navigation path and here you have to create a nested deep entity design meaning this is the entity set okay and this entity set has an internal table meaning it has another deep entity okay so now what i have is this particular uh internal table or the entity has one more internal table so that way the design is going to be so it's very simple only three or four lines of extra
code compared to your deep entity set model other than that everything is similar over here so that's why i mentioned here nested deep entity design we have to create it in the mpc extension class okay and the uri perspective us we are going to introduce a new symbol called slash because the navigation path is two different ways one is entity to deep entity this is the one another one first level of deep ended to second level of deep entity here another terminology i am using is dependent entity okay dependent deep entity so if you want
a data from entity as well as deep entity so what you're going to do is you got to say expand equal to navigation path and further additionally i want the dependent entity data as well so you have to use material plant expand equal to navigation property of material plant slash navigation property of material description okay so that way you have to use it i will i will give the all the combination suppose you want i want uh all the three then how to create overhead service i want multi-level how to create a world service we'll
see everything in detail um yeah this is one example so my entity and the navigation property name is navigation property one navigation property two and this is multi-level uh navigation properties some name okay just for a reference so the uri would be so the first thing uri equal to np1 what happens if you your uri is look like this then orders and material plan detail will populate okay in the ui perspective next one if i say expand equal to np1 and np2 so first level of deep entity data will be populated np1 material plant np2
material storage now i want dependent deep entity as well so you have to introduce slash so expand equal to np1 slash mnp1 then it will uh get the data of plant as well as material description okay comma np2 i want this np2 also so all three datas i want okay furthermore suppose my uh material storage also has a dependent entity or next level of entity then you have to use np1 i want the dependent one so m np1 comma np2 so i want mnp2 suppose you have one more level of depended entity sets and again
you gotta use slash m and p three so slash is for dependent entities and comma is for independent entities so this way you were you are i should be so before question mark you know about the service like they say pvc and those your service name everything should come okay and then this is only expand part so hope this might be very useful uh you can understand now you have at least an idea what we are going to do in the system so i'm going to take this is the example like i'm going to get
the orders i think i have one more slide yeah okay i'm going to get the orders from three different tables like a ufk i'm going to get the order number afko reservation number resb material number it's one select statement i'm using left to join and then i'm going to get the material plan from okay this is wrong okay it's it's m a r c not mara m a r c and this is m e r d storage location and m a k t for description okay yeah so the code level this is the deep entity
set so deep entity said how we designed it i want these three is going to be only single record so order reservation number material is going to be a single record and if you want this is the first level of deep entity material plan and material location you have to create an internal table for the for this okay and don't confuse yourself with material planner np1 np1 just for your reference okay so this is just a name of your navigation property and type table off so this is going to be internal table now second deep
second level of deep entries come to the picture so what i'm gonna do is i don't want um this material plant okay so second level is one second let me go back yeah so i'm talking about these two entity now okay so material plant so material plant is designed as a just an internal table no because material plant has a dependent entity as well so i'm going to design the material plant in a different way so it's a material deep it has material material plant and i'm having material description okay of type table material description
with default keys so that is a change in your deep entity so here you can't use simply ts underscore material plant because it has a deep entity so this is the only change i am going to do what in the design level okay so this material plant is little different so i am creating a one more structure in the same mpc extension class same like the design same way how it should be like material works material description and i am going to use this structure as a reference while creating my deep entity uh structure work
area whatever it is okay and suppose if you want okay i want the material location also to be extended for another dependent one so you need one more structure to be generated here along with material storage location and again same thing material description type table of ts underscore material description with default key and here there is a change okay so this is the way you have to extend your deep entity for multi-level uh as for my understanding because this is going to be consumed in ui they are not going to make more complicated so that's
why you're not getting more deep multi-level entity set because the data should be very faster so if you keep on adding the more multi-level it might affect the performance of your ui so probably this is very rare scenarios where we have lot of multi-level entity set but if you know the understanding whenever you get a chance to work on it it's very simple to work on it okay so hope you have an idea about what uh is multi-level deep entities it okay anything else okay yeah i added this one also so why i need this
because of the material plant it is going to be a dependent internal table is going to be keep it here so that's why i want the structure good let me take you into the system so this is my system and i have created the basic model because i don't want to waste your time uh to create everything from scratch so this is same like the deep entity so i have created the project and four different entity types the first topmost is orders it has afnr reservation material and first deep entity level as mediterranean plant it
has material and works and this is material storage location this has a field of material and storage location and this is a deep entity level two so multi-level it has material and its material description okay so key fields for all the four ntd types material m80 okay let's create start creating association so here i'm going to do the coding uh declaration everything for deep entity level one first then we'll extend it for level two as well so it's easy for your understanding so let me create an association first so i need to create an association
for orders and material to plant and orders and material storage location so that is the idea so association so let me say a underscore orders to material plant just some names you have to give f4 orders cardinality one so these are very old steps we follow the same for [Music] deep entity previous ones so a navigation path uh navigation path this is for material plant implant so that's it click next oh sorry i missed the cardinality for the dependent ones let me have this as zero to n click next and then dependent property is also
matner so this is the association uh like reference like orders material as well as a media plan also material and click next and this is for your verification and click finish and create the next association for orders and storage locations so association for material sloc gear storage location an entity typos orders cardinality one and here entity type plus material storage location cardinality as 010 or 1 to n and navigation path as for material sloc storage location clear plans material storage location next here dependent properties [Music] next and finish so deep entity level one designing is
over so if you see there are two associations and if you see the navigation path for orders you have two okay so this is my in uh initial entity and it has two deep entity sets so a deep entity level one so now let me act toward it or generate my project okay it's got generator so let's go to the mpc extension class to create a deep entity so just again for a reference i'm going i'm doing only for deep entity level one let's go here okay that's fine i want this first as my actual
entity so here you can give any name but here i just followed whatever they have already so ttts they mentioned so this is my initial entity set fields look like a header and here i'm going to create a path and for this is for material plant so you have to use the same um [Music] name of your navigation path then only the records will fill then it reflects in your uh test case in the gate basis gateway system they don't give any error and you don't fill data as well so naming conversion is very important
you got to give the same navigation property name of your dependent deep entity okay so type table off so ts underscore is already there uh material so name material plant with default key so same thing i have to create for material storage location that is also a internal table so type table of ts underscore control space bar m a t s location with default key okay and for the reference or reusability better copy this code and keep it in a notepad because once i'm going to add a deep entity level 2 and generate my acgw
project your mpc extension class will be regenerated meaning it just delete all the custom code so i need this code again so that's why i just keep make a note of it always remember whenever you are regenerating your segw project it will regenerate your mpc extension class as well so all the custom code will be deleted let me act about it so now it's very simple we need to add a code i think i don't want to explain much on it because we already see normal select normal loop so i'll go a little faster so
please try to follow because our main idea is going to be a multi-level deep entity so here i need to okay sorry i'm an mpc class go to dpc class extension and redefine your method that is coming under your apple server runtime and get expanded entity set redefine okay so let's start with the declaration i need deep entity set internal table so it deep entity type z cl and the score cj hi yeah this is mine oh god multi-deep yeah zero one mpc and uh structure is tsd entity this is a body and i need
a work area as well entity type it's the same class and same structure that's it okay so now okay sorry this should be table off so now i'm going to do a select for first three tables so select from i i'll use a new way of syntax so it's very easy so please practice yourself with the new syntax uh selects from a ufk so this is my training system so better i'll go the left outer join to gather more data so leftover join with afko on auf k u f and r is equal to f
k o a u f n r okay and another left outer join is for our asb so this is for my header first entity data on afk o [Music] okay and then fields so what are the fields we want i need a open up and i want rsnam and then m80 so might get an issue because this is ambiguous meaning it's available in more than one table so we have to mention which from which table you want this data i'll go with afk and rs numbers from afko and m80nr is from okay and no wire
condition uh just wide open select this one then only i'll get more data i can show you and into table on on the floor declaration internal table rs okay once this is success get the data from different dependent table so you can write any kind of code any way of code to fill your final internal table so this is uh i'll just go very basic for your understanding uh you have to get the actual idea of the multi-level deep entity that's why i'm going uh internal table by table okay so select and from marc so
i want fields m80nr and works then uh wire condition okay before wire condition i am going to use for all entries in orders and where m80 and r is is equal i t orders hyphen m okay and finally into table data this is for material plants okay and i need at symbol otherwise i'll get a syntax error okay and i want data for so data from storage location as well so select from m a r d and fields i want matner and l g o r t uh for all entries in it orders where mdnr
equal to it orders mhtnr okay into table at data storage location on the flow all the things are declared that's it so data is ready then i need to fill it so i'm going to fill for deep entity level one so i need to fill uh orders first so i t orders into data on the flow declaring my internal sorry work area so here deep entity work area hyphen a uf and r equal to from this orders ufnr and next field is for reservation number r is num equal to wa orders r is num and
then deep entity for matner is equal to orders hyphen imagine that's it so now data for deep entity [Music] level one is nothing but material plant so i need a loop over here i.t material plants into work area material brilliant yes i should not use the earth symbol over here because that is only applicable for select statements okay so here i'm going to use wire condition where it's not required because anyway uh based on the for all entries in one day it comes so it doesn't make any difference so let's let it add over there
or does it okay so if s so then okay i need one or carrier to be declared based on my declaration based on my design of gateway project so data i want material plans type zcl [Music] ts material plant and i need for material location as well storage location type pcl ts underscore material storage location okay so i can say data because i am giving the same name and the loop as well okay so here i'm going to use that work area material plans data material is equal to here plants immediate enough and material plants
data works is equal to wa plants so implants that's it then i need to append this to my deep entity work area so [Music] material plans data to deep entity hyphen control space bar navigation path implant okay so clear at your plant information so that's it and i'm going to use another loop for storage location so this is data for deep entity level 1 and material storage location so loop at it material storage location into data material storage location so here material storage location underscore data matner equal to here i didn't use the bar condition
storage location iphone material yeah better i have to use where then only i'll just get the actual data over there so that m8tnr is equal to wa orders imagine so that that makes sense okay storage location data iphone lgo t equal w a location l g o r t so append this to your deep entity work area to w a t entity iphone and this is the navigation path name means your internal table name same like your navigation property name relation data dot data save it so almost done the code level so finally i need
to append everything this is one record right so append my deep entity to id deep entity clear it deep entity that's it so once the end loop is done you need to pass the deep entity into your er entity so what is the output of you means export or import parameter i think it's export parameter of this particular class so the class is [Music] this one and f4 you have to take copy data to ref so this is a class and method so you are input exporting data from this method as it deep entity and
go to the signature get what is the name they used here okay so this is the er entity set so and typed the ref to data so diver f2 data so that's why we can use whatever internet intel table is required uh what is that er entity set okay er underscore tit y entity set and another one we need to add is based on which entity name because this is calling more than once so always have that particular if condition and the field is what is the field lv sorry iv entity name so if i
v e n t i entity name equal to order so that is the name we have given in our entity so only that case please execute this code otherwise don't do what everything is coming under that validation only act toward it checking it open syntax i used to do that symbol now deep entity level one code is ready so now you have to go to your um gateway uh service and create a service for your gateway project and execute with navigation path and see how it happens secured ad service local cji star so this is
the one multi-deep service click local object continue so these are very old steps metadata was loaded successfully that's great then go back and get the added service for execution cgi star multi double deep sap gateway client so here get the entity so the basic entity as order set is the basic entity and here i'm going to use expand question dollar expand i'm going to give only the first name navigation path implant i believe it's in plant only let's see execute uh yes it's correct so okay it has a lot of records uh that's why it's
take little time so here it shows okay let me add json format it's very easy to understand format json execute yeah so these are the results and here it shows metadata and this is the header header has auf nr rs metnr and the navigation path we have is nap material location and we have maybe plant but you don't have any data for your material location because i didn't requested it i requested only napm plant so that's why it comes over here so your nap material storage location is empty so if you need so this is
the one um deep level deep entity level one you want all the level of entity to be filled then you have to request with the help of separated by comma the help of comma so i want the data for my ms loc as well okay now execute it again uh what is that name okay sorry this time okay deleter plants okay which now which is not available okay so okay added t over here delete it and execute it hope it's worked because it takes time it gets all the data yes so now again the header
is filled and nap storage location also filled material and lgorp so this is that deep ntt level one it filled uh both ndt a dependency level with the help of your navigation path so now i'm going to extend means i am going to add one more deep entity we called as deep energy level 2 multi level under the dependent of material plant okay so let's go to the project scgw project go back okay let me do like this cgw and go to my project so here i'm going to add an association because any type entity
type is already available media description is already available so i'm going to create an association for material plant and descriptions so go to association excuse me change it so right click create so now the association is for material plant and material description okay and i need material plant here cardinality is one and material entity is material description and cardinality is zero to n navigation paths nap material description okay so yeah it's fine nap material description and click next contains a character that is not allowed what character is always a space yes there's a space click
next yeah and the dependent property is nothing big material number click next everything is fine finish now if you go to material plant you're able to see the navigation property so here you are not able to see that tree structure like dependent uh deep entity one deep a2 that is not possible so you have to based on the association only just come to know okay so now i added this material description under the deep entity level one that's it in the design level regenerated so whenever you are doing regen rate your mpc extension class also
regenerate with the code with the actual code so it deletes uh whatever code we have added it so i already had a copy let me add it once again i'm sorry go to runtime artifact in pc extension why it looks like it just take to directly over here okay okay go to types if you see you say ts deep ended e is missed because it's got it deleted okay so once you regenerate if your ui application is trying to call the same entity type they will get an error called as some syntax error is happening
because mpc got changed and if you go to the get expanded entity set method it has a syntax error because we declared everything based on the dats deep entity only okay let me do it the core declaration for deep entity level one so maybe you just recollect the ppt whatever i showed i need to have a structure over here this one so my material plant has a deep entity on it so it's kind of a deep structure so i'm going to create a structure for my material plant which has one more internal table so this
type to be added and the type table of the source code going to be changed okay so let me have that one as well types begin off this is for ts deep entity for material description okay i can have material plan not description okay material plant you can give any name so here what is the header for this particular structure m80 either you can copy or you can type your own works and then you have to use the same name naming convention and ap material description i believe i have used the same name let's confirm
as well and this is ts material description so it has only two fields material and material text with default key and of uh ts deep ntt implant that's it and just change your material plant so technically this is basic entity and this is deep entity level one and this is deep entity level two okay and this is deep entity level one it doesn't have level two got it that's it over here act ordered let's start very simple okay so go to dbc class get the data added and call the gateway service okay so i need
one more select let me go over here select from m a k t sorry let me get fields i want s and m a k t x for all entries in id orders where mma tnr is equal to my key orders so if you want a language key you just use it depends on your need into table at data i.t material description that's it so it is over and i need to add loop over here which is here so here you don't worry about i think i already mentioned in the ppd as well you don't
worry about why we are using loop and loop and loop normally in ui we won't go very deep multi-level entity because they want data in a different pages or different request as well so okay so they want single data only because it's a ui maybe in a mobile they're going to see very very short informations so it's very rare they're going to use more data so performance wise also is not going to affect mostly it's going to be the request is one data and we're going to send the details of the one particular material number
with the deep entity set okay but you have to analyze before commit you're going to do a deep entity multi-level deep entity make sure what is the data volume as requested from ui level that is a very important thing based on that you can decide whether the multi-level depending is feasible or not if not you have to change the design along with your ui person i t material description okay i need one more regulation let me do it into data material description where me tnr is equal to wa orders 18 okay one more declaration is
over here wa material description data type zcl control spacebar ts material description okay almost done final wa um material description data mhtnr is equal to wa material description description data how does that make dx equal to description and making tx then append it to your deep entity work area material description data to wa material plan that's what we just declared right and sorry material plans hyphen okay i think i didn't declare it empty plans and everything over there this is the declaration part that i need empty plans data is going to be changed over here
correct so this is deep entity material plan because that declaration has both your plant information as a header and one more interval table as media description so that needs to be changed i got it material data material data over here uh data data here okay got it material plans data iphone control spacebar so here it is nab m description clear it and maybe your description data as well that's set so then is automatically plans data is going to be added in your deep entity level two okay i have small doubts let me make sure my
mpg extension is also active okay so now go to the servers so make sure it's working fine it's not uh [Music] just break any existing one just executed yes it's working fine this is level one material plant header is filling material location is filling and the material plant is also filling so now i need my level 2 as well deep entity level 2. so that is by introduced by slash nap i want material description okay before that let me okay i think i need to refresh let's see execute okay material plant is here and material
plant and here you have a material description so that is also filled okay so let me yeah this is the header basic entity and this is the deep entity level one and this is deep entity level two nap method description is also executed or displayed based on your request over here okay and let me go down to deep entity level one material storage location it's filled it doesn't have entity too so then it's go to the next order so hope this is clear for you how to use a multi-level deep entity and you can you
can continue your slash over here if it is more than one or you can go with comma for your deep entity level one so just go through it if you need more clarification just put a diagram of your requirement initially because don't design everything it's very simple normal method you're going to use select and loop within a loop only only maybe the declaration over has not worked on deep entity it may be a new for you but everything is very very very simple okay so understand the requirement draw your design first whether it may be
achieved through a deep entity or it needs a multi-level deep entity consider your data volume so everything is fine it takes probably a very small amount of time to design and develop it okay just play around it if you need any help any doubt please let me know thank you so much for your time see you in the next video bye