cancel
Showing results for 
Search instead for 
Did you mean: 

How to create metadata dynamically at runtime ... in odata service

0 Kudos

Hi experts

In one of my requirement my entity type has 10 fields, so in $metadata i will  get 10 fields in the properties.

But from UI side they want only 5 to 6 fields, selecting fields is done at the runtime,

So is there any way to change the $metadata properties at runtime, so that we can send only selected fields from backend in $metadata properties

Any chages is need to made in MPC_EXT class define() method .

Ex:-

Consider Employee  entity type having 10 fields, if user selects one option, i have to send only 4 fields in the properties of $metadata

.

If user selects another option, we need to send 8 fields in the properties of $metadata .

Any way to do it ... ??

Thanks .....

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Amarnath,

I too have the same requirement, I need to display the some information based on the user.

The FM that provides the data will return all the field, but in the UI I need display only the relevant fields configured in the SAP from T588M. So I was thinking of having an additional metadata in the ODATA services like IsVisibleForUser="True". Which can be dynamically added metadata information for each field.

It looks like your requirement is also the same, can you explain me how you had resolved this issue ?

This would be a get help for me.

Thanks

amarnath_prasad
Explorer
0 Kudos

Fiori template will not fixed & for creation dynamic UI backend need to pass additional info(eg isvisibletoemp = 'X' ,iseditabletoemp = 'X')

Former Member
0 Kudos

Thanks for your response.

The info isvisibletoemp = 'X' ,iseditabletoemp = 'X' is added to the metadata of the odata service? , if so can you explain how to add info dynamically to the odata metadata.


I had been breaking my heads with this issue and since I am new to abap, I am not able to find the way to dynamically add the metadata info to the ODATA.

This would be of great help to me. You can just explain the process or steps or refer some articles related to this issue that would be of great help.

amarnath_prasad
Explorer
0 Kudos

Actual requirement is like something---after selecting from dropdown odata wl call by passing insurance type based on insurance type table header & record wl fetch from tables(field table & record table) and have to display on ui in tabular  format.After displaying record along with column name(header) of atble we have to do CRUDQ on particular row

sreehari_vpillai
Active Contributor
0 Kudos

Association is to be established ( 1: n) between the header ( dropdown value ?) and the items( table data to be displayed ) and bind the association URL directly to the table. In most cases what I have seen is, EDM design may not be proper enough to handle such situation. People would import DDIC tables directly and convert it into the OData entity types .

amarnath_prasad
Explorer
0 Kudos

But table fields will be fixed na for importing ddic

sreehari_vpillai
Active Contributor
0 Kudos

Yes..

sreehari_vpillai
Active Contributor
0 Kudos

Are you looking for dynamic OData metadata to be generated ? No donut . EDM is to be defined statically. It is not for dynamic cases . May be you can think of creating a SICF node manually and get it done -

Sree

amarnath_prasad
Explorer
0 Kudos


hello

sreehari_vpillai
Active Contributor
0 Kudos

Sure,

If I understood the requirement properly, you are trying to do something like below. Correct me otherwise .

You have a drop down list in your screen and below that , you have a table. An entity set is bound to the drop down list and on selection of a value, you need to display some related data in the table .

Is the table columns fixed, or you want it dynamic ?

If it is fixed(or even dynamic), you have to define it in EDM and establish an association between header entity set and item entity set and bind it to the table.

Sree

amarnath_prasad
Explorer
0 Kudos


hello Ashwin Dutt R

but fields are  unknown to us ie fields will come from table

AshwinDutt
Active Contributor
0 Kudos

Hello Nandish,

It would be great if you can clearly explain your requirement what is that dynamic thing which you want to achieve ?


Ex:-

Consider Employee  entity type having 10 fields, if user selects one option, i have to send only 4 fields in the properties of $metadata

.

If user selects another option, we need to send 8 fields in the properties of $metadata .

We cannot send anything to $metadata. GW frame work will show the details of your GW Model.

In the question you are talking about $metadata, So at the metadata level, Its not in our control to select the properties to be displayed when you fire your $metadata URL. i.e., dynamically.

We cannot dynamically change the properties shown in $metadata at run-time.

If anything related to selecting the properties to be displayed as part of response then Chandra has already show the way to do it.

Regards,

Ashwin


0 Kudos

Hi Chandra/Aswin,

Let me explain my requirement, we have a dropdown field in UI5 say for example Insurance: and we have two options in dropdown i.e. self and dependent.

Based on our selection i.e. self or dependent in insurance dropdown field i need to display the respective details below dynamically.

In Back end we have only one entity type and entity set i.e insurance/insuranceset so how can we send/display the respective details based on selecting the value in drop down.

Thanks ...

AshwinDutt
Active Contributor
0 Kudos

Hello Nandish,

Since you don't want to use $select,

In that case i suggest to create two different entities.

One for Self and another for Dependent and maintain the only required properties for both of them separately.


Implement methods for above entities separately and fire the service by passing particular entity on selection in the UI.

In this way you will get fields which are required only for self and for dependent based on selection in the UI level.

Regards,

Ashwin

kammaje_cis
Active Contributor
0 Kudos

Another option is to have one entity with a union of all required properties. Send null as the value for all not required properties.

In the UI logic, ask UI developers to check if the property value is not null, rather than checking if the property is found.

Regards

Krishna

amarnath_prasad
Explorer
0 Kudos

hi Krishna Kishor Kammaje

in se11 table there are 150 fields then then creating all fields is not good.In future they can add more fields then i have to add those 2 in entity type

ChandraMahajan
Active Contributor
0 Kudos
0 Kudos

$select field_name its not dynamic, here we have to mention the field name.

We dont the fields name until method will return field and its values.