Skip to Content
Author's profile photo srinivas karri

Creating a Custom field and display it in a table view

This document will help you how to add a new filed in the table view, so that we can display any data related to that node. So for that we have to create a z (custom) field for that and add it to this screen. Now we will see standard filed and display data in a table view.


We may sometime come across a requirement of adding standard field to table view in CRM web UI.  This article explains how to add standard field to the table view and display data based on search.


Procedure:

1) Add value or model attributes to the table view context node ( in my scenario i have taken value node).

2) redefine GET_TABLE_LINE_SAMPLE and extend the existing structure by adding z fields

3) go to SPRO and search for design layer. There you have to check disable hiding of fields by design layer checkbox

4) Find out the relation between context nodes.

5) populate the value in the fields by using relation name in GETTER and SETTER method.


Step 1: Add value attributes to the table view context node


            go to table context node right click and create.


attrbut.JPG

first1.JPG

Provide the attribute name any name which is relevant to your requirement and DDIC structure that is data element for that field.


first1.JPG

click on continue.


first1.JPG

Click on complete the wizard will generate one filed under your context node.

city.JPG

While creating table view at that moment wizard will create one structure in GET_TABLE_LINE_SAMPLE.


Step 2 : redefine GET_TABLE_LINE_SAMPLE and extend the existing structure by adding z fields

Enhance the GET_TABLE_LINE_SAMPLE method under your context node..


get.JPG

Extending the structure by adding your field in to GET_TABLE_LINE_SAMPLE.

get1.JPG

Step 3 : go to SPRO and search for design layer. There you have to check disable hiding of fields by design layer checkbox

SPRO->CRM->UI Framework->Design layer-> Deactivate Hiding of Fields.


fav.JPG


bsp2.JPG

Go to table view click on configuration move your filed form available to display.

bsp2.JPG

Then we can see your filed in result view.

If we want to display data for that filed we can write the code in getter and setter methods.

Based on the relation we can fetch the data.

Step 4: Find out the relation between nodes.

Go to web ui in which field u have to identify the relation place a cursor on that field click on f2 then u can identify the component name, view name, context node.


bsp.JPG

Go to that component there is a method do_prepare_method.

Place a breakpoint


bsp.JPG

We have to pass typed_context->context_node->collection_wrapper right side same as like above.

Double click on that.

Click on collection_ref-> ENTITY_LIST-> CONTAINER_PROXY->data_ref-> RELATIONS

bsp.JPG

Under this is the relation.


bsp.JPG


This relation we have to use.

Step 5: In getter and setter method write this code.


bsp.JPG

In setter method .

bsp.JPG

This is the out put..

bsp.JPG


Thanks & Regards

Srinivas

Assigned Tags

      14 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Is this supposed to be an xml file or uploaded as such by mistake. I was hoping it to be a pdf doc.

      Thanks & regards.

      Chitwanjit

      Author's profile photo srinivas karri
      srinivas karri
      Blog Post Author

      Hi Chitwanjit Singh,

      Sorry for the inconvenience now i have attached proper doc.. go through that.. if you have any queries let me know.  

      Thanks & Regards,

      Srinivas

      Author's profile photo Former Member
      Former Member

      Thanks for the correction, Srinivas. Its better now. One pointer only, couple of snapshots are less readable, but are comprehensible. Apart from that, its great job.

      Author's profile photo srinivas karri
      srinivas karri
      Blog Post Author

      Hi Chitwanjit Singh,

      Thanks for your appreciation. i had tried for uploading pdf doc but its not allowing me to upload more than 1MB. if you want pdf doc please send me your mail id.

      Thanks & Regards,

      Srinivas

      Author's profile photo zafar karnalkar
      zafar karnalkar

      Hi Srinivas,

          Nice document.

      Thanks for sharing.

      Regards,

      Zafar

      Author's profile photo Former Member
      Former Member

      Hello Srinivas,

      while reading your blog one question came to me: Why do you select "Add Value Attribute" in the first step of the wizard when adding an attribute present in the BOL?

      The second option "Add Model Attribute" allows you to add a new arbitrary named attribute as well. You can then select, directly in the wizard, from the BOL model the data source. In your example you could go from the BuilHeader to the BuilStandardAdressRel and then choose CITY.

      Afterwards the wizard does generate all the necessary coding automatically. No need for the manual steps you described. Way easier.

      The DesignLayer still has to be handled separately.

      cheers Carsten

      Author's profile photo Luís Pérez Grau
      Luís Pérez Grau

      Don't be so mean 😉 , Let's assume this is just an example and imagine the attribute comes from a collection which you need to filter manually because there's no standard relationship whcih will give you this 1-1 relationship.

      Anyway, I agree with you and the author should clarify this is just an example and in a real scenrio first you must investigate if is a direct relationship, before coding/enhancing "like crazy".

      Cheers!

      Luis

      Author's profile photo Former Member
      Former Member

      I am not trying to be mean or anything. My assumption is that the author has spent time investigating this topic and has decided to share his/her insights with us. A thing I really like and support. I suspect there has to be a reason why this path is followed instead of just using the wizard.

      In my opinion this way makes sense for custom fields, as long as the attributes are not reachable by a BOL relation. Say you have to call a function module or a web service.

      Maybe this was just a bad example taking a BOL relation out of simplicity. Perhaps the author did not know better. Could be we both are missing one important step why this way is better.

      What remains for sure is that the SCN is a place of knowledge sharing. The goal should be to learn something from contributing here. By writing a blog you offer knowledge, why not get something back through the comments?

      cheers Carsten

      Author's profile photo Luís Pérez Grau
      Luís Pérez Grau

      "Don't be so mean" it was suposed to be some sort of joke,  I understood your point perfectly and I though I was clear enough with my comment:

      Anyway, I agree with you and the author should clarify this is just an example and in a real scenrio first you must investigate if is a direct relationship, before coding/enhancing "like crazy".

      Cheers!

      Luis

      Author's profile photo Rajkumar Deshetti
      Rajkumar Deshetti

      Hi srinivas,

      nice post....

      Author's profile photo srinivas karri
      srinivas karri
      Blog Post Author

      Hi Rajkumar,

      Thanks for your appreciation and spending your valuable time for reading this doc.

      Thanks & Regards,

      Srinivas.

      Author's profile photo Rohan Parab
      Rohan Parab

      Dear Srinivas,

      I followed your steps, the field is displayed on WebUI but the field has not been populated in standard tables/structures. Also after refreshing screen value clears. And sometimes the whole table area goes blank.

      Author's profile photo srinivas karri
      srinivas karri
      Blog Post Author

      Hello Rohan,

      First of all thanks for reading my blog.. the field which you added is under context->attribute level so this will not added into standard structure/table.

      If you refresh any web ui will start from initial so u have to check what u wrote in  do_init_context or do_prepare_output method in search view impl.

      Thanks & Regards,

      Srinivas.

      Author's profile photo Rohan Hardikar
      Rohan Hardikar

      Hi Srini,

      Thanks for such a helpful blog.
      I am pretty new to CRM ABAP. I Have got a requirement where we need to use a standard attribute "PLANT" from the Item level in sales order and copy this field on the header part, so that if we enter a value in header PLANT, this value gets populated in all the line items present.
      To achieve this, I created a Model attribute using relations and added the field and used relationship BTHeaderItemsExt and BTOrderItemAll in get and set methods.
      But when I enter a value on screen and press enter, the value gets disappear.
      Can you please help me where I might be going wrong?

      Thanks & Regards,

      Rohan.