method ui5_valuehelp_ajax_run. field-symbols: type any. field-symbols: type any. data: lv_length type i, lv_position type i, lv_level type i, lv_char type c, lv_in_string type c, lv_separator type c, lv_sep_rec type c, lv_index type i, lv_use_exit type ddbool_d, lv_table type string, lv_empty type string, lv_record type string, lv_content type string, lv_content_d type sy-datum, lv_f4key type string, lv_f4keysep type string, lv_global type /neptune/shlp_global, it_fields type standard table of dfies, lv_fm_name type rs38l_fnam, wa_fields type dfies, wa_fieldprop type ddshfprop, it_shlp type shlp_desct, wa_shlp type shlp_descr. data: wa_selopt type ddshselopt, it_data type standard table of seahlpres, it_desc type standard table of dfies, wa_interface type ddshiface, wa_desc type dfies, wa_data type seahlpres, lv_maxrows type i, lv_tabix type sy-tabix, lr_dyn_ref type ref to data. *---------------------------------------------------------------------* * PRE PROCESSING *---------------------------------------------------------------------* * Get Binding call method server_get_binding( object ). * Check for Disable call method server_check_disable exporting object = object data = space. * Disabled ? check data_server-disable is initial. *--------------------------------------------------------------------- * PARSE JSON *--------------------------------------------------------------------- call method me->handle_on_parse_json_sh exporting object = object changing lv_global = lv_global. *---------------------------------------------------------------------* * GET SEARCH HELP DATA *---------------------------------------------------------------------* wa_shlp-shlpname = lv_global-shlp. wa_shlp-shlptype = 'SH'. * Get Search Help Info call function 'DD_SHLP_EXPAND_HELPMETHOD' exporting shlp_top = wa_shlp importing shlp_tab = it_shlp. *--------------------------------------------------------------------- * BUILD SELECTION FIELDS *--------------------------------------------------------------------- read table it_shlp into wa_shlp with key shlpname = lv_global-shlpname. check sy-subrc eq 0. * Set Fields for Current SH it_fields = wa_shlp-fielddescr. * Set Position by "List Position" column loop at it_fields into wa_fields. lv_tabix = sy-tabix. clear wa_fieldprop. read table wa_shlp-fieldprop into wa_fieldprop with key fieldname = wa_fields-fieldname. check sy-subrc is initial. wa_fields-position = wa_fieldprop-shlplispos. modify it_fields from wa_fields index lv_tabix. endloop. * Delete Fields with no position delete it_fields where position eq 0. * Sorting (LPos) sort it_fields by position. loop at it_fields into wa_fields. case sy-tabix. when 1. check lv_global-value0 is not initial. wa_selopt-low = lv_global-value0. when 2. check lv_global-value1 is not initial. wa_selopt-low = lv_global-value1. when 3. check lv_global-value2 is not initial. wa_selopt-low = lv_global-value2. when 4. check lv_global-value3 is not initial. wa_selopt-low = lv_global-value3. when 5. check lv_global-value4 is not initial. wa_selopt-low = lv_global-value4. when 6. check lv_global-value5 is not initial. wa_selopt-low = lv_global-value5. when 7. check lv_global-value6 is not initial. wa_selopt-low = lv_global-value6. when 8. check lv_global-value7 is not initial. wa_selopt-low = lv_global-value7. when 9. check lv_global-value8 is not initial. wa_selopt-low = lv_global-value8. when 10. check lv_global-value9 is not initial. wa_selopt-low = lv_global-value9. endcase. wa_selopt-shlpname = lv_global-shlpname. wa_selopt-shlpfield = wa_fields-fieldname. wa_selopt-sign = 'I'. wa_selopt-option = 'CP'. if wa_fields-checktable is initial. concatenate '*' wa_selopt-low '*' into wa_selopt-low. append wa_selopt to wa_shlp-selopt. translate wa_selopt-low to upper case. endif. append wa_selopt to wa_shlp-selopt. clear wa_selopt. endloop. *--------------------------------------------------------------------- * DO SEARCH *--------------------------------------------------------------------- lv_maxrows = lv_global-maxrows. if not wa_shlp-intdescr-selmexit is initial. lv_use_exit = 'X'. else. lv_use_exit = space. endif. call function 'F4IF_SELECT_VALUES' exporting shlp = wa_shlp maxrows = lv_maxrows call_shlp_exit = lv_use_exit tables record_tab = it_data recdescr_tab = it_desc. *--------------------------------------------------------------------- * BUILD STRUCTURE *--------------------------------------------------------------------- data: lo_struc type ref to cl_abap_structdescr, lt_desc_temp type standard table of dfies, wa_comp_all type cl_abap_structdescr=>component, wa_comp_new type cl_abap_structdescr=>component, lt_comp_sorted type cl_abap_structdescr=>component_table, wa_comp_sorted type cl_abap_structdescr=>component, lt_comp_all type cl_abap_structdescr=>component_table, lt_comp_new type cl_abap_structdescr=>component_table. * Temp Table lt_desc_temp = it_desc. * Get all TABNAME sort lt_desc_temp by tabname ascending. delete adjacent duplicates from lt_desc_temp comparing tabname. * Build field table loop at lt_desc_temp into wa_desc. clear lo_struc. clear lt_comp_new. lo_struc ?= cl_abap_structdescr=>describe_by_name( wa_desc-tabname ). lt_comp_new = lo_struc->get_components( ). loop at lt_comp_new into wa_comp_new. read table lt_comp_all into wa_comp_all with key name = wa_comp_new-name. if sy-subrc ne 0. append wa_comp_new to lt_comp_all. endif. endloop. endloop. * Remove unnesesary fields that are not part of search help output describe table lt_desc_temp lines lv_length. if lv_length > 1. * Sort output fields in correct order (specified in search help parameters) sort it_desc by position ascending. * First append MANDT if any (should always be in first place) read table lt_comp_all into wa_comp_all with key name = 'MANDT'. if sy-subrc eq 0. append wa_comp_all to lt_comp_sorted. endif. * Now append all others in correct order loop at it_desc into wa_desc. read table lt_comp_all into wa_comp_all with key name = wa_desc-fieldname. append wa_comp_all to lt_comp_sorted. endloop. clear lt_comp_all. lt_comp_all = lt_comp_sorted. endif. * Create the RTTC instance for the merged structure try. lo_struc = cl_abap_structdescr=>create( p_components = lt_comp_all ). catch cx_sy_struct_creation. endtry. * Assign to Structure create data lr_dyn_ref type handle lo_struc. assign lr_dyn_ref->* to . check sy-subrc eq 0. *--------------------------------------------------------------------- * BUILD CONTENT *--------------------------------------------------------------------- loop at it_data into wa_data. = wa_data-string. concatenate data_server-json lv_sep_rec '{' into data_server-json. lv_separator = space. lv_f4keysep = space. lv_f4key = space. loop at it_desc into wa_desc. assign component wa_desc-fieldname of structure to . check sy-subrc eq 0. lv_content = . call method me->server_encode_json changing data = lv_content. * Date Handling if wa_desc-datatype eq 'DATS'. lv_content_d = lv_content. if lv_content_d is initial. lv_content = space. else. call function 'CONVERT_DATE_TO_EXTERNAL' exporting date_internal = lv_content_d importing date_external = lv_content exceptions date_internal_is_invalid = 1 others = 2. endif. endif. * Build JSON concatenate data_server-json lv_separator '"' wa_desc-fieldname '":"' lv_content '"' into data_server-json. * Field Separator lv_separator = ','. * Set Key Data read table wa_shlp-interface into wa_interface with key topshlpfld = wa_desc-fieldname. if sy-subrc eq 0. concatenate lv_f4key lv_f4keysep lv_content into lv_f4key. lv_f4keysep = ':'. endif. endloop. "F4 Key concatenate data_server-json lv_separator '"F4KEY":"' lv_f4key '"' into data_server-json. lv_sep_rec = ','. concatenate data_server-json '}' into data_server-json. endloop. * Build JSON String concatenate '{"modelF4tabResultData":[' data_server-json ']' into data_server-json. * Global Data Structure describe table it_data lines lv_length. lv_global-title = lv_length. concatenate 'LIST (' lv_global-title ')' into lv_global-title separated by space. concatenate data_server-json ',"modelF4DialogData":' into data_server-json. call method um5_struc_to_json exporting object = object struc_data = lv_global importing json_data = data_server-json. concatenate data_server-json '}' into data_server-json. endmethod.