[转http://www.cnblogs.com/byfhd/archive/2007/08/17/859829.html]
******************************************************************** * Report for generating class from XML-file * Author: Sergey Korolev (slkorolev@mail.ru) * Does not work with interfaces and exception classes ******************************************************************** REPORT yrs_class_upload_xml . PARAMETERS: xmlfile TYPE localfile. TYPE-POOLS: seok, seop. INCLUDE yrs_class_xml_const. DATA: corr_mode, * Extracted structures (from XML file) gt_locals_src TYPE seop_source_string, gt_locals_def TYPE seop_source_string, gt_locals_imp TYPE seop_source_string, gt_locals_mac TYPE seop_source_string, gs_class TYPE vseoclass, gt_attributes TYPE seoo_attributes_r, gt_methods TYPE seoo_methods_r, gt_events TYPE seoo_events_r, gt_types TYPE seoo_types_r, gt_parameters TYPE seos_parameters_r, gt_exceps TYPE seos_exceptions_r, gt_implementings TYPE seor_implementings_r, gs_inheritance TYPE vseoextend, gt_redefinitions TYPE seor_redefinitions_r, gt_impl_details TYPE seor_redefinitions_r, gt_friendships TYPE seof_friendships_r, gt_typepusages TYPE seot_typepusages_r, gt_clsdeferrds TYPE seot_clsdeferrds_r, gt_intdeferrds TYPE seot_intdeferrds_r, gt_aliases TYPE seoo_aliases_r, gt_interfaces TYPE seok_int_typeinfos, gs_includes TYPE seop_methods_w_include, gt_texts TYPE TABLE OF textpool, gt_source TYPE seop_source, gt_type_source TYPE seop_source, gt_mtd_source TYPE seo_method_source_table, wa_mtd_source TYPE seo_method_source. CLASS lcx_xml_error DEFINITION DEFERRED. DATA: ex TYPE REF TO lcx_xml_error. *----------------------------------------------------------------------* * CLASS lCX_xml_error DEFINITIO *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcx_xml_error DEFINITION INHERITING FROM cx_static_check. PUBLIC SECTION. DATA: error TYPE string. METHODS: constructor IMPORTING value(i_error) TYPE string OPTIONAL. ENDCLASS. "lCX_xml_error DEFINITIO *----------------------------------------------------------------------* * CLASS lcx_xml_section_error DEFINITIO *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcx_xml_section_error DEFINITION INHERITING FROM lcx_xml_error. PUBLIC SECTION. METHODS: constructor IMPORTING value(i_section) TYPE string OPTIONAL . ENDCLASS. "lCX_xml_error DEFINITIO *----------------------------------------------------------------------* * CLASS lcx_xml_error IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcx_xml_error IMPLEMENTATION. METHOD constructor. CALL METHOD super->constructor. error = i_error. ENDMETHOD. "constructor ENDCLASS. "lcx_xml_error IMPLEMENTATION *----------------------------------------------------------------------* * CLASS lcx_xml__section_error IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcx_xml_section_error IMPLEMENTATION. METHOD constructor. DATA: msg TYPE string. CONCATENATE 'File does not contain obligatory section' i_section INTO msg SEPARATED BY space. CALL METHOD super->constructor EXPORTING i_error = msg. ENDMETHOD. "constructor ENDCLASS. "lcx_xml__section_error IMPLEMENTATION AT SELECTION-SCREEN ON VALUE-REQUEST FOR xmlfile. DATA: file_table TYPE filetable, action TYPE i, rc TYPE sysubrc. FIELD-SYMBOLS: <file> TYPE file_table. CALL METHOD cl_gui_frontend_services=>file_open_dialog EXPORTING default_extension = 'xml' file_filter = cl_gui_frontend_services=>filetype_xml CHANGING file_table = file_table rc = rc user_action = action EXCEPTIONS file_open_dialog_failed = 1 cntl_error = 2 error_no_gui = 3 not_supported_by_gui = 4 OTHERS = 5. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. CHECK action = cl_gui_frontend_services=>action_ok. READ TABLE file_table INDEX 1 ASSIGNING <file>. xmlfile = <file>. START-OF-SELECTION. DATA: retcode TYPE sysubrc, source_node TYPE REF TO if_ixml_node, xml TYPE REF TO cl_xml_document. CREATE OBJECT xml. TRY. CALL METHOD xml->import_from_file EXPORTING filename = xmlfile RECEIVING retcode = retcode. IF retcode NE xml->c_ok. DATA: msg TYPE string. CASE retcode. WHEN xml->c_no_ixml. msg = 'This is not XML file'. WHEN xml->c_failed. msg = 'Failed to parse the XML file'. WHEN xml->c_not_found. msg = 'XML file not found'. ENDCASE. RAISE EXCEPTION TYPE lcx_xml_error EXPORTING i_error = msg. ENDIF. DEFINE load_section. call method xml->get_data exporting name = &1 importing retcode = retcode changing dataobject = &2. if retcode ne xml->c_ok. raise exception type lcx_xml_section_error exporting i_section = &1. endif. END-OF-DEFINITION. load_section: c_xml_root gs_class, c_xml_attributes gt_attributes, c_xml_methods gt_methods, c_xml_events gt_events, c_xml_types gt_types, c_xml_parameters gt_parameters, c_xml_exceps gt_exceps, c_xml_implementings gt_implementings, c_xml_impl_details gt_impl_details, c_xml_friendships gt_friendships, c_xml_typepusages gt_typepusages, c_xml_clsdeferrds gt_clsdeferrds, c_xml_intdeferrds gt_intdeferrds, c_xml_aliases gt_aliases, c_xml_inheritance gs_inheritance, c_xml_interfaces gt_interfaces, c_xml_redefinitions gt_redefinitions, c_xml_typesource gt_type_source, * c_xml_text_pool gt_texts, c_xml_locals_src gt_locals_src, c_xml_locals_def gt_locals_def, c_xml_locals_mac gt_locals_mac, c_xml_locals_imp gt_locals_imp. * Now find method implementation node containing sources * for each method as a subnode CALL METHOD xml->find_node EXPORTING name = c_xml_method_src RECEIVING node = source_node. IF source_node IS INITIAL. RAISE EXCEPTION TYPE lcx_xml_section_error EXPORTING i_section = c_xml_methods. ENDIF. source_node = source_node->get_first_child( ). DATA: name1 TYPE string, name2 TYPE string, xml_sep(5) VALUE '_--7E'. WHILE NOT source_node IS INITIAL. CLEAR wa_mtd_source. name1 = source_node->get_name( ). SPLIT name1 AT xml_sep INTO name1 name2. IF name2 IS INITIAL. wa_mtd_source-cpdname = name1. ELSE. CONCATENATE name1 name2 INTO wa_mtd_source-cpdname SEPARATED BY '~'. ENDIF. CALL METHOD xml->get_node_data EXPORTING node = source_node IMPORTING dataobject = wa_mtd_source-source retcode = retcode. IF retcode = xml->c_ok. APPEND wa_mtd_source TO gt_mtd_source. ENDIF. source_node = source_node->get_next( ). ENDWHILE. CATCH lcx_xml_error INTO ex. MESSAGE ex->error TYPE 'E'. ENDTRY. DATA: answer, fields TYPE TABLE OF sval WITH HEADER LINE, parameter TYPE TABLE OF spar WITH HEADER LINE, clskey TYPE seoclskey. clskey-clsname = gs_class-clsname. corr_mode = 'I'. DO. CALL FUNCTION 'SEO_CLASS_GET' EXPORTING clskey = clskey EXCEPTIONS not_existing = 1 deleted = 2 is_interface = 3 model_only = 4 OTHERS = 5. IF sy-subrc NE 0. EXIT. ENDIF. REFRESH parameter. parameter-param = 'CLASS'. parameter-value = clskey-clsname. APPEND parameter. CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING titlebar = 'Class already exists' text_question = 'Class &CLASS& already exists. Overwrite?' default_button = '2' IMPORTING answer = answer TABLES parameter = parameter EXCEPTIONS text_not_found = 0 OTHERS = 0. CASE answer. WHEN '1'. corr_mode = 'U'. EXIT. WHEN 'A'. RETURN. ENDCASE. REFRESH fields. fields-tabname = 'SEOCLSKEY'. fields-fieldname = 'CLSNAME'. fields-value = clskey-clsname. APPEND fields. CALL FUNCTION 'POPUP_GET_VALUES' EXPORTING popup_title = 'Enter new class name' IMPORTING returncode = answer TABLES fields = fields EXCEPTIONS error_in_fields = 1 OTHERS = 2. IF answer = 'A'. RETURN. ENDIF. READ TABLE fields INDEX 1. clskey-clsname = fields-value. ENDDO. IF clskey-clsname NE gs_class-clsname. gs_class-clsname = clskey-clsname. gs_class-author = sy-uname. gs_class-changedby = sy-uname. gs_class-changedon = sy-datum. gs_inheritance-clsname = clskey-clsname. PERFORM rename_class TABLES gt_implementings USING clskey-clsname. PERFORM rename_class TABLES gt_attributes USING clskey-clsname. PERFORM rename_class TABLES gt_methods USING clskey-clsname. PERFORM rename_class TABLES gt_events USING clskey-clsname. PERFORM rename_class TABLES gt_types USING clskey-clsname. PERFORM rename_class TABLES gt_parameters USING clskey-clsname. PERFORM rename_class TABLES gt_exceps USING clskey-clsname. PERFORM rename_class TABLES gt_aliases USING clskey-clsname. PERFORM rename_class TABLES gt_typepusages USING clskey-clsname. PERFORM rename_class TABLES gt_clsdeferrds USING clskey-clsname. PERFORM rename_class TABLES gt_intdeferrds USING clskey-clsname. PERFORM rename_class TABLES gt_redefinitions USING clskey-clsname. PERFORM rename_class TABLES gt_impl_details USING clskey-clsname. PERFORM rename_class TABLES gt_friendships USING clskey-clsname. ENDIF. DATA: devclass LIKE tadir-devclass, korrnum LIKE e070-trkorr. CALL FUNCTION 'RS_CORR_INSERT' EXPORTING object = gs_class-clsname object_class = 'CLAS' mode = corr_mode global_lock = 'X' master_language = gs_class-langu IMPORTING devclass = devclass korrnum = korrnum EXCEPTIONS cancelled = 1 permission_failure = 2 unknown_objectclass = 3 OTHERS = 4. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. DATA: overwrite TYPE seox_boolean. IF corr_mode = 'U'. overwrite = seox_true. ENDIF. CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' EXPORTING text = 'Generating class definition'. CALL FUNCTION 'SEO_CLASS_CREATE_COMPLETE' EXPORTING corrnr = korrnum devclass = devclass version = seoc_version_inactive overwrite = overwrite IMPORTING korrnr = korrnum CHANGING class = gs_class inheritance = gs_inheritance redefinitions = gt_redefinitions implementings = gt_implementings impl_details = gt_impl_details attributes = gt_attributes methods = gt_methods events = gt_events types = gt_types type_source = gt_type_source PARAMETERS = gt_parameters exceps = gt_exceps aliases = gt_aliases typepusages = gt_typepusages clsdeferrds = gt_clsdeferrds intdeferrds = gt_intdeferrds friendships = gt_friendships EXCEPTIONS existing = 1 is_interface = 2 db_error = 3 component_error = 4 no_access = 5 other = 6 OTHERS = 7. IF sy-subrc <> 0. MESSAGE 'Error generating class' TYPE 'E'. ENDIF. CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' EXPORTING text = 'Generating local class definitions'. CALL FUNCTION 'SEO_CLASS_GENERATE_LOCALS' EXPORTING clskey = clskey force = seox_true corrnr = korrnum implementation = gt_locals_src locals_def = gt_locals_def locals_imp = gt_locals_imp locals_mac = gt_locals_mac EXCEPTIONS not_existing = 1 model_only = 2 locals_not_generated = 3 locals_not_initialised = 4 OTHERS = 5. IF sy-subrc <> 0. MESSAGE 'Error generating local class definitions' TYPE 'E'. ENDIF. FIELD-SYMBOLS: <mtd_source> TYPE seo_method_source. DATA: status_line(128), mtdkey TYPE seocpdkey. LOOP AT gt_mtd_source ASSIGNING <mtd_source>. CONCATENATE 'Generating implementation of the method' <mtd_source>-cpdname INTO status_line SEPARATED BY space. CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' EXPORTING text = status_line. mtdkey-clsname = clskey-clsname. mtdkey-cpdname = <mtd_source>-cpdname. CALL FUNCTION 'SEO_METHOD_GENERATE_INCLUDE' EXPORTING mtdkey = mtdkey force = seox_true suppress_corr = seox_true implementation_expanded = <mtd_source>-source corrnr = korrnum without_method_frame = seox_true EXCEPTIONS not_existing = 1 model_only = 2 include_existing = 3 method_imp_not_generated = 4 method_imp_not_initialised = 5 _internal_class_not_existing = 6 _internal_method_overflow = 7 cancelled = 8 method_is_abstract_implemented = 9 method_is_final_implemented = 10 internal_error_insert_report = 11 OTHERS = 12. * IF sy-subrc <> 0. * MESSAGE 'Error generating class' TYPE 'E'. * ENDIF. ENDLOOP. * Now find text pool node containing textpools for * different languages as subnodes DATA: langu TYPE sy-langu, include_name TYPE programm. TRY. CALL FUNCTION 'SEO_CLASS_GET_INCLUDE_BY_NAME' EXPORTING clskey = clskey IMPORTING progname = include_name. CALL METHOD xml->find_node EXPORTING name = c_xml_text_pool RECEIVING node = source_node. IF source_node IS INITIAL. RAISE EXCEPTION TYPE lcx_xml_section_error EXPORTING i_section = c_xml_text_pool. ENDIF. source_node = source_node->get_first_child( ). WHILE NOT source_node IS INITIAL. langu = source_node->get_name( ). REFRESH gt_texts. CALL METHOD xml->get_node_data EXPORTING node = source_node IMPORTING dataobject = gt_texts retcode = retcode. source_node = source_node->get_next( ). CHECK retcode = xml->c_ok AND NOT gt_texts IS INITIAL. CONCATENATE 'Generating class text pool for language' langu INTO msg SEPARATED BY space. CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' EXPORTING text = msg. INSERT textpool include_name FROM gt_texts LANGUAGE langu. ENDWHILE. CATCH lcx_xml_section_error. MESSAGE 'XML-file does not contain Text pool data' TYPE 'S'. ENDTRY. SET PARAMETER ID 'CLASS' FIELD clskey-clsname. CALL TRANSACTION 'SE24'. *&---------------------------------------------------------------------* *& Form rename_class *&---------------------------------------------------------------------* * Renames class references in arbitrary table *----------------------------------------------------------------------* * -->P_TABLE some generation structure * -->P_NAME new class name *----------------------------------------------------------------------* FORM rename_class TABLES p_table USING p_name. FIELD-SYMBOLS: <field> TYPE ANY, <line> TYPE ANY. DEFINE set_field. assign component &1 of structure <line> to <field>. if sy-subrc = 0. <field> = &2. endif. END-OF-DEFINITION. LOOP AT p_table ASSIGNING <line>. set_field 'CLSNAME' p_name. set_field 'AUTHOR' sy-uname. set_field 'CHANGEDBY' sy-uname. ENDLOOP. ENDFORM. " rename_class
[Edit section] Report YRS_CLASS_DOWNLOAD_XML
******************************************************************** * Report for generating XML-file from class * Author: Sergey Korolev (slkorolev@mail.ru) * Does not work with interfaces and exception classes ******************************************************************** REPORT yrs_class_download. PARAMETERS: class TYPE seoclskey OBLIGATORY. SELECTION-SCREEN SKIP. PARAMETERS: p_show AS CHECKBOX. TYPE-POOLS: seok, seop, srext. INCLUDE yrs_class_xml_const. INCLUDE lseopm01. DATA: g_xml TYPE REF TO cl_xml_document, gs_class TYPE vseoclass, gt_attributes TYPE seoo_attributes_r, gt_methods TYPE seoo_methods_r, gt_events TYPE seoo_events_r, gt_types TYPE seoo_types_r, gt_parameters TYPE seos_parameters_r, gt_exceps TYPE seos_exceptions_r, gt_implementings TYPE seor_implementings_r, gs_inheritance TYPE vseoextend, gt_redefinitions TYPE seor_redefinitions_r, gt_impl_details TYPE seor_redefinitions_r, gt_friendships TYPE seof_friendships_r, gt_typepusages TYPE seot_typepusages_r, gt_clsdeferrds TYPE seot_clsdeferrds_r, gt_intdeferrds TYPE seot_intdeferrds_r, gt_aliases TYPE seoo_aliases_r, gt_interfaces TYPE seok_int_typeinfos, gs_includes TYPE seop_methods_w_include, gt_source TYPE seop_source_string. DATA: typkey TYPE seocmpkey, single_source TYPE seop_source, type_source TYPE seop_source_string. FIELD-SYMBOLS: <type> TYPE seoo_type_r, <source_line> TYPE LINE OF seop_source. FIELD-SYMBOLS: <include> TYPE LINE OF seop_methods_w_include. AT SELECTION-SCREEN ON VALUE-REQUEST FOR class. DATA: clsname TYPE seoclass-clsname. clsname = class. CALL FUNCTION 'F4_OBJECTS_CLASS' EXPORTING object = clsname IMPORTING RESULT = clsname. class = clsname. AT SELECTION-SCREEN ON class. DATA: clskey TYPE seoclskey. clskey-clsname = class. * Check if active version of class exists CALL FUNCTION 'SEO_CLASS_GET' EXPORTING clskey = clskey version = '1' state = '1' EXCEPTIONS not_existing = 1 deleted = 2 is_interface = 3 model_only = 4 OTHERS = 5. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. START-OF-SELECTION. CALL FUNCTION 'SEO_CLASS_TYPEINFO_GET' EXPORTING clskey = class version = seoc_version_active IMPORTING class = gs_class attributes = gt_attributes methods = gt_methods events = gt_events types = gt_types PARAMETERS = gt_parameters exceps = gt_exceps implementings = gt_implementings inheritance = gs_inheritance redefinitions = gt_redefinitions impl_details = gt_impl_details friendships = gt_friendships typepusages = gt_typepusages clsdeferrds = gt_clsdeferrds intdeferrds = gt_intdeferrds aliases = gt_aliases EXCEPTIONS not_existing = 1 is_interface = 2 model_only = 3 OTHERS = 4. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. * Load all method include names CALL FUNCTION 'SEO_CLASS_GET_METHOD_INCLUDES' EXPORTING clskey = class IMPORTING includes = gs_includes EXCEPTIONS _internal_class_not_existing = 1 OTHERS = 2. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. * Gathering together internal type source LOOP AT gt_types ASSIGNING <type>. typkey-clsname = <type>-clsname. typkey-cmpname = <type>-cmpname. REFRESH single_source. PERFORM get_type_source USING typkey CHANGING single_source. * CALL FUNCTION 'SEO_CLASS_GET_TYPE_SOURCE' * EXPORTING * typkey = typkey * IMPORTING * SOURCE = single_source * EXCEPTIONS * _internal_class_not_existing = 1 * not_existing = 2 * not_edited = 3 * OTHERS = 4. CHECK NOT single_source[] IS INITIAL. <type>-srcrow1 = LINES( type_source ) + 1. <type>-srccolumn1 = 0. LOOP AT single_source ASSIGNING <source_line>. CONDENSE <source_line>. <type>-srccolumn2 = STRLEN( <source_line> ). APPEND <source_line> TO type_source. ENDLOOP. <type>-srcrow2 = LINES( type_source ). ENDLOOP. END-OF-SELECTION. DATA: mtd_name TYPE string, class_root TYPE REF TO if_ixml_node, section TYPE REF TO if_ixml_node, l_description TYPE sdok_descr. l_description = gs_class-descript. CREATE OBJECT g_xml EXPORTING description = l_description object_type = cl_xml_document=>c_bor_classtype object_name = gs_class-clsname. * Simply generate sections of XML document * First create root section g_xml->set_data( name = c_xml_root dataobject = gs_class ). class_root = g_xml->find_node( name = c_xml_root ). * All other sections will be under the root (see parent_node) g_xml->set_data( name = c_xml_attributes parent_node = class_root dataobject = gt_attributes ). g_xml->set_data( name = c_xml_methods parent_node = class_root dataobject = gt_methods ). g_xml->set_data( name = c_xml_events parent_node = class_root dataobject = gt_events ). g_xml->set_data( name = c_xml_types parent_node = class_root dataobject = gt_types ). g_xml->set_data( name = c_xml_parameters parent_node = class_root dataobject = gt_parameters ). g_xml->set_data( name = c_xml_exceps parent_node = class_root dataobject = gt_exceps ). g_xml->set_data( name = c_xml_implementings parent_node = class_root dataobject = gt_implementings ). g_xml->set_data( name = c_xml_impl_details parent_node = class_root dataobject = gt_impl_details ). g_xml->set_data( name = c_xml_friendships parent_node = class_root dataobject = gt_friendships ). g_xml->set_data( name = c_xml_typepusages parent_node = class_root dataobject = gt_typepusages ). g_xml->set_data( name = c_xml_clsdeferrds parent_node = class_root dataobject = gt_clsdeferrds ). g_xml->set_data( name = c_xml_intdeferrds parent_node = class_root dataobject = gt_intdeferrds ). g_xml->set_data( name = c_xml_aliases parent_node = class_root dataobject = gt_aliases ). g_xml->set_data( name = c_xml_inheritance parent_node = class_root dataobject = gs_inheritance ). g_xml->set_data( name = c_xml_interfaces parent_node = class_root dataobject = gt_interfaces ). g_xml->set_data( name = c_xml_redefinitions parent_node = class_root dataobject = gt_redefinitions ). g_xml->set_data( name = c_xml_typesource parent_node = class_root dataobject = type_source ). * Extract local definitions (classes, macros) DEFINE set_locals. refresh gt_source. call function 'SEO_CLASS_GET_INCLUDE_SOURCE' exporting clskey = class inctype = &1 importing source_expanded = gt_source exceptions _internal_class_not_existing = 0 not_existing = 0 others = 0. g_xml->set_data( name = &2 parent_node = class_root dataobject = gt_source ). END-OF-DEFINITION. DATA: include_name TYPE programm. CALL FUNCTION 'SEO_CLASS_GET_INCLUDE_BY_NAME' EXPORTING clskey = class limu = seok_limu_locals IMPORTING progname = include_name. set_locals: include_name c_xml_locals_src, seop_ext_class_locals_def c_xml_locals_def, seop_ext_class_locals_imp c_xml_locals_imp, seop_ext_class_macros c_xml_locals_mac. * Extract text pool DATA: gt_texts TYPE TABLE OF textpool. CALL FUNCTION 'SEO_CLASS_GET_INCLUDE_BY_NAME' EXPORTING clskey = class IMPORTING progname = include_name. READ TEXTPOOL include_name INTO gt_texts LANGUAGE sy-langu. g_xml->set_data( name = c_xml_text_pool parent_node = class_root dataobject = gt_texts ). * Create section for method source. * Then each metod as a single node under the common section section = g_xml->create_simple_element( name = c_xml_method_src parent = class_root ). LOOP AT gs_includes ASSIGNING <include>. REFRESH gt_source. CALL FUNCTION 'SEO_METHOD_GET_SOURCE' EXPORTING mtdkey = <include>-cpdkey state = 'A' IMPORTING source_expanded = gt_source EXCEPTIONS _internal_method_not_existing = 1 _internal_class_not_existing = 2 version_not_existing = 3 inactive_new = 4 inactive_deleted = 5 OTHERS = 6. CHECK sy-subrc = 0. mtd_name = <include>-cpdkey-cpdname. g_xml->set_data( name = mtd_name parent_node = section dataobject = gt_source[] ). ENDLOOP. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. * Now display resulting XML-file or export it into workstation file mtd_name = class. IF p_show = 'X'. g_xml->display( ). EXIT. ENDIF. DATA: user_action TYPE i, path TYPE string, full_path TYPE string, file_name TYPE string. CALL METHOD cl_gui_frontend_services=>file_save_dialog EXPORTING default_extension = 'xml' default_file_name = mtd_name file_filter = cl_gui_frontend_services=>filetype_xml CHANGING filename = file_name path = path fullpath = full_path user_action = user_action EXCEPTIONS cntl_error = 1 error_no_gui = 2 not_supported_by_gui = 3 OTHERS = 4. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. CHECK user_action = cl_gui_frontend_services=>action_ok. DATA: localfile TYPE localfile. localfile = full_path. g_xml->export_to_file( filename = localfile ). *&---------------------------------------------------------------------* *& Form get_type_source *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->VALUE(P_TYPKEY) text * -->P_SOURCE text *----------------------------------------------------------------------* FORM get_type_source USING value(p_typkey) TYPE seocmpkey CHANGING p_source TYPE seop_source. STATICS: loaded, private_section TYPE seop_source, protected_section TYPE seop_source. DATA: filename TYPE progstruc, expanded_srouce TYPE seop_source_string, type TYPE vseotype. FIELD-SYMBOLS: <dest> TYPE seop_source. IF loaded IS INITIAL. class_include p_typkey srext_ext_class_protected filename. READ REPORT filename INTO expanded_srouce. protected_section[] = expanded_srouce[]. class_include p_typkey srext_ext_class_private filename. READ REPORT filename INTO expanded_srouce. private_section[] = expanded_srouce[]. loaded = 'X'. ENDIF. CALL FUNCTION 'SEO_TYPE_GET' EXPORTING typkey = typkey version = seoc_version_inactive IMPORTING type = type EXCEPTIONS OTHERS = 0. IF type-exposure = seoc_exposure_protected. ASSIGN protected_section TO <dest>. ELSE. ASSIGN private_section TO <dest>. ENDIF. PERFORM extract_type_source(saplseop) USING <dest> type-srcrow1 type-srccolumn1 type-srcrow2 type-srccolumn2 CHANGING p_source. * CALL FUNCTION 'SEO_CLASS_GET_TYPE_SOURCE'. ENDFORM. " GET_TYPE_SOURCE
[Edit section] Include YRS_CLASS_XML_CONST
*&---------------------------------------------------------------------* *& Include YRS_CLASS_XML_CONST *&---------------------------------------------------------------------* CONSTANTS: c_xml_root TYPE string VALUE 'CLASS_ROOT', c_xml_public TYPE string VALUE 'PUBLIC_SECTION', c_xml_protected TYPE string VALUE 'PROTECTED_SECTION', c_xml_private TYPE string VALUE 'PRIVATE_SECTION', c_xml_inheritance TYPE string VALUE 'INHERITANCE', c_xml_friends TYPE string VALUE 'FRIENDS', c_xml_interfaces TYPE string VALUE 'INTERFACES', c_xml_redefinitions TYPE string VALUE 'REDEFINITIONS', c_xml_typesource TYPE string VALUE 'TYPE_SOURCE', c_xml_locals_src TYPE string VALUE 'LOCALS_SRC', c_xml_locals_def TYPE string VALUE 'LOCALS_DEF', c_xml_locals_imp TYPE string VALUE 'LOCALS_IMP', c_xml_locals_mac TYPE string VALUE 'LOCALS_MAC', c_xml_method_src TYPE string VALUE 'METHOD_SOURCE'. CONSTANTS: c_xml_attributes TYPE string VALUE 'ATTRIBUTES', c_xml_methods TYPE string VALUE 'METHODS', c_xml_events TYPE string VALUE 'EVENTS', c_xml_types TYPE string VALUE 'TYPES', c_xml_parameters TYPE string VALUE 'PARAMETERS', c_xml_exceps TYPE string VALUE 'EXCEPTIONS', c_xml_implementings TYPE string VALUE 'IMPLEMENTINGS', c_xml_impl_details TYPE string VALUE 'IMPL_DETAILS', c_xml_friendships TYPE string VALUE 'FRIENDSHIPS', c_xml_typepusages TYPE string VALUE 'TYPEPUSAGES', c_xml_clsdeferrds TYPE string VALUE 'CLSDEFERRDS', c_xml_intdeferrds TYPE string VALUE 'INTDEFERRDS', c_xml_aliases TYPE string VALUE 'ALIASES', c_xml_text_pool TYPE string VALUE 'TEXT_POOL'.
[Edit section] Sample class
This is tiny yet useful ABAP class, implementing progress indicator functionality by utilizing SAPGUI_PROGRESS_INDICATOR function module. Sometimes you need to show a progress of some process. For example, you can process quite large internal table in a loop. Also it should be better to show progress only when it really changes and not very often or else a user can see blinking watch-icon in the GUI status line. Also it would be nice not to bother with percent calculation. All this can be done with ZCL_PROGRESS_INDICATOR class. First, call its START method to define total amount of process steps (say internal table line count) and status line text. Also you can set percent threshold which defines frequency of progress indicator updates. If you set threshold to 5 then the progress indicator will be updated less often than 5% of step count. Next, call ADVANCE method on every countable process step (say on every loop step). It will show progress when needed and increment internal progress counts. Also you can call SET method to set current progress absolutely. Finally, call FINISH method to clear GUI status line.
Save the contents of this page starting with <?xml version="1.0"?> tag and ending with </CLASS_ROOT> tag, then save it as XML file and finally upload with YRS_UPLOAD_CLASS_XML report.
<?xml version="1.0" encoding="utf-16"?> <CLASS_ROOT>
<CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Progress indicator</DESCRIPT> <UUID>CHTdPkI0GECU1I4g7Jzm4A==</UUID> <CATEGORY>00</CATEGORY> <EXPOSURE>2</EXPOSURE> <STATE>1</STATE> <RELEASE>0</RELEASE> <AUTHOR>SKOROLEV</AUTHOR> <CREATEDON>2005-10-19</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <CHGDANYON>0000-00-00</CHGDANYON> <FIXPT>X</FIXPT> <UNICODE>X</UNICODE> <R3RELEASE>700</R3RELEASE> <CLSBCCAT>00</CLSBCCAT> <DURATION_TYPE>0</DURATION_TYPE> <RISK_LEVEL>0</RISK_LEVEL> <ATTRIBUTES> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>PROGRESS_TEXT</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Progress text</DESCRIPT> <EXPOSURE>2</EXPOSURE> <STATE>1</STATE> <EDITORDER>1</EDITORDER> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <ATTDECLTYP>0</ATTDECLTYP> <ATTEXPVIRT>0</ATTEXPVIRT> <TYPTYPE>1</TYPTYPE> <TYPE>STRING</TYPE> <SRCROW1>0</SRCROW1> <SRCCOLUMN1>0</SRCCOLUMN1> <SRCROW2>0</SRCROW2> <SRCCOLUMN2>0</SRCCOLUMN2> <R3RELEASE>700</R3RELEASE> <TYPESRC_LENG>0</TYPESRC_LENG> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>HIGH_BOUND</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>High bound</DESCRIPT> <EXPOSURE>2</EXPOSURE> <STATE>1</STATE> <EDITORDER>2</EDITORDER> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <ATTDECLTYP>0</ATTDECLTYP> <ATTEXPVIRT>0</ATTEXPVIRT> <TYPTYPE>1</TYPTYPE> <TYPE>I</TYPE> <SRCROW1>0</SRCROW1> <SRCCOLUMN1>0</SRCCOLUMN1> <SRCROW2>0</SRCROW2> <SRCCOLUMN2>0</SRCCOLUMN2> <R3RELEASE>700</R3RELEASE> <TYPESRC_LENG>0</TYPESRC_LENG> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>TIME_LIMIT</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>System time out limit</DESCRIPT> <EXPOSURE>2</EXPOSURE> <STATE>1</STATE> <EDITORDER>3</EDITORDER> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <ATTDECLTYP>0</ATTDECLTYP> <ATTRDONLY>X</ATTRDONLY> <ATTEXPVIRT>0</ATTEXPVIRT> <TYPTYPE>1</TYPTYPE> <TYPE>F</TYPE> <SRCROW1>0</SRCROW1> <SRCCOLUMN1>0</SRCCOLUMN1> <SRCROW2>0</SRCROW2> <SRCCOLUMN2>0</SRCCOLUMN2> <R3RELEASE>700</R3RELEASE> <TYPESRC_LENG>0</TYPESRC_LENG> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>CURRENT_PROGRESS</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Current indicator value (absolute)</DESCRIPT> <EXPOSURE>2</EXPOSURE> <STATE>1</STATE> <EDITORDER>4</EDITORDER> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <ATTDECLTYP>0</ATTDECLTYP> <ATTRDONLY>X</ATTRDONLY> <ATTEXPVIRT>0</ATTEXPVIRT> <TYPTYPE>1</TYPTYPE> <TYPE>I</TYPE> <SRCROW1>0</SRCROW1> <SRCCOLUMN1>0</SRCCOLUMN1> <SRCROW2>0</SRCROW2> <SRCCOLUMN2>0</SRCCOLUMN2> <R3RELEASE>700</R3RELEASE> <TYPESRC_LENG>0</TYPESRC_LENG> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>LAST_SHOWN_PROGRESS</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Last shown indicator value (absolute)</DESCRIPT> <EXPOSURE>0</EXPOSURE> <STATE>1</STATE> <EDITORDER>1</EDITORDER> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <ATTDECLTYP>0</ATTDECLTYP> <ATTEXPVIRT>0</ATTEXPVIRT> <TYPTYPE>1</TYPTYPE> <TYPE>I</TYPE> <SRCROW1>0</SRCROW1> <SRCCOLUMN1>0</SRCCOLUMN1> <SRCROW2>0</SRCROW2> <SRCCOLUMN2>0</SRCCOLUMN2> <R3RELEASE>700</R3RELEASE> <TYPESRC_LENG>0</TYPESRC_LENG> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>TRESHOLD</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Percent treshold</DESCRIPT> <EXPOSURE>0</EXPOSURE> <STATE>1</STATE> <EDITORDER>2</EDITORDER> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <ATTDECLTYP>0</ATTDECLTYP> <ATTEXPVIRT>0</ATTEXPVIRT> <TYPTYPE>1</TYPTYPE> <TYPE>I</TYPE> <SRCROW1>0</SRCROW1> <SRCCOLUMN1>0</SRCCOLUMN1> <SRCROW2>0</SRCROW2> <SRCCOLUMN2>0</SRCCOLUMN2> <R3RELEASE>700</R3RELEASE> <TYPESRC_LENG>0</TYPESRC_LENG> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>START_TIME_STAMP</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Start time</DESCRIPT> <EXPOSURE>0</EXPOSURE> <STATE>1</STATE> <EDITORDER>3</EDITORDER> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <ATTDECLTYP>0</ATTDECLTYP> <ATTEXPVIRT>0</ATTEXPVIRT> <TYPTYPE>1</TYPTYPE> <TYPE>TIMESTAMP</TYPE> <SRCROW1>0</SRCROW1> <SRCCOLUMN1>0</SRCCOLUMN1> <SRCROW2>0</SRCROW2> <SRCCOLUMN2>0</SRCCOLUMN2> <R3RELEASE>700</R3RELEASE> <TYPESRC_LENG>0</TYPESRC_LENG> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>TRESHOLD_SEC</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Treshold in seconds</DESCRIPT> <EXPOSURE>0</EXPOSURE> <STATE>1</STATE> <EDITORDER>4</EDITORDER> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <ATTDECLTYP>0</ATTDECLTYP> <ATTEXPVIRT>0</ATTEXPVIRT> <TYPTYPE>1</TYPTYPE> <TYPE>I</TYPE> <SRCROW1>0</SRCROW1> <SRCCOLUMN1>0</SRCCOLUMN1> <SRCROW2>0</SRCROW2> <SRCCOLUMN2>0</SRCCOLUMN2> <R3RELEASE>700</R3RELEASE> <TYPESRC_LENG>0</TYPESRC_LENG> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>STEP_TIME_STAMP</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>step timestamp</DESCRIPT> <EXPOSURE>0</EXPOSURE> <STATE>1</STATE> <EDITORDER>5</EDITORDER> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <ATTDECLTYP>0</ATTDECLTYP> <ATTEXPVIRT>0</ATTEXPVIRT> <TYPTYPE>1</TYPTYPE> <TYPE>TIMESTAMP</TYPE> <SRCROW1>0</SRCROW1> <SRCCOLUMN1>0</SRCCOLUMN1> <SRCROW2>0</SRCROW2> <SRCCOLUMN2>0</SRCCOLUMN2> <R3RELEASE>700</R3RELEASE> <TYPESRC_LENG>0</TYPESRC_LENG> </item> </ATTRIBUTES> <METHODS> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>START</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Start progress</DESCRIPT> <EXPOSURE>2</EXPOSURE> <STATE>1</STATE> <EDITORDER>1</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <MTDTYPE>0</MTDTYPE> <MTDDECLTYP>0</MTDDECLTYP> <R3RELEASE>700</R3RELEASE> <BCMTDCAT>00</BCMTDCAT> <BCMTDSYN>0</BCMTDSYN> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>FINISH</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Finish progress, clear status line</DESCRIPT> <EXPOSURE>2</EXPOSURE> <STATE>1</STATE> <EDITORDER>2</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <MTDTYPE>0</MTDTYPE> <MTDDECLTYP>0</MTDDECLTYP> <R3RELEASE>700</R3RELEASE> <BCMTDCAT>00</BCMTDCAT> <BCMTDSYN>0</BCMTDSYN> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>ADVANCE</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Advance indicator relatively</DESCRIPT> <EXPOSURE>2</EXPOSURE> <STATE>1</STATE> <EDITORDER>3</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <MTDTYPE>0</MTDTYPE> <MTDDECLTYP>0</MTDDECLTYP> <R3RELEASE>700</R3RELEASE> <BCMTDCAT>00</BCMTDCAT> <BCMTDSYN>0</BCMTDSYN> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>SET</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Set indicator absolutely</DESCRIPT> <EXPOSURE>2</EXPOSURE> <STATE>1</STATE> <EDITORDER>4</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <MTDTYPE>0</MTDTYPE> <MTDDECLTYP>0</MTDDECLTYP> <R3RELEASE>700</R3RELEASE> <BCMTDCAT>00</BCMTDCAT> <BCMTDSYN>0</BCMTDSYN> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>START_TIME</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Start Time checking</DESCRIPT> <EXPOSURE>2</EXPOSURE> <STATE>1</STATE> <EDITORDER>5</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <MTDTYPE>0</MTDTYPE> <MTDDECLTYP>0</MTDDECLTYP> <R3RELEASE>700</R3RELEASE> <BCMTDCAT>00</BCMTDCAT> <BCMTDSYN>0</BCMTDSYN> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>SET_STATUS_TEXT</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Set Status Text</DESCRIPT> <EXPOSURE>2</EXPOSURE> <STATE>1</STATE> <EDITORDER>6</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <MTDTYPE>0</MTDTYPE> <MTDDECLTYP>0</MTDDECLTYP> <R3RELEASE>700</R3RELEASE> <BCMTDCAT>00</BCMTDCAT> <BCMTDSYN>0</BCMTDSYN> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>RESET_TIME</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>reset times</DESCRIPT> <EXPOSURE>0</EXPOSURE> <STATE>1</STATE> <EDITORDER>1</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <MTDTYPE>0</MTDTYPE> <MTDDECLTYP>0</MTDDECLTYP> <R3RELEASE>700</R3RELEASE> <BCMTDCAT>00</BCMTDCAT> <BCMTDSYN>0</BCMTDSYN> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>CHECK_TIME</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>check elapsed time</DESCRIPT> <EXPOSURE>0</EXPOSURE> <STATE>1</STATE> <EDITORDER>2</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <MTDTYPE>0</MTDTYPE> <MTDDECLTYP>0</MTDDECLTYP> <R3RELEASE>700</R3RELEASE> <BCMTDCAT>00</BCMTDCAT> <BCMTDSYN>0</BCMTDSYN> </item> </METHODS> <EVENTS> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>ON_TIMEOUT</CMPNAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Fired when system timeout treshold exceeded</DESCRIPT> <EXPOSURE>2</EXPOSURE> <STATE>1</STATE> <EDITORDER>1</EDITORDER> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <EVTDECLTYP>0</EVTDECLTYP> <R3RELEASE>700</R3RELEASE> <BCEVTCAT>00</BCEVTCAT> </item> </EVENTS> <TYPES/> <PARAMETERS> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>ADVANCE</CMPNAME> <SCONAME>I_STATUS_TEXT</SCONAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Status line text</DESCRIPT> <CMPTYPE>1</CMPTYPE> <MTDTYPE>0</MTDTYPE> <EDITORDER>1</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <PARDECLTYP>0</PARDECLTYP> <PARPASSTYP>0</PARPASSTYP> <TYPTYPE>1</TYPTYPE> <TYPE>ANY</TYPE> <PAROPTIONL>X</PAROPTIONL> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>ADVANCE</CMPNAME> <SCONAME>I_STEP</SCONAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Advance step</DESCRIPT> <CMPTYPE>1</CMPTYPE> <MTDTYPE>0</MTDTYPE> <EDITORDER>2</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <PARDECLTYP>0</PARDECLTYP> <PARPASSTYP>0</PARPASSTYP> <TYPTYPE>1</TYPTYPE> <TYPE>I</TYPE> <PARVALUE>1</PARVALUE> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>ON_TIMEOUT</CMPNAME> <SCONAME>I_PERCENT_REMAINING</SCONAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Number of percent remaining in curr process</DESCRIPT> <CMPTYPE>2</CMPTYPE> <MTDTYPE>0</MTDTYPE> <EDITORDER>1</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <PARDECLTYP>1</PARDECLTYP> <PARPASSTYP>0</PARPASSTYP> <TYPTYPE>1</TYPTYPE> <TYPE>I</TYPE> <PAROPTIONL>X</PAROPTIONL> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>SET</CMPNAME> <SCONAME>I_STATUS_TEXT</SCONAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Status line text</DESCRIPT> <CMPTYPE>1</CMPTYPE> <MTDTYPE>0</MTDTYPE> <EDITORDER>1</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <PARDECLTYP>0</PARDECLTYP> <PARPASSTYP>0</PARPASSTYP> <TYPTYPE>1</TYPTYPE> <TYPE>ANY</TYPE> <PAROPTIONL>X</PAROPTIONL> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>SET</CMPNAME> <SCONAME>I_PROGRESS</SCONAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>New indicator value (absolute)</DESCRIPT> <CMPTYPE>1</CMPTYPE> <MTDTYPE>0</MTDTYPE> <EDITORDER>2</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <PARDECLTYP>0</PARDECLTYP> <PARPASSTYP>0</PARPASSTYP> <TYPTYPE>1</TYPTYPE> <TYPE>I</TYPE> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>SET_STATUS_TEXT</CMPNAME> <SCONAME>I_STATUS_TEXT</SCONAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Status line text</DESCRIPT> <CMPTYPE>1</CMPTYPE> <MTDTYPE>0</MTDTYPE> <EDITORDER>1</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <PARDECLTYP>0</PARDECLTYP> <PARPASSTYP>0</PARPASSTYP> <TYPTYPE>1</TYPTYPE> <TYPE>ANY</TYPE> <PAROPTIONL>X</PAROPTIONL> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>START</CMPNAME> <SCONAME>I_STATUS_TEXT</SCONAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Status line text</DESCRIPT> <CMPTYPE>1</CMPTYPE> <MTDTYPE>0</MTDTYPE> <EDITORDER>1</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <PARDECLTYP>0</PARDECLTYP> <PARPASSTYP>0</PARPASSTYP> <TYPTYPE>1</TYPTYPE> <TYPE>ANY</TYPE> <PAROPTIONL>X</PAROPTIONL> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>START</CMPNAME> <SCONAME>I_HIGH_BOUND</SCONAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Maximum step count</DESCRIPT> <CMPTYPE>1</CMPTYPE> <MTDTYPE>0</MTDTYPE> <EDITORDER>2</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <PARDECLTYP>0</PARDECLTYP> <PARPASSTYP>0</PARPASSTYP> <TYPTYPE>1</TYPTYPE> <TYPE>I</TYPE> <PARVALUE>100</PARVALUE> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>START</CMPNAME> <SCONAME>I_PERCENT_TRESHOLD</SCONAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Percent treshold to update indicator and status
line</DESCRIPT>
<CMPTYPE>1</CMPTYPE> <MTDTYPE>0</MTDTYPE> <EDITORDER>3</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <PARDECLTYP>0</PARDECLTYP> <PARPASSTYP>0</PARPASSTYP> <TYPTYPE>1</TYPTYPE> <TYPE>I</TYPE> <PARVALUE>5</PARVALUE> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>START</CMPNAME> <SCONAME>I_ANY_TAB</SCONAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Data table to count the high bound</DESCRIPT> <CMPTYPE>1</CMPTYPE> <MTDTYPE>0</MTDTYPE> <EDITORDER>4</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <PARDECLTYP>0</PARDECLTYP> <PARPASSTYP>1</PARPASSTYP> <TYPTYPE>1</TYPTYPE> <TYPE>ANY TABLE</TYPE> <PAROPTIONL>X</PAROPTIONL> </item> <item> <CLSNAME>ZCL_PROGRESS_INDICATOR</CLSNAME> <CMPNAME>START</CMPNAME> <SCONAME>I_SEC_TRESHOLD</SCONAME> <VERSION>1</VERSION> <LANGU>E</LANGU> <DESCRIPT>Seconds treshold</DESCRIPT> <CMPTYPE>1</CMPTYPE> <MTDTYPE>0</MTDTYPE> <EDITORDER>5</EDITORDER> <DISPID>0</DISPID> <AUTHOR>KOROLESE</AUTHOR> <CREATEDON>2006-07-31</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> <PARDECLTYP>0</PARDECLTYP> <PARPASSTYP>0</PARPASSTYP> <TYPTYPE>1</TYPTYPE> <TYPE>I</TYPE> <PAROPTIONL>X</PAROPTIONL> </item> </PARAMETERS> <EXCEPTIONS/> <IMPLEMENTINGS/> <IMPL_DETAILS/> <FRIENDSHIPS/> <TYPEPUSAGES/> <CLSDEFERRDS/> <INTDEFERRDS/> <ALIASES/> <INHERITANCE> <VERSION>0</VERSION> <STATE>0</STATE> <CREATEDON>0000-00-00</CREATEDON> <CHANGEDON>0000-00-00</CHANGEDON> </INHERITANCE> <INTERFACES/> <REDEFINITIONS/> <TYPE_SOURCE/> <LOCALS_SRC/> <LOCALS_DEF/> <LOCALS_IMP/> <LOCALS_MAC/> <TEXT_POOL> <E/> </TEXT_POOL> <METHOD_SOURCE> <ADVANCE> <item>METHOD advance.</item> <item> DATA:</item> <item> l_progress TYPE i.</item> <item/> <item> l_progress = current_progress + i_step.</item> <item> CALL METHOD set( i_status_text = i_status_text</item> <item> i_progress = l_progress ).</item> <item>ENDMETHOD.</item> </ADVANCE> <FINISH> <item>METHOD finish.</item> <item> CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'.</item> <item>ENDMETHOD.</item> </FINISH> <SET> <item>METHOD set.</item> <item> DATA:</item> <item> text TYPE string,</item> <item> delta TYPE i,</item> <item> timestamp TYPE timestamp,</item> <item> last_percent TYPE i,</item> <item> need_show,</item> <item> l_new_progress TYPE i.</item> <item/> <item> current_progress = i_progress.</item> <item> IF current_progress > high_bound.</item> <item> current_progress = high_bound.</item> <item> ENDIF.</item> <item/> <item> l_new_progress = 100 * current_progress / high_bound.</item> <item> CHECK last_shown_progress NE l_new_progress.</item> <item/> <item> last_percent = 100 - treshold.</item> <item/> <item> CALL METHOD check_time.</item> <item/> <item> IF treshold_sec > 0</item> <item> AND l_new_progress < last_percent.</item> <item> GET TIME STAMP FIELD timestamp.</item> <item> IF timestamp > step_time_stamp.</item> <item> CALL FUNCTION 'SRET_TIME_DIFF_GET'</item> <item> EXPORTING</item> <item> utc_start = step_time_stamp</item> <item> utc_end = timestamp</item> <item> IMPORTING</item> <item> second = delta</item> <item> EXCEPTIONS</item> <item> paramerr = 0</item> <item> OTHERS = 0.</item> <item/> <item> IF delta > treshold_sec.</item> <item> need_show = 'X'.</item> <item> step_time_stamp = timestamp.</item> <item> ENDIF.</item> <item> ENDIF.</item> <item> ELSE.</item> <item> delta = abs( l_new_progress - last_shown_progress ).</item>
<item> IF delta >= treshold.</item> <item> need_show = 'X'.</item> <item> ENDIF.</item> <item> ENDIF.</item> <item/> <item> IF need_show = 'X'.</item> <item/> <item> last_shown_progress = l_new_progress.</item> <item/> <item> IF i_status_text IS INITIAL.</item> <item> text = progress_text.</item> <item> ELSE.</item> <item> text = i_status_text.</item> <item> ENDIF.</item> <item/> <item> CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'</item> <item> EXPORTING</item> <item> percentage = last_shown_progress</item> <item> text = text.</item> <item> ENDIF.</item> <item/> <item>ENDMETHOD.</item> </SET> <START> <item>METHOD start.</item> <item> CLEAR:</item> <item> current_progress,</item> <item> last_shown_progress.</item> <item/> <item> treshold = i_percent_treshold.</item> <item> progress_text = i_status_text.</item> <item/> <item> GET TIME STAMP FIELD step_time_stamp.</item> <item/> <item> IF i_any_tab[] IS INITIAL.</item> <item> high_bound = i_high_bound.</item> <item> ELSE.</item> <item> DESCRIBE TABLE i_any_tab LINES high_bound.</item> <item> ENDIF.</item> <item/> <item> IF high_bound > 0.</item> <item> last_shown_progress = 1.</item> <item> ENDIF.</item> <item/> <item> IF i_sec_treshold > 0.</item> <item> treshold_sec = i_sec_treshold.</item> <item> ENDIF.</item> <item/> <item> CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'</item> <item> EXPORTING</item> <item> percentage = last_shown_progress</item> <item> text = i_status_text.</item> <item/> <item/> <item>ENDMETHOD.</item> </START> <RESET_TIME> <item>METHOD reset_time.</item> <item> DATA:</item> <item> e_value TYPE spfpflpar-pvalue.</item> <item/> <item> GET TIME STAMP FIELD start_time_stamp.</item> <item/> <item> CALL FUNCTION 'RSAN_SYSTEM_PARAMETER_READ'</item> <item> EXPORTING</item> <item> i_name = 'rdisp/max_wprun_time'</item> <item> IMPORTING</item> <item> e_value = e_value</item> <item> EXCEPTIONS</item> <item> read_error = 0</item> <item> OTHERS = 0.</item> <item/> <item> time_limit = e_value + e_value / 2.</item> <item/> <item>ENDMETHOD.</item> </RESET_TIME> <CHECK_TIME> <item>METHOD check_time.</item> <item> DATA:</item> <item> diff TYPE i,</item> <item> l_remaining_percent TYPE i,</item> <item> current_time TYPE timestamp.</item> <item/> <item> CHECK NOT start_time_stamp IS INITIAL</item> <item> AND NOT time_limit IS INITIAL.</item> <item/> <item> GET TIME STAMP FIELD current_time.</item> <item> CHECK current_time > start_time_stamp.</item> <item/> <item> CALL FUNCTION 'SRET_TIME_DIFF_GET'</item> <item> EXPORTING</item> <item> utc_start = start_time_stamp</item> <item> utc_end = current_time</item> <item> IMPORTING</item> <item> second = diff</item> <item> EXCEPTIONS</item> <item> paramerr = 0</item> <item> OTHERS = 0.</item> <item/> <item> IF diff > time_limit.</item> <item> CALL METHOD reset_time.</item> <item/> <item> l_remaining_percent = 100 - 100 * current_progress /
high_bound.</item>
<item> RAISE EVENT on_timeout</item> <item> EXPORTING i_percent_remaining =
l_remaining_percent.</item>
<item> ENDIF.</item> <item>ENDMETHOD.</item> </CHECK_TIME> <START_TIME> <item>METHOD start_time.</item> <item> CALL METHOD reset_time.</item> <item>ENDMETHOD.</item> </START_TIME> <SET_STATUS_TEXT> <item>METHOD set_status_text .</item> <item> CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'</item> <item> EXPORTING</item> <item> text = i_status_text.</item> <item>ENDMETHOD.</item> </SET_STATUS_TEXT> </METHOD_SOURCE>
</CLASS_ROOT>