二维码

[教程] LAYOUT OF SEARCH VIEW PAGE

Twilight发表于 2015-12-03 00:18Twilight 最后回复于 2015-12-03 00:18 [复制链接] 2733 0

DESIGNING LAYOUT:When we created the search view, framework automatically creates one .htm page for us. We will use this page to show the output to the user.
Search layout 1.jpg

BSP technology supports HTML. But in SAP has developed new tags which will make developer work very easy.
For all advance search pages, we use <thtmlb: advanced Search> tag to display the input fields. User will enter the selection criteria using these search fields.

Just double click on SEARCHPAGE.htm and add the following tag in that page.
SearchPage.htm:
  1. <%@page language="abap" %>
  2. <%@extension name="thtmlb" prefix="thtmlb" %>
  3. <%@extension name="chtmlb" prefix="chtmlb" %>
  4. <%@extension name="bsp" prefix="bsp" %>
  5. <thtmlb:advancedSearch id                = "advs0"
  6.                        fieldMetadata     = "<%= controller->GET_DQUERY_DEFINITIONS( ) %>"
  7.                        header            = "<%= SEARCH->get_param_struct_name( ) %>"
  8.                        fieldNames        = "<%= controller->GET_POSSIBLE_FIELDS( ) %>"
  9.                        values            = "//SEARCH/PARAMETERS"
  10.                        maxHits           = "//SEARCH/MAX_HITS"
  11.                        ajaxDeltaHandling = "false"
  12.                        onEnter           = "search" />
复制代码
When you do syntax check, it will throw some errors.

Why?
Obviously, this tag has certain properties for which we need to use some methods. These methods do not exist in our class.

What to do?
Here we need to know one important thing that every normal view controller in the WEB UI is inheriting one class I.E CL_BSP_WD_VIEW_CONTROLLER.

Double click on view implementation class, go to properties, you can see ‘ZL_ZTUTCOMP_SEARCHPAGE’ as super class. Double click on it again and in the properties tab you can find CL_BSP_WD_VIEW_CONTROLLER as super class.

For normal view, this class is enough. For search view, SAP has provided another special controller that we need to use to give correct input to the ADVANCEDSEARCH tag.
Search layout 2.jpg
All we need to do is , change the super class of ZL_ZTUTCOMP_SEARCHPAGE from CL_BSP_WD_VIEW_CONTROLLER  to ‘CL_CRM_BP_ADVSEARCH_CONTROLLER’. This class  provides the methods GET DQUERY DEFINITIONS and GET POSSIBLE FIELDS.

Go to the class and change to edit mode. Go to the properties tab. Change the description and click on CHANGE INHERITANCE button. Give the class as above mentioned. Choose yes in the next popup.

We are not finished yet, again go to the .htm page and repeat the syntax check. It will throw one more error. This time error related to the context node SEARCH.

System will add the context nodes to the .htm page as properties. So that we can use the methods or attributes of context node class.
Search layout 3.jpg

Here also our context node is not a normal context node. It is a search context node.

All general context nodes classes have ‘CL_BSP_WD_CONTEXT_NODE’ as super class. If they are table type context nodes, then they have ‘CL_BSP_WD_CONTEXT_NODE_TV’ as super class.  

However search type context nodes need to have ‘CL_BSP_WD_CONTEXT_NODE_ASP’ as a super class. This class will provide necessary methods for doing advanced search.

Change the super class of the context node class ZL_ZTUTCOMP_SEARCHPAGE_CN00.
Search layout 4.jpg

Save and activate the class.
Now go to the .htm page, we won’t any syntax errors. Activate the page. Now we almost finished the search view.

We can test it now. Come back the component and press on test application button. It will invoke new browser session. Give user id and password to complete the authentication.

OOPS. I could not see any output.  It’s a blank page.

Why?
Let us discuss it in the next chapter.
回复

使用道具 举报

快速回帖

本版积分规则
您需要登录后才可以回帖 登录 | 注册有礼

快速回复 返回顶部 返回列表