I intend to show how easy it is to implement value lookup scenarios (F4 helps) in WebDynpro for ABAP (WDA). Using Search Helps attachments helps to implement various value lookup scenarios, eliminating the need to code for the same.
Before we begin with the scenarios, for your information, a search help can be attached at various levels:
1) Directly attached to the component that intends to use the search help
2) Attached to the table/structure being referenced or used in the component
3) Attached to the data element of the component
Here I would like to demonstrate the use of search help attachments with dictionary structures, that are used in WDA component.
Let us consider two scenarios:
You have a category id in one database table say ZEP_RCA_CATE_TXT and sub-category id in a different database table say ZEP_RCA_SUBC_TXT with foreign key relationship with ZEP_RCA_CATE_TXT. Now you want to have F4 helps in WDA for category id and subcategory id such that the hit list for subcategory id must be filtered or narrowed based on the value selected for category id.
F4 help values for Category ID
F4 help values for Sub-Category ID (displays all sub-categories as no value selected for category yet)
RCA2 selected for Category ID using F4 help. Now check the values for sub-category ID, only those are displayed that belong to the category ID RCA2.
Change the Category ID to RCA6, the list for sub categories is narrowed to those having RCA6 as the category ID.
Another very common requirement is to display description next to the input box with search help, for the code selected in the input box. See the example below, where based on the org unit selected, the corresponding org unit description must be displayed next to the input box.
Let us see how simple it is to implement the above mentioned scenarios with Search Help attachments!
Step1: Since we have two different tables for category and sub-category, we would create two search helps. Note the import/export parameters of the search helps.
The first search help provides the list of category IDs.
The second search helps takes the category ID as the input (import parameter). The WDA component would receive the categroy ID value selected using the first search help and would pass it to this importing parameter of the second search help.
Step 2: The WebDynpro component uses structure ZEP_STRUCT_LPO_RCA_CHITS, to create view context RCA.
The context node RCA is bound to the view UI elements.
Next, attach the search helps created in Step 1 to this structure in the following way:
Okay so the search helps have been attached to the structure.
Note that the fields RCA_CATID and RCA_CATID_TMP refer to the same entity i.e. category id. We need to use a temporary field in this case to keep a copy of the value selected in RCA_CATID. This temporary field as shown above is a part of the second search help attachment. This is done because category id is required in the second search help too as the importing parameter, to restrict sub categories based on it. Here, two search helps have been used for simplicity; the same can be achieved by using one search help and implementing the seach help exit.
Step 3: Since the OnChangeof event is not yet available for the input field UI element, we need to write code in the wddomodifyview method of the view, to assign value of the context attribte RCA_CATID to RCA_CATID_TMP .
Step 4: You are all set to use the context on the view layout and test the output!
Step 1: Similar to scenario 1, we would need a search help. In this case we have a standard SAP search help H_T527X that can be attached to the structure ZEP_STRUCT_T527X being used in WDA.
Step 2: Now its just the matter of using this structure in WDA view context, and placing the required UI elements like input box and text view on the view layout and binding them to the view context!
Simple! Isn't it?