我们登录 SAP CRM WebUI,在搜索框里输入 product id:JavaScript
,进行搜索:
找到一条匹配记录,点击之后可以进入明细页面:
完整的 ABAP 代码:
*&---------------------------------------------------------------------*
*& Report ZBOL_SEARCH_BY_ID
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zbol_search_by_id.
DATA: lo_core TYPE REF TO cl_crm_bol_core,
lo_collection TYPE REF TO if_bol_entity_col,
lv_view_name TYPE crmt_view_name,
lt_select_para TYPE genilt_selection_parameter_tab,
lv_size TYPE i.
APPEND INITIAL LINE TO lt_select_para ASSIGNING FIELD-SYMBOL(<single>).
*<single> = VALUE #( attr_name = 'PRODUCT_ID' sign = 'I' option = 'EQ'
* low = 'JERRYTESTFORISSUE5' ).
<single> = VALUE #( attr_name = 'ONLY_01_02' sign = 'I' option = 'EQ'
low = 'X' ).
data(id) = value genilt_selection_parameter( attr_name = 'PRODUCT_ID'
sign = 'I' option = 'EQ' low = 'JAVASCRIPT').
append id to lt_select_para.
lo_core = cl_crm_bol_core=>get_instance( ).
lo_core->load_component_set( 'PROD_ALL' ).
DATA(ls_query_parameter) = VALUE genilt_query_parameters( max_hits = 100 ).
lo_collection = lo_core->dquery(
iv_query_name = 'ProdAdvSearchRgProducts'
it_selection_parameters = lt_select_para
iv_view_name = lv_view_name
is_query_parameters = ls_query_parameter ).
lv_size = lo_collection->if_bol_bo_col~size( ).
WRITE:/ 'size:', lv_size.
"ASSERT lv_size = 1.
IF lv_size > 0.
WRITE:/ 'ok'.
ELSE.
WRITE:/ 'FAIL'.
ENDIF.
DATA(FIRST) = lo_collection->get_first( ).
DATA(LV_ID) = FIRST->get_property_as_string( 'PRODUCT_ID' ).
WRITE:/ | PRODUCT ID: { lv_id } | COLOR COL_GROUP.
执行结果,成功搜索到一条记录,并打印出 product id:
网友评论