FPM里的OVS用法基本和WDA一致。
1,将OVS类添加到SEARCH.(可以单独写个类,因为这里为了方便,就和SEARCH放一起了)
IF_FPM_GUIBB_OVS~HANDLE_PHASE_0 Phase 0 (OVS config, c.f. IF_WD_OVS->set_configuration( ))“设置显示字段
IF_FPM_GUIBB_OVS~HANDLE_PHASE_1 Phase 1 (initialize fields, c.f. set_input_structure( ))"设置输入查询条件
IF_FPM_GUIBB_OVS~HANDLE_PHASE_2 Phase 2 (search, c.f. query_parameters, set_output_table( ))"查询处理
IF_FPM_GUIBB_OVS~HANDLE_PHASE_3 Phase 3 (set return value, c.f. selection)"返回结果
先在SEARCH的定义里,定义使用OVS。
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'. gw_field-ovs_name = 'ZCL_FPM_DEMO_SEARCH'. APPEND gw_field TO et_field_description_attr. ENDMETHOD.
定义结构:
METHOD IF_FPM_GUIBB_OVS~HANDLE_PHASE_0. DATA:LT_COL TYPE WDR_NAME_VALUE_LIST, LS_COL TYPE WDR_NAME_VALUE. IF IV_FIELD_NAME = 'PROCESS_TYPE'. LS_COL-NAME = 'PROCESS_TYPE'. LS_COL-VALUE = 'Porcess Type'. APPEND LS_COL TO LT_COL. LS_COL-NAME = 'P_DESCRIPTION_20'. LS_COL-VALUE = 'Description'. APPEND LS_COL TO LT_COL. ENDIF. IO_OVS_CALLBACK->SET_CONFIGURATION( WINDOW_TITLE = 'Process Type' * GROUP_HEADER = GROUP_HEADER * LABEL_TEXTS = LABEL_TEXTS TABLE_HEADER = 'Process Type List' COLUMN_TEXTS = LT_COL * COL_COUNT = COL_COUNT * ROW_COUNT = ROW_COUNT * TABLE_MULTI_SELECT = TABLE_MULTI_SELECT ). ENDMETHOD.
定义查询字段:
METHOD IF_FPM_GUIBB_OVS~HANDLE_PHASE_1. TYPES:BEGIN OF TY_PROCE, PROCESS_TYPE TYPE CRMT_PROCESS_TYPE, DESCRIPTION TYPE CRMT_DESCRIPTION_20, END OF TY_PROCE. DATA:LS_INPUT TYPE TY_PROCE. IF IV_FIELD_NAME = 'PROCESS_TYPE'. IO_OVS_CALLBACK->CONTEXT_ELEMENT->GET_ATTRIBUTE( EXPORTING NAME = IO_OVS_CALLBACK->CONTEXT_ATTRIBUTE IMPORTING VALUE = LS_INPUT-PROCESS_TYPE ). IO_OVS_CALLBACK->SET_INPUT_STRUCTURE( EXPORTING INPUT = LS_INPUT ). ENDIF. ENDMETHOD.
查询及输出:
METHOD IF_FPM_GUIBB_OVS~HANDLE_PHASE_2. TYPES:BEGIN OF TY_PROCE, PROCESS_TYPE TYPE CRMT_PROCESS_TYPE, DESCRIPTION TYPE CRMT_DESCRIPTION_20, END OF TY_PROCE. DATA:GT_LIST TYPE TABLE OF TY_PROCE. FIELD-SYMBOLS:<FS> TYPE TY_PROCE. ASSIGN IO_OVS_CALLBACK->QUERY_PARAMETERS->* TO <FS>. IF <FS>-PROCESS_TYPE IS NOT INITIAL. IF <FS>-PROCESS_TYPE CS '*'. REPLACE ALL OCCURRENCES OF '*' IN <FS>-PROCESS_TYPE WITH '%'. SELECT PROCESS_TYPE P_DESCRIPTION_20 AS DESCRIPTION INTO TABLE GT_LIST FROM CRMC_PROC_TYPE_T WHERE LANGU = 'E' AND PROCESS_TYPE LIKE <FS>-PROCESS_TYPE. ELSE. SELECT PROCESS_TYPE P_DESCRIPTION_20 AS DESCRIPTION INTO TABLE GT_LIST FROM CRMC_PROC_TYPE_T WHERE LANGU = 'E' AND PROCESS_TYPE = <FS>-PROCESS_TYPE. ENDIF. ELSE. SELECT PROCESS_TYPE P_DESCRIPTION_20 AS DESCRIPTION INTO TABLE GT_LIST FROM CRMC_PROC_TYPE_T WHERE LANGU = 'E'. ENDIF. IO_OVS_CALLBACK->SET_OUTPUT_TABLE( EXPORTING OUTPUT = GT_LIST ). ENDMETHOD.
返回选择的值:
METHOD IF_FPM_GUIBB_OVS~HANDLE_PHASE_3. TYPES:BEGIN OF TY_PROCE, PROCESS_TYPE TYPE CRMT_PROCESS_TYPE, DESCRIPTION TYPE CRMT_DESCRIPTION_20, END OF TY_PROCE. FIELD-SYMBOLS:<FS> TYPE TY_PROCE. ASSIGN IO_OVS_CALLBACK->SELECTION->* TO <FS>. IO_OVS_CALLBACK->CONTEXT_ELEMENT->SET_ATTRIBUTE( EXPORTING VALUE = <FS>-PROCESS_TYPE NAME = IV_WD_CONTEXT_ATTR_NAME ). ENDMETHOD.