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.
Provide the attribute name any name which is relevant to your requirement and DDIC structure that is data element for that field.
click on continue.
Click on complete the wizard will generate one filed under your context node.
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..
Extending the structure by adding your field in to GET_TABLE_LINE_SAMPLE.
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.
Go to table view click on configuration move your filed form available to display.
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.
Go to that component there is a method do_prepare_method.
Place a breakpoint
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
Under this is the relation.
This relation we have to use.
Step 5: In getter and setter method write this code.
In setter method .
This is the out put..
Thanks & Regards
Srinivas
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
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
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.
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
Hi Srinivas,
Nice document.
Thanks for sharing.
Regards,
Zafar
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
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
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
"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:
Cheers!
Luis
Hi srinivas,
nice post....
Hi Rajkumar,
Thanks for your appreciation and spending your valuable time for reading this doc.
Thanks & Regards,
Srinivas.
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.
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.
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.