UI基础三:简单的BOL报表开发
Posted ^ω^SAp傻X^o^
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UI基础三:简单的BOL报表开发相关的知识,希望对你有一定的参考价值。
巧了。。。刚好一个需求,就直接来撸起来吧。
需要做一个报表:
1.创建查询结构和结果结构
2.创建实施类:
SE24创建ZCL_JPEXPORT_ORDER_IL
更改父类:CL_WCF_GENIL_ABSTR_COMPONENT
重定义方法:GET_DYNAMIC_QUERY_RESULT
METHOD if_genil_appl_intlay~get_dynamic_query_result. TYPES:BEGIN OF ty_order, guid TYPE crmt_object_guid, object_id TYPE crmt_object_id_db, process_type TYPE crmt_process_type, END OF ty_order, BEGIN OF ty_product, product_guid TYPE comt_product_guid, product_id TYPE comt_product_id, short_text TYPE comt_prshtextx, END OF ty_product, BEGIN OF ty_part, guid_hi TYPE crmt_object_guid, addr_nr TYPE ad_addrnum, addr_type TYPE ad_adrtype, partner_fct TYPE crmt_partner_fct, END OF ty_part, BEGIN OF ty_adrc, addrnumber TYPE ad_addrnum, name1 TYPE ad_name1, smtp_addr TYPE ad_smtpadr, tel_number TYPE ad_tlnmbr1, street TYPE ad_street, str_suppl1 TYPE ad_strspp1, str_suppl2 TYPE ad_strspp2, post_code1 TYPE ad_pstcd1, city1 TYPE ad_city1, END OF ty_adrc. DATA: lt_selection TYPE axtt_tables_sel_param, ls_selection TYPE axt_tables_sel_param, rt_object_id TYPE RANGE OF crmt_object_id, rs_object_id LIKE LINE OF rt_object_id, rt_process_type TYPE RANGE OF crmt_process_type, rs_process_type LIKE LINE OF rt_process_type, rt_cgi_date TYPE RANGE OF zadtel00009q, rs_cgi_date LIKE LINE OF rt_cgi_date, rt_cgi_time TYPE RANGE OF zadtel00009u, rs_cgi_time LIKE LINE OF rt_cgi_time, lx_root TYPE REF TO cx_root. "#EC NEEDED DATA:gt_order TYPE TABLE OF ty_order, gw_order LIKE LINE OF gt_order, gt_product TYPE TABLE OF ty_product, gw_product LIKE LINE OF gt_product, gt_part TYPE TABLE OF ty_part, vt_part TYPE TABLE OF ty_part, gw_part LIKE LINE OF gt_part, gt_adrc TYPE TABLE OF ty_adrc, gw_adrc LIKE LINE OF gt_adrc, gv_index TYPE i. " DATA ls_selection_paras TYPE genilt_selection_parameter. DATA lt_where_condition TYPE crmt_report_dyn_sql_line_ta. DATA: gt_result TYPE TABLE OF zcrms0056, vt_result TYPE TABLE OF zcrms0056, ls_result TYPE zcrms0056. DATA: lv_maxhit TYPE int4, lv_object_key TYPE crmt_bsp_objectkey, lr_object TYPE REF TO if_genil_cont_root_object. DEFINE set_result. LOOP AT GT_RESULT INTO LS_RESULT. LR_OBJECT = IV_ROOT_LIST->ADD_OBJECT( IV_OBJECT_NAME = \'ZTCRESULT\' IS_OBJECT_KEY = LS_RESULT-GUID ). LV_OBJECT_KEY = LS_RESULT-GUID. LR_OBJECT->SET_KEY( LV_OBJECT_KEY ). LR_OBJECT->SET_ATTRIBUTES( LS_RESULT ). CLEAR LS_RESULT. ENDLOOP. END-OF-DEFINITION . lt_selection = it_selection_parameters. * SORT LT_SELECTION BY ATTR_NAME. LOOP AT lt_selection INTO ls_selection. CASE ls_selection-attr_name. WHEN \'ZZAFLD00001Y\'. MOVE-CORRESPONDING ls_selection TO rs_cgi_time. INSERT rs_cgi_time INTO TABLE rt_cgi_time. WHEN \'PROCESS_TYPE\'. MOVE-CORRESPONDING ls_selection TO rs_process_type. INSERT rs_process_type INTO TABLE rt_process_type. WHEN \'ZZAFLD00001X\'. MOVE-CORRESPONDING ls_selection TO rs_cgi_date. INSERT rs_cgi_date INTO TABLE rt_cgi_date. ENDCASE. ENDLOOP. lv_maxhit = is_query_parameters-max_hits. SELECT b~guid a~guid AS header a~po_number_sold a~zzztrackreturn a~zzafld000001 b~zzafld00001x AS zzgi_date b~description AS short_text INTO CORRESPONDING FIELDS OF TABLE gt_result FROM zhsb_sales_index AS a INNER JOIN crmd_orderadm_i AS b ON a~guid = b~header WHERE a~process_type = \'ZSO5\' AND a~sales_org = \'O 50000231\' AND a~sold_to_party = \'0000202693\' AND b~zzafld00001x IN rt_cgi_date AND b~zzafld00001y IN rt_cgi_time AND b~itm_type = \'ZSO5\'. "取前置服务工单 vt_result[] = gt_result[]. DELETE vt_result WHERE po_number_sold IS INITIAL. IF vt_result[] IS NOT INITIAL. SELECT guid object_id process_type INTO TABLE gt_order FROM zhsb_order_index FOR ALL ENTRIES IN vt_result WHERE object_id = vt_result-po_number_sold+0(10) AND process_type = \'ZSV1\'. ENDIF. "取合作伙伴ship to REFRESH:vt_result. vt_result[] = gt_result[]. SORT vt_result BY header. DELETE ADJACENT DUPLICATES FROM vt_result COMPARING header. IF vt_result[] IS NOT INITIAL. SELECT crmd_link~guid_hi crmd_partner~addr_nr crmd_partner~addr_type crmd_partner~partner_fct INTO TABLE gt_part FROM crmd_link INNER JOIN crmd_partner ON crmd_link~guid_set = crmd_partner~guid FOR ALL ENTRIES IN vt_result WHERE crmd_link~guid_hi = vt_result-header AND crmd_partner~partner_fct = \'00000002\' AND crmd_link~objtype_set = \'07\'."PARTNER REFRESH:vt_part. vt_part[] = gt_part[]. SORT vt_part BY addr_nr. DELETE ADJACENT DUPLICATES FROM vt_part COMPARING addr_nr. IF vt_part[] IS NOT INITIAL. SELECT adrc~addrnumber adrc~name1 adr6~smtp_addr adrc~tel_number adrc~street adrc~str_suppl1 adrc~str_suppl2 adrc~post_code1 adrc~city1 INTO TABLE gt_adrc FROM adrc LEFT JOIN adr6 ON adrc~addrnumber = adr6~addrnumber FOR ALL ENTRIES IN vt_part WHERE adrc~addrnumber = vt_part-addr_nr. REFRESH:vt_part. ENDIF. ENDIF. SORT gt_part BY guid_hi. SORT gt_adrc BY addrnumber. LOOP AT gt_result INTO ls_result. READ TABLE gt_order INTO gw_order WITH KEY object_id = ls_result-po_number_sold+0(10). IF sy-subrc <> 0. CONTINUE. ENDIF. ls_result-name2 = \'固定值\'. "赋值联系人信息 READ TABLE gt_part INTO gw_part WITH KEY guid_hi = ls_result-header BINARY SEARCH. IF sy-subrc = 0. READ TABLE gt_adrc INTO gw_adrc WITH KEY addrnumber = gw_part-addr_nr BINARY SEARCH. IF sy-subrc = 0. ls_result-tel_number = gw_adrc-tel_number. ls_result-post_code1 = gw_adrc-post_code1. ls_result-street = gw_adrc-street. ls_result-str_suppl1 = gw_adrc-str_suppl1. ls_result-name1 = gw_adrc-name1. ENDIF. ENDIF. MODIFY gt_result FROM ls_result. ENDLOOP. set_result. ENDMETHOD.
注意在处理Object key的时候一定不能有重复,不然会dump
3.创建BOL对象
t-code:GENIL_MODEL_BROWSER
创建结果对象
定义动态搜索对象:
到此对象创建完成,点击transport将对象数据添加到请求中
4.创建组件集:
5.创建搜索页面
T-CODE:BSP_WD_CMPWB
输入组件名:ZHSI_JPEXP点击创建
4.1添加BOL模型节点
点击:Runtime Repository Editor
点击编辑按钮
右键Model节点,添加model:ZJPEXP保存
4.2创建搜索页面:
以上是关于UI基础三:简单的BOL报表开发的主要内容,如果未能解决你的问题,请参考以下文章