SAP CRM tree view

Source: Internet
Author: User

A tree view can be used to represent the hierarchy of data.

For example, organizational data in SAP CRM can be represented as a tree view.

In the terms of the SAP CRM Web UI, there is no specific tree view type like table view or Form view. We can assume that a tree view is a special case of a table view. There are no wizards that you can use to create a tree view. The existing view needs to be manually modified by the following specific steps.

First of all, this looks pretty hard, but the more you do it, the easier it will be to understand it. In this article, I'll create a tree view that looks like this.

  

As you can see, it has a level two structure. The first level shows the lead ID, and the next level shows the customer. I have used such a simplified example.

To learn this tutorial, we need to create a table view. The steps to create a table view are not described here, as already mentioned in the previous article.

In this article, I created a table view that uses the basic entity "Btqleaddoc".

A context node with the same type is created in the component controller and written to the code in its method do_init_context to get the data.

I then bound the table view context node and the component controller context node so that the table view can get to the data. The code written in Do_init_context is as follows.

  

What does this piece of code do?

I simply fetched the first 10 lead records and handed them to the context node leads. Data is bound between the table view and the component controller context node, and the data is streamed to the table view as well.

We are ready to start the main link.

First, go to the Table view context node to implement the class and change its parent class from "Cl_bsp_wd_context_node_tv" to "Cl_bsp_wd_context_node_tree". If you have a dialog box that asks for a specific method redefinition, select Yes.

This class provides two important methods.

  Get_table_line_sample and REFRESH.

The first method returns the structure based on the View column.

The Refresh method is typically used to build the node's first or root node.

I now use only two columns to present the information. So go to get_table_line_sample and add two columns as needed.

After the method is activated, the entire component is reopened using the transaction BSP_WD_CMPWB code. You can now see two columns in the view configuration in the Configuration tab. Move the two columns from the available zone to the presentation area, modify the corresponding title, and save the configuration.

We'll use the Refresh method later.

An important step now is to modify the tags in the HTM file. Use the CHTMLB tag:configtreeto to display the tree view. Go to the HTM page, remove the existing configcellerator or configtable tags, fill in the following tags, and activate.

The "lead" in the tag is a context node.

  The Nodetextcolumn property is used to select the root node of the tree or the properties of the first column. Here I select the ID column as required.

After populating the node table properties with the required nodes, we pass it to Lead->node_tab. Specifies the event handler "collapse" used to collapse the tree and the event handler "expand" that is used to expand the tree:oncollapsenode and Onexpandnode.

  Next, we need to create a class in SE24 that has a parent class.

Cl_bsp_wd_tree_node_proxy, this class provides a method called Get_children, which is used to create child nodes.

  

Before activating the class, redefine the Get_children method and activate it. Let's go back to the Refresh method, write down the following code and activate it.  

  

It's just that each record in the loop context node-in other words, the lead record-and uses Node_factory's method get_proxy to create a node for each record. We then use the method Add_root_node to add the root node to the tree. In this scenario, because I get 10 records, I create 10 root nodes.

Pass in the name of the class that you just created in SE24 to the proxy type parameter. We have created the root node, but we have not yet shown it, we need to manually add the Gett method to the proxy class to display the attributes in the tree.

Go to the proxy class "Zcl_tree_proxy_main" Copy method if_bsp_model_setter_getter~_get_xyz Click the Filter check box and copy it to a blank line. Doing so will copy all import export parameters required by the method. Then change the name to get_id. We only copy the Getter method template and rename it based on the property name.  

  

  

Write down the following code to get the ID of the lead.

  

The creation and display of the first-level node is complete, and the next step is to focus on the child nodes (here is the Customer node). To create a second-level node, you need to write code in the Get_children method of the proxy class. We will create a proxy class for the child nodes. Go to SE24 and create a new class by the method above.

  

We also need to showcase our customers. Follow the same procedure to add a getter method Get_prospect, write down the following code.

  

The key point to remember is that we create getter methods in the proxy class, which are not part of the context node class.

The display of the child node is complete, but we did not create it. Now go to the first class you created, "Zcl_tree_proxy_main," and write the code in the Get children method.

  

  

  

What did the code do?

Here we use some BOL programming to get the customer of the lead, so we need to go through some relationships to reach the target entity Btpartner. I read all the partners of the lead.

After getting all the partners, loop each partner, using the node factory method and the "zcl_tree_proxy_custome" created above to create the child nodes.

After the child node is created, set the Is_leaf property to True because in this scenario, the customer is the last level, after which no child nodes under any clients are displayed. Therefore, no arrows appear adjacent to the Child node's folder icon.

Next, create two event handlers in the view implementation class, named Collapse and expand, and write the following code.

  

  

As the name suggests, they are triggered when you collapse or expand a node.

The last thing we need to do is to add a bit of code to the Do PREPARE output method to invoke the Refresh method.

  

Now you can run the app and watch the output.

When you look at this tutorial for the first time, there will be a lot of steps, but in fact, it's not that hard.

If you want to display the address as a child of the client, you need to create a new proxy class that writes code through the BOL relationship between the client and the address in the GET children method of the customer proxy class. And you need to add a getter method to the proxy class to display the address. Don't forget to add a new "address" column to the Get_table_line_sample.

You can try it yourself. Hope this article can help you, but also hope you can recommend this site to your colleague, if you think it is worth it.

This article link: http://www.cnblogs.com/hhelibeb/p/6035059.html

Original link: TREE VIEW

  

  

  

  

SAP CRM tree view

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.