二维码

[教程] FETCHING THE DATA IN EVENT HANDLER

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

Here we are going to fetch the data based on the selection criteria. One important point to keep in mind is, we never use any select queries at the UI level (some exceptional cases may be there).

We use BOL programming to search, retrieve, update, and delete the data.

We will discuss BOL programming in detail in later chapters. There are some predefine steps to search any data from the UI using BOL programming.

Open the event handler search and paste the following code.
  1. METHOD eh_onsearch.

  2.   DATA:lr_selcriteria TYPE REF TO cl_crm_bol_dquery_service,
  3.        lr_result     TYPE REF TO if_bol_bo_col.

  4.   lr_selcriteria ?= me->typed_context->search->collection_wrapper->get_current( ).
  5.   CHECK lr_selcriteria IS BOUND.
  6.   lr_result = lr_selcriteria->get_query_result( ).

  7. ENDMETHOD.
复制代码

An instance of any dynamic search object can be represented as using the class

CL_CRM_BOL_DQUERY_SERVICE.  If we remember, we used dynamic search object BTQSrvcon to create the context node.  So we declared one reference variable lr_selcriteria.

Generally user will enter some selection criteria and then press SEARCH button. So these selection criteria we need to read from the context node SEARCH.

LR_SELCRITERIA?= ME->TYPED_CONTEXT->SEARCH->COLLECTION_WRAPPER->GET_CURRENT ( ).

Above line does exactly same thing. It will give the selection criteria details in the form of instance of class CL_CRM_BOL_DQUERY_SERVICE and that instance we are taking into variable lr_selcriteria.

Next we will fire the method GET_QUERY_RESULT to retrieve the records that match with the selection criteria.  This method returns the records in the form of collection (just understand collection as container that holds the records) and we are taking that collection into LR_RESULT of type IF_BOL_BO_COL.

Now we have the data.

Oops, where to display this data. Yes we forgot to create one more view to display this results. Let us create result view in our UI component.
回复

使用道具 举报

快速回帖

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

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