前面写的FPM都是自己练习用的。直到自己正式用了一个,才发现一些小问题。feeder class写在一起和分开写有好有坏,这里就不说了。
自己做了个小的查询报表如下:
现在来按SAP官方的做法来重新做练习。
一.整体结构:
1.search structure,feeder class,search event process
2.list structure,feeder class
3.Application Controller CLass
这是双主表查询,而且表名较长,沿用了前面练习里的转换模式,所以代码看起来繁琐些。
二:具体实施:
1.查询结构:
结果结构:
Controller的Feeder class:添加接口类,并激活下面的方法。
Search 的Feeder class:添加接口类,并激活下面的方法。
LIST的Feeder class:添加接口类,激活方法。
Search的Feeder class实现:
METHOD if_fpm_guibb_search~get_definition. DATA:gt_field TYPE TABLE OF fpmgb_s_searchfield_descr, gw_field TYPE fpmgb_s_searchfield_descr, gt_value TYPE fpmgb_t_namevalue, gw_value TYPE fpmgb_s_namevalue. DEFINE setv. gw_value-value = &1. gw_value-name = &2. APPEND gw_value TO gt_value. END-OF-DEFINITION. eo_field_catalog_attr ?= cl_abap_structdescr=>describe_by_name( 'ZCRMJP002' ). "品牌下拉 gw_field-name = 'ZZZBRAND'. SELECT line_key AS value value1 AS name INTO CORRESPONDING FIELDS OF TABLE gt_value FROM zcrmt_domain_t WHERE tab_name = 'ZTVS_BRAND' AND spras = sy-langu. gw_field-enumeration[] = gt_value[]. gw_field-is_of_type = 'EN'. APPEND gw_field TO et_field_description_attr. "inprogress 下拉 CLEAR:gt_value[],gw_field. gw_field-name = 'ZZDLYRSN'. SELECT estat AS value text AS name INTO CORRESPONDING FIELDS OF TABLE gt_value FROM zdelay_reason WHERE spras = 'J'."sy-langu. gw_field-enumeration[] = gt_value[]. gw_field-is_of_type = 'EN'. APPEND gw_field TO et_field_description_attr. "inprogress 下拉 CLEAR:gt_value[],gw_field. gw_field-name = 'DATE_RANGE'. setv 'D+0' 'D+0 今日'. setv 'D-1' 'D-1 昨日'. setv 'M+0' 'M+0 今月'. setv 'M-1' 'M-1 先月'. * setv 'W+0' 'W+0 今週'. * setv 'W-1' 'W-1 先週'. setv 'Y+0' 'Y+0 今年'. setv 'Y-1' 'Y-1 去年'. gw_field-enumeration[] = gt_value[]. gw_field-max_1_value = 'X'. gw_field-is_of_type = 'EN'. APPEND gw_field TO et_field_description_attr. "CHARG TYPE 下拉 CLEAR:gt_value[],gw_field. gw_field-name = 'ZZCHARG_TYPE'. SELECT line_key AS value value1 AS name INTO CORRESPONDING FIELDS OF TABLE gt_value FROM zcrmt_domain_t WHERE spras = 'J'"sy-langu. AND tab_name = 'ZJP_REPAIR_CHARGETPYE'. gw_field-enumeration[] = gt_value[]. gw_field-is_of_type = 'EN'. APPEND gw_field TO et_field_description_attr. "Process Type 下拉 CLEAR:gt_value[],gw_field. gw_field-name = 'PROCESS_TYPE'. SELECT process_type AS value p_description_20 AS name INTO CORRESPONDING FIELDS OF TABLE gt_value FROM crmc_proc_type_t WHERE langu = sy-langu AND ( process_type BETWEEN 'ZSV1' AND 'ZSV4' OR process_type EQ 'ZWO3' OR process_type EQ 'ZWO4' ). gw_field-enumeration[] = gt_value[]. gw_field-ddic_shlp_name = 'ZCRM_PROCESS_TYPE'. gw_field-is_of_type = 'EN'. APPEND gw_field TO et_field_description_attr. ENDMETHOD.
METHOD if_fpm_guibb_search~process_event. DATA:lr_fpm TYPE REF TO if_fpm, lr_event_data TYPE REF TO cl_fpm_parameter. IF io_event->mv_event_id = if_fpm_guibb_search=>fpm_execute_search. "取当前FPM对象实例 lr_fpm = cl_fpm_factory=>get_instance( ). "创建FPM传输参数对象 CREATE OBJECT lr_event_data. "将查询条件信息赋值到参数对象 lr_event_data->if_fpm_parameter~set_value( iv_key = 'SEL_TAB' iv_value = it_fpm_search_criteria ). lr_event_data->if_fpm_parameter~set_value( iv_key = 'MAX_NUM' iv_value = iv_max_num_results ). "数据抛转 lr_fpm->raise_event_by_id( iv_event_id = if_fpm_guibb_list=>gc_event_list_filter io_event_data = lr_event_data ). ENDIF. ENDMETHOD.
LIST的Feeder Class处理:
定义结构表:
METHOD if_fpm_guibb_list~get_data. IF iv_eventid->mv_event_id = if_fpm_guibb_list=>gc_event_list_filter. ct_data = gt_result. ev_data_changed = abap_true. ENDIF. ENDMETHOD.
METHOD if_fpm_guibb_list~get_definition. DATA:gt_table TYPE TABLE OF zcrmjp003. DATA:gw_field TYPE fpmgb_s_listfield_descr, gt_value TYPE wdr_context_attr_value_list, gt_dd03l TYPE TABLE OF dd03l, gw_dd03l LIKE LINE OF gt_dd03l. eo_field_catalog ?= cl_abap_tabledescr=>describe_by_data( gt_table ). SELECT * INTO TABLE gt_dd03l FROM dd03l WHERE tabname = 'ZCRMJP003' AND inttype = 'C'. LOOP AT gt_dd03l INTO gw_dd03l. gw_field-name = gw_dd03l-fieldname. gw_field-allow_sort = 'X'. gw_field-allow_filter = 'X'. APPEND gw_field TO et_field_description. ENDLOOP. ENDMETHOD.
METHOD if_fpm_guibb_list~process_event. DATA:lt_fpm_search TYPE fpmgb_t_search_criteria, lv_max TYPE i, ls_rsds TYPE rsdsselopt. TYPES: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, region TYPE regio, END OF ty_adrc, BEGIN OF ty_type, process_type TYPE crmt_process_type, p_description_20 TYPE crmt_description_20, user_stat_proc TYPE j_stsma, END OF ty_type, BEGIN OF ty_zso1, object_id TYPE crmt_object_id, zzrepchg_type TYPE zsrve_repchg_type, ref_object_id TYPE crmt_object_id, END OF ty_zso1, BEGIN OF ty_item, guid TYPE crmt_object_guid, header TYPE crmt_object_guid, zzzsp_price TYPE zadtel000072, zzafld00001f TYPE zadtel000073, quantity TYPE crmt_schedlin_quan, END OF ty_item, BEGIN OF ty_head, guid TYPE crmt_object_guid, zzafld000005 TYPE zadtel000018, zzfld00000j TYPE zdtel00003p, zzfld00000k TYPE zdtel00003q, zzafld00001c TYPE zadtel000081, END OF ty_head. DATA:lt_where TYPE rsds_where_tab, ls_where LIKE LINE OF lt_where, vt_where TYPE rsds_where_tab. DATA:lt_order TYPE TABLE OF zcrmjp003, ls_order TYPE zcrmjp003. DATA:lc_para TYPE REF TO cl_fpm_parameter. DATA:ls_value TYPE string, rt_zzafld000005 TYPE RANGE OF zadtel000018, rs_zzafld000005 LIKE LINE OF rt_zzafld000005, rt_zzztransaid TYPE RANGE OF ztransaid, rs_zzztransaid LIKE LINE OF rt_zzztransaid, gt_search_index TYPE fpmgb_t_search_criteria, gw_search LIKE LINE OF gt_search_index, gt_search_head TYPE fpmgb_t_search_criteria, gt_protype TYPE TABLE OF crmc_proc_type_t, gw_protype TYPE crmc_proc_type_t, 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, gt_type TYPE TABLE OF ty_type, gw_type LIKE LINE OF gt_type, gt_tj30t TYPE TABLE OF tj30t, gw_tj30t LIKE LINE OF gt_tj30t, gt_zso1 TYPE TABLE OF ty_zso1, gw_zso1 LIKE LINE OF gt_zso1, gt_zcrmt0046 TYPE TABLE OF zcrmt0046, gw_zcrmt0046 LIKE LINE OF gt_zcrmt0046, gt_head TYPE TABLE OF ty_head, gw_head LIKE LINE OF gt_head, gt_item TYPE TABLE OF ty_item, gw_item LIKE LINE OF gt_item, gt_domain TYPE TABLE OF zcrmt_domain_t, gw_domain TYPE zcrmt_domain_t, v_e0075 TYPE datum, v_e0080 TYPE datum, v_ss TYPE string, v_ll TYPE string, v_flag TYPE c, gv_index TYPE i. DATA:ls_result TYPE zcrmjp003. IF io_event->mv_event_id = if_fpm_guibb_list=>gc_event_list_filter. io_event->mo_event_data->get_value( EXPORTING iv_key = 'SEL_TAB' IMPORTING ev_value = lt_fpm_search ). io_event->mo_event_data->get_value( EXPORTING iv_key = 'MAX_NUM' IMPORTING ev_value = lv_max ). REFRESH:gt_result. gt_search_index[] = lt_fpm_search[]."转移查询条件,待处理. LOOP AT gt_search_index INTO gw_search. gv_index = sy-tabix. IF gw_search-search_attribute = 'ZNOT_CHARGED' AND gw_search-low IS NOT INITIAL. v_flag = 'X'. DELETE gt_search_index INDEX gv_index. ENDIF. IF gw_search-search_attribute = 'ZZAFLD000005' OR gw_search-search_attribute = 'ZZZTRANSAID' OR gw_search-search_attribute = 'ZZCANSHIP'. APPEND gw_search TO gt_search_head. DELETE gt_search_index INDEX gv_index. ENDIF. IF gw_search-search_attribute = 'DATE_RANGE'."时间周期 DATA:v_date TYPE datum. DELETE gt_search_index INDEX gv_index. gw_search-search_attribute = 'POSTING_DATE'. IF gw_search-low = 'D+0'."今天 gw_search-low = sy-datlo. ELSEIF gw_search-low = 'D-0'."昨天 gw_search-low = sy-datlo - 1. ELSEIF gw_search-low = 'M+0'."当月 gw_search-low = sy-datlo+0(6) && '01'. gw_search-high = sy-datlo. gw_search-operator = 10. ELSEIF gw_search-low = 'M-1'."上月 v_date = sy-datlo+0(6) && '01'."当月1号 v_date = v_date - 1."上月底 gw_search-low = sy-datlo+0(6) && '01'. gw_search-high = v_date. gw_search-operator = 10. ELSEIF gw_search-low = 'Y+0'."今年 gw_search-low = sy-datlo+0(4) && '0101'. gw_search-high = sy-datlo+0(4) && '1231'. gw_search-operator = 10. ELSEIF gw_search-low = 'Y+-1'."去年 v_date = sy-datlo+0(4) && '0101'."今年1号 v_date = v_date - 1."去年年底 gw_search-low = v_date+0(4) && '0101'. gw_search-high = v_date. gw_search-operator = 10. ENDIF. APPEND gw_search TO gt_search_index. ENDIF. ENDLOOP. IF gt_search_index[] IS NOT INITIAL. TRY . CALL METHOD cl_fpm_guibb_search_conversion=>to_abap_select_where_tab EXPORTING it_fpm_search_criteria = gt_search_index iv_table_name = 'ZHSB_ORDER_INDEX' * io_field_catalog = mo_catalog IMPORTING et_abap_select_table = lt_where. CATCH cx_fpmgb. ENDTRY. APPEND LINES OF lt_where TO vt_where.REFRESH:lt_where. ENDIF. IF gt_search_head[] IS NOT INITIAL. TRY . CALL METHOD cl_fpm_guibb_search_conversion=>to_abap_select_where_tab EXPORTING it_fpm_search_criteria = gt_search_head iv_table_name = 'CRMD_ORDERADM_H' * io_field_catalog = mo_catalog IMPORTING et_abap_select_table = lt_where. CATCH cx_fpmgb. ENDTRY. IF vt_where IS NOT INITIAL. APPEND 'AND' TO vt_where. ENDIF. APPEND LINES OF lt_where TO vt_where.REFRESH:lt_where. ENDIF. LOOP AT vt_where INTO ls_where. LOOP AT gt_search_index INTO gw_search. SEARCH ls_where FOR gw_search-search_attribute. IF sy-subrc = 0. CONCATENATE gw_search-search_attribute ` ` INTO v_ll. CONCATENATE 'a~' gw_search-search_attribute INTO v_ss. REPLACE ALL OCCURRENCES OF v_ll IN ls_where WITH v_ss . ENDIF. ENDLOOP. LOOP AT gt_search_head INTO gw_search. SEARCH ls_where FOR gw_search-search_attribute. IF sy-subrc = 0. CONCATENATE gw_search-search_attribute ` ` INTO v_ll. CONCATENATE 'b~' gw_search-search_attribute INTO v_ss. REPLACE ALL OCCURRENCES OF v_ll IN ls_where WITH v_ss . ENDIF. ENDLOOP. APPEND ls_where TO lt_where. ENDLOOP. REFRESH:vt_where. IF v_flag = 'X'. IF lt_where[] IS NOT INITIAL. APPEND 'AND ( A~TXT04 = ''Z075'' )' TO lt_where. APPEND 'AND ( A~ZZWARRANTY IN (''O'',''E'') )' TO lt_where. APPEND 'AND ( A~PROCESS_TYPE = ''ZSV1'' )' TO lt_where. APPEND 'AND ( A~ZZONTIME = '''' )' TO lt_where. ELSE. APPEND ' A~TXT04 = ''Z075'' ' TO lt_where. APPEND 'AND ( A~ZZWARRANTY IN (''O'',''E'') )' TO lt_where. APPEND 'AND ( A~PROCESS_TYPE = ''ZSV1'' )' TO lt_where. APPEND 'AND ( A~ZZONTIME = '''' )' TO lt_where. ENDIF. ENDIF. SELECT a~guid a~object_id a~process_type a~stat_user AS estat a~description * b~zzafld000005 * b~zzfld00000j AS zzfld00000j * b~zzfld00000k AS zzfld00000k * b~zzzafld00001c AS zzzafld00001c a~end_user AS soldto a~created_at a~zzzbrand a~zzwarranty a~zzcharg_type a~provider AS zs_provider_id a~po_number_sold a~created_by a~zzzsymptomsgroup * b~zzfld00000j AS zzfld00000j * b~zzfld00000k AS zzfld00000k * b~zzzafld00001c INTO CORRESPONDING FIELDS OF TABLE lt_order FROM zhsb_order_index AS a INNER JOIN crmd_orderadm_h AS b ON a~guid = b~guid UP TO lv_max ROWS WHERE (lt_where). * INTO CORRESPONDING FIELDS OF TABLE lt_order UP TO iv_max_num_results ROWS WHERE (lt_where). IF sy-subrc = 0. "取品牌描述,取收费类型描述 SELECT * INTO TABLE gt_domain FROM zcrmt_domain_t WHERE tab_name = 'ZTVS_BRAND' AND spras = 'J'. SELECT * APPENDING TABLE gt_domain FROM zcrmt_domain_t WHERE tab_name = 'ZJP_REPAIR_CHARGETPYE' AND spras = 'J'."sy-langu. SORT lt_order BY object_id ASCENDING. SELECT guid zzafld000005 zzfld00000j zzfld00000k zzzafld00001c INTO TABLE gt_head FROM crmd_orderadm_h FOR ALL ENTRIES IN lt_order WHERE guid = lt_order-guid. SELECT crmc_proc_type~process_type crmc_proc_type_t~p_description_20 crmc_proc_type~user_stat_proc INTO TABLE gt_type FROM crmc_proc_type INNER JOIN crmc_proc_type_t ON crmc_proc_type~process_type = crmc_proc_type_t~process_type WHERE ( crmc_proc_type~process_type BETWEEN 'ZSV1' AND 'ZSV4' OR crmc_proc_type~process_type EQ 'ZWO3' OR crmc_proc_type~process_type EQ 'ZWO4' ) AND crmc_proc_type_t~langu = 'J'."sy-langu."取单据类型描述. IF gt_type IS NOT INITIAL. SELECT * INTO TABLE gt_tj30t FROM tj30t FOR ALL ENTRIES IN gt_type WHERE stsma = gt_type-user_stat_proc AND spras = 'J'."sy-langu."取状态描述. ENDIF. "取partner信息 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 lt_order WHERE crmd_link~guid_hi = lt_order-guid AND crmd_partner~partner_fct IN ('00000001','ZHSI00SP') 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 adrc~region 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. "取后续符合条件的ZSO1单据 SELECT object_id zzrepchg_type ref_object_id INTO TABLE gt_zso1 FROM zhsb_sales_index FOR ALL ENTRIES IN lt_order WHERE ref_object_id = lt_order-object_id AND sales_org = 'O 50000231' AND process_type = 'ZSO1' AND stat_user <> 'E0007'. "取In Progress的变更日志 SELECT * INTO TABLE gt_zcrmt0046 FROM zcrmt0046 FOR ALL ENTRIES IN lt_order WHERE bt_guid = lt_order-guid AND zzdlyrsn IN ('E0075','E0080'). "取项目数量金额 SELECT crmd_orderadm_i~guid crmd_orderadm_i~header crmd_orderadm_i~zzzsp_price crmd_orderadm_i~zzafld00001f crmd_schedlin~quantity INTO TABLE gt_item FROM crmd_orderadm_i INNER JOIN crmd_schedlin ON crmd_schedlin~item_guid = crmd_orderadm_i~guid FOR ALL ENTRIES IN lt_order WHERE crmd_schedlin~event_type = 'ORDER' AND crmd_orderadm_i~header = lt_order-guid. LOOP AT lt_order INTO ls_order. MOVE-CORRESPONDING ls_order TO ls_result. READ TABLE gt_head INTO gw_head WITH KEY guid = ls_order-guid. IF sy-subrc = 0. ls_result-zzafld000005 = gw_head-zzafld000005. ls_result-zzfld00000j = gw_head-zzfld00000j. ls_result-zzfld00000k = gw_head-zzfld00000k. ls_result-zzafld00001c = gw_head-zzafld00001c. ENDIF. READ TABLE gt_type INTO gw_type WITH KEY process_type = ls_order-process_type. IF sy-subrc = 0. ls_result-process_type_txt = gw_type-p_description_20. READ TABLE gt_tj30t INTO gw_tj30t WITH KEY stsma = gw_type-user_stat_proc estat = ls_result-estat. IF sy-subrc = 0. ls_result-concatstatuser = gw_tj30t-txt30. ENDIF. ENDIF. "取partner信息 READ TABLE gt_part INTO gw_part WITH KEY guid_hi = ls_order-guid partner_fct = '00000001'. IF sy-subrc = 0. READ TABLE gt_adrc INTO gw_adrc WITH KEY addrnumber = gw_part-addr_nr. IF sy-subrc = 0. CONCATENATE gw_adrc-name1 '/' gw_adrc-city1 space gw_adrc-post_code1 INTO ls_result-sold_to_party_list. ENDIF. ENDIF. READ TABLE gt_part INTO gw_part WITH KEY guid_hi = ls_order-guid partner_fct = 'ZHSI00SP'. IF sy-subrc = 0. READ TABLE gt_adrc INTO gw_adrc WITH KEY addrnumber = gw_part-addr_nr. IF sy-subrc = 0. ls_result-zs_provider_name = gw_adrc-name1. ENDIF. ENDIF. LOOP AT gt_zso1 INTO gw_zso1 WHERE ref_object_id = ls_result-object_id. IF ls_result-zzwarranty = 'E' AND gw_zso1-zzrepchg_type = '20'. ls_result-zeucorder = gw_zso1-object_id. ELSEIF ls_result-zzwarranty = 'O' AND ls_result-zzcharg_type <> '10'. ls_result-zeucorder = gw_zso1-object_id. ELSEIF ls_result-zzcharg_type = '10'. ls_result-zrcorder = gw_zso1-object_id. ELSEIF ls_result-zzcharg_type <> '10' AND ls_result-zzwarranty = 'E' AND ls_result-zzcharg_type = '10'. ls_result-zrcorder = gw_zso1-object_id. ENDIF. ENDLOOP. LOOP AT gt_zcrmt0046 INTO gw_zcrmt0046 WHERE bt_guid = ls_order-guid. IF gw_zcrmt0046-zzdlyrsn = 'E0075'. v_e0075 = gw_zcrmt0046-crdat. ELSEIF gw_zcrmt0046-zzdlyrsn = 'E0080'. v_e0080 = gw_zcrmt0046-crdat. ENDIF. ENDLOOP. IF v_e0075 IS NOT INITIAL AND v_e0080 IS NOT INITIAL. CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS' EXPORTING i_date_from = v_e0080 i_date_to = v_e0075 IMPORTING e_days = ls_result-zquote_day. ENDIF. LOOP AT gt_item INTO gw_item WHERE header = ls_order-guid. ls_result-zclamun = ls_result-zclamun + gw_item-zzzsp_price * gw_item-quantity. ENDLOOP. READ TABLE gt_domain INTO gw_domain WITH KEY tab_name = 'ZTVS_BRAND' line_key = ls_order-zzzbrand. IF sy-subrc = 0. ls_result-zzzbrandt = gw_domain-value1. ENDIF. READ TABLE gt_domain INTO gw_domain WITH KEY tab_name = 'ZJP_REPAIR_CHARGETPYE' line_key = ls_order-zzcharg_type. IF sy-subrc = 0. ls_result-zzcharg_typet = gw_domain-value1. ENDIF. APPEND ls_result TO gt_result. CLEAR:ls_result. ENDLOOP. ENDIF. IF gt_result[] IS NOT INITIAL. ev_result = 'OK'. ENDIF. ENDIF. ENDMETHOD.
下面开始FPM页面配置。
T-code:FPM_WB.
点击创建空的FPM程序。
输入程序名称和描述,选择OverView Page
保存本地。
点击编辑配置。
....剩下的好像搞了几百遍了,添加SEARCH UIBB.LIST UIBB.配置,添加字段。。。不写了,浪费时间。
最后结果如下图: