* _______ _______ _______ _______ _______ _______ ______ _______ _______ ______ _______ * | _ | _ | _ | | | _ | || _ | _ | _ | | _ | * | |_| | |_| | |_| | _ | | |_| | _ | |_| | |_| | | || | |_| | * | | | | |_| | | | | | | | | |_||_| | * | | _ || | ___| _| | |_| | | _ || __ | | * | _ | |_| | _ | | | |_| _ | | _ | |_| | | | | _ | * |__| |__|_______|__| |__|___| |_______|__| |__|______||__| |__|_______|___| |_|__| |__| * www.abapcadabra.com * *------------------------------------------------------------------------------------------- * program : ZABAPCADABRA_SAPSCRIPT_SCANNER * title : Analyse SapScript forms - find hardcoded references that * may need to be changed (such as website references) * functional area : Cross modules * environment : 4.7 * program Function : This report allows the end user to specify SapScript * forms that are then analyzed for references to eg a website * or a company email address. Need to change the company name? * Run it through the analyzer to find what needs to be changed. * * Documentation : Search for "Sapscript analysis" on AbapcadabrA.com * Previous version : This is the initial version * Developer name : Wim Maasdam * Development date : 08/01/2015 * Version : 0.1 *--------------------------------------------------------------------- * Change list: * Date Description * 08/01/2015 Initial release * *--------------------------------------------------------------------- REPORT ZABAPCADABRA_SAPSCRIPT_SCANNER. TABLES: stxh, sscrfields. "Selection screen purpose only *--------------------------------------------------------------------- * C L A S S D E F I N I T I O N *--------------------------------------------------------------------- CLASS lcl_controller DEFINITION. PUBLIC SECTION. TYPES: BEGIN OF ty_forms, * List the fields you want to show in the F4 popup TDNAME TYPE stxh-TDNAME, TDTITLE TYPE stxh-TDTITLE, TDSPRAS TYPE stxh-TDSPRAS, END OF ty_forms, BEGIN OF ty_totals, forms TYPE n length 8, languages TYPE n length 8, case1 TYPE n length 8, case2 TYPE n length 8, case3 TYPE n length 8, case4 TYPE n length 8, END OF ty_totals. CLASS-DATA: gt_comparison_strings TYPE STANDARD TABLE OF string, gt_forms TYPE STANDARD TABLE OF ty_forms, gw_form TYPE ty_forms, gv_current_form TYPE stxh-TDNAME, gw_totals TYPE ty_totals, gw_form_totals TYPE ty_totals. CLASS-METHODS: f4_forms CHANGING formname TYPE stxh-TDNAME, check_form, print_totals IMPORTING totals TYPE ty_totals TITLE TYPE string. ENDCLASS. *--------------------------------------------------------------------- * S E L E C T I O N - S C R E E N *--------------------------------------------------------------------- SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(27) lbl_01 FOR FIELD so_sform. SELECT-OPTIONS: so_sform FOR stxh-TDNAME OBLIGATORY. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(27) lbl_02 FOR FIELD so_spras. SELECT-OPTIONS: so_spras FOR stxh-tdspras. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(30) lbl_03 FOR FIELD pa_mandt. PARAMETERS: pa_mandt TYPE sy-mandt DEFAULT sy-mandt. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(27) lbl_04 FOR FIELD so_refs. SELECT-OPTIONS so_refs FOR stxh-TDREFNAME NO INTERVALS LOWER CASE. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN SKIP. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(30) lbl_10 FOR FIELD pa_time1. PARAMETERS: pa_time1 TYPE p LENGTH 3 DECIMALS 2 DEFAULT '0.25'. SELECTION-SCREEN COMMENT 40(30) lbl_hrs. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(30) lbl_11 FOR FIELD pa_time2. PARAMETERS: pa_time2 TYPE p LENGTH 3 DECIMALS 2 DEFAULT '0.25'. SELECTION-SCREEN COMMENT 40(30) lbl_hr2. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(30) lbl_12 FOR FIELD pa_time3. PARAMETERS: pa_time3 TYPE p LENGTH 3 DECIMALS 2 DEFAULT '0.75'. SELECTION-SCREEN COMMENT 40(30) lbl_hr3. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(30) lbl_13 FOR FIELD pa_time4. PARAMETERS: pa_time4 TYPE p LENGTH 3 DECIMALS 2 DEFAULT '1.50'. SELECTION-SCREEN COMMENT 40(30) lbl_hr4. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(30) lbl_14 FOR FIELD pa_time5. PARAMETERS: pa_time5 TYPE p LENGTH 3 DECIMALS 2 DEFAULT '1.00'. SELECTION-SCREEN COMMENT 40(30) lbl_hr5. SELECTION-SCREEN END OF LINE. selection-SCREEN SKIP. selection-SCREEN BEGIN OF LINE. SELECTION-SCREEN PUSHBUTTON (70) lbl_abca USER-COMMAND ABAPCADABRA VISIBLE LENGTH 5. selection-SCREEN END OF LINE. AT SELECTION-SCREEN ON VALUE-REQUEST FOR so_sform-low. lcl_controller=>f4_forms( CHANGING formname = so_sform-low ). AT SELECTION-SCREEN. CASE sscrfields-ucomm. WHEN 'ABAPCADABRA'. CALL FUNCTION 'CALL_BROWSER' EXPORTING URL = 'http://abapcadabra.com/index.php/smartforms/488-sapscript-analyser' EXCEPTIONS OTHERS = 0. ENDCASE. *--------------------------------------------------------------------- * C L A S S I M P L E M E N T A T I O N *--------------------------------------------------------------------- CLASS lcl_controller IMPLEMENTATION. METHOD f4_forms. DATA: lt_columns TYPE STANDARD TABLE OF ty_forms, lt_returns TYPE STANDARD TABLE OF DDSHRETVAL, lw_return TYPE DDSHRETVAL, lv_dynpro_field TYPE HELP_INFO-DYNPROFLD. CLEAR: lt_columns[]. * Selection of actual data SELECT TDNAME TDTITLE TDSPRAS FROM STXH INTO TABLE lt_columns WHERE TDOBJECT = 'FORM' AND * TDID = 'DEF' AND TDSPRAS = sy-langu. lv_dynpro_field = formname. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'TDNAME' dynpprog = SY-REPID dynpnr = '1000' dynprofield = lv_dynpro_field value_org = 'S' TABLES value_tab = lt_columns return_tab = lt_returns. READ TABLE lt_returns INDEX 1 INTO lw_return. IF sy-subrc = 0. formname = lw_return-FIELDVAL. ENDIF. ENDMETHOD. METHOD check_form. DATA: lv_sapscript_form TYPE ITCTA-TDFORM, lw_HEADER TYPE THEAD, lw_FORM_HEADER TYPE ITCTA, lt_FORM_LINES TYPE STANDARD TABLE OF TLINE, lw_formline TYPE tline, lv_last_window TYPE tline, lv_last_element TYPE tline, lv_last_longtext TYPE tline, lv_comparison_string TYPE string, lv_hit TYPE boolean, lw_THEAD TYPE THEAD, lv_dummy TYPE C length 30, lt_lines TYPE STANDARD TABLE OF tline, lw_tline TYPE tline. DEFINE write_prep. IF NOT lv_last_window IS INITIAL. FORMAT COLOR 1 INTENSIFIED ON. WRITE: /4(14) 'WINDOW:', (110) lv_last_window-tdline. CLEAR lv_last_window. "< to avoid printing the window multiple times ENDIF. IF NOT lv_last_element IS INITIAL. FORMAT COLOR 1 INTENSIFIED off. WRITE: /6(12) 'ELEMENT:', (110) lv_last_element-tdline. CLEAR lv_last_element. "< to avoid printing the element multiple times ENDIF. IF NOT lv_last_longtext IS INITIAL. FORMAT COLOR 4 INTENSIFIED ON. WRITE: /8(10) 'LONGTEXT:', (110) lv_last_longtext+10. CLEAR lv_last_longtext. "< to avoid printing the longtext heading multiple times ENDIF. FORMAT RESET. END-OF-DEFINITION. lv_sapscript_form = gw_form-tdname. * gt_comparison_strings CALL FUNCTION 'READ_FORM' EXPORTING CLIENT = pa_mandt FORM = lv_sapscript_form LANGUAGE = gw_form-tdspras IMPORTING FORM_HEADER = lw_FORM_HEADER HEADER = lw_HEADER TABLES FORM_LINES = lt_FORM_LINES. SKIP. FORMAT COLOR 7 INTENSIFIED ON. WRITE: / 'Sapscript:', lv_sapscript_form INTENSIFIED off, 'language:', gw_form-tdspras INTENSIFIED off, 'Original language:', lw_FORM_HEADER-TDOSPRAS INTENSIFIED off, 'client:', pa_mandt INTENSIFIED off, (53) space. FORMAT RESET. * Check the content of the form: LOOP AT LT_FORM_LINES INTO lw_formline. * Keep track of the (last) window: IF lw_formline-tdformat = '/W'. lv_last_window = lw_formline. CONTINUE. ENDIF. IF lw_formline-tdformat = '/E'. lv_last_element = lw_formline. CONTINUE. ENDIF. * A line on form_lines could refer to a longtext: longtexts are listed IF lw_formline(10) = '/:INCLUDE '. * If the longtext can be read, it can be checked: lv_last_longtext = lw_formline. * NOTE: it is assumed that the sequence of parameters for long text is a fixed one: SPLIT lw_formline-tdline AT space INTO lv_dummy lw_THEAD-tdname lv_dummy lw_THEAD-tdobject lv_dummy lw_thead-tdid lv_dummy lw_thead-tdspras. * If the text reference contains variables, mention the text: IF lw_THEAD-tdname CS '&' OR lw_THEAD-tdobject CS '&' OR lw_thead-tdid CS '&'. write_prep. FORMAT COLOR 3 INTENSIFIED ON. WRITE: /10(8) 'NOTE:', (110) 'include text reference with variable name(s)', (6) pa_time3, 'h'. ADD 1 TO lcl_controller=>gw_form_totals-case3. FORMAT RESET. CONTINUE. ENDIF. * If the text reference contains the text 'LOGO': IF lw_formline-tdline CS 'LOGO' OR lw_formline-tdline CS 'GRAPHIC' OR lw_formline-tdline CS 'IMAGE'. write_prep. FORMAT COLOR 3 INTENSIFIED ON. WRITE: /10(8) 'NOTE:', (110) 'include text could be for GRAPHICS ', (6) pa_time4, 'h'. ADD 1 TO lcl_controller=>gw_form_totals-case4. FORMAT RESET. ENDIF. * If (only) the language was set up as a variabele, assume the form language IF lw_thead-tdspras CS '&'. lw_thead-tdspras = gw_form-tdspras. ENDIF. CALL FUNCTION 'READ_TEXT' EXPORTING ID = lw_thead-tdid LANGUAGE = lw_thead-tdspras NAME = lw_THEAD-tdname OBJECT = lw_THEAD-tdobject TABLES LINES = lt_lines EXCEPTIONS OTHERS = 4. IF SY-SUBRC <> 0. * Longtext could not be read - ignore the entry ELSE. LOOP AT lt_lines INTO lw_tline. LOOP AT gt_comparison_strings INTO lv_comparison_string. CLEAR lv_hit. CONCATENATE '*' lv_comparison_string '*' INTO lv_comparison_string. IF lw_tline-tdline CP lv_comparison_string. lv_hit = 'X'. EXIT. ENDIF. ENDLOOP. IF NOT lv_hit IS INITIAL. write_prep. FORMAT COLOR 3 INTENSIFIED ON. WRITE: /16(2) lw_tline-tdformat, (110) lw_tline-tdline, (6) pa_time2, 'h'. ADD 1 TO lcl_controller=>gw_form_totals-case2. FORMAT RESET. ENDIF. ENDLOOP. ENDIF. CLEAR lv_last_longtext. ELSEIF lw_formline(9) = '/:BITMAP '. write_prep. FORMAT COLOR 3 INTENSIFIED ON. WRITE: /10(8) 'BITMAP:', (110) lw_formline-tdline, (6) pa_time4, 'h'. ADD 1 TO lcl_controller=>gw_form_totals-case4. FORMAT RESET. CONTINUE. ELSEIF lw_formline-tdformat = '/*'. * Comment lines are to be ignored ELSE. * Check if the line contains references to the search words: LOOP AT gt_comparison_strings INTO lv_comparison_string. CLEAR lv_hit. CONCATENATE '*' lv_comparison_string '*' INTO lv_comparison_string. IF lw_formline-tdline CP lv_comparison_string. lv_hit = 'X'. EXIT. ENDIF. ENDLOOP. IF NOT lv_hit IS INITIAL. write_prep. FORMAT COLOR 3 INTENSIFIED ON. WRITE: /16(2) lw_formline-tdformat, (110) lw_formline-tdline, (6) pa_time1, 'h'. ADD 1 TO lcl_controller=>gw_form_totals-case1. FORMAT RESET. ENDIF. ENDIF. ENDLOOP. ENDMETHOD. METHOD print_totals. DATA: lv_calculated TYPE f, lv_calculated_total TYPE f. * Report the totals-block: ULINE. WRITE: / TITLE. SKIP. lv_calculated = totals-forms * pa_time5. WRITE: /8(22) 'Nr of forms:', totals-forms NO-ZERO, 'x', pa_time5 no-gap, 'h', '=', (8) lv_calculated DECIMALS 2 EXPONENT 0, 'h'. lv_calculated_total = lv_calculated. lv_calculated = totals-case1 * pa_time1. WRITE: /8(22) 'Nr of Languages:', totals-languages NO-ZERO, /8(22) 'Hardcoded references:', totals-case1 NO-ZERO, 'x', pa_time1 no-gap, 'h', '=', (8) lv_calculated DECIMALS 2 EXPONENT 0, 'h'. ADD lv_calculated TO lv_calculated_total. lv_calculated = totals-case2 * pa_time2. WRITE: /8(22) 'Long text changes:', totals-case2 NO-ZERO, 'x', pa_time2 no-gap, 'h', '=', (8) lv_calculated DECIMALS 2 EXPONENT 0, 'h'. ADD lv_calculated TO lv_calculated_total. lv_calculated = totals-case3 * pa_time3. WRITE: /8(22) 'Variabele long texts:', totals-case3 NO-ZERO, 'x', pa_time3 no-gap, 'h', '=', (8) lv_calculated DECIMALS 2 EXPONENT 0, 'h'. ADD lv_calculated TO lv_calculated_total. lv_calculated = totals-case4 * pa_time4. WRITE: /8(22) 'Logo and bitmap:', totals-case4 NO-ZERO, 'x', pa_time4 no-gap, 'h', '=', (8) lv_calculated DECIMALS 2 EXPONENT 0, 'h'. ADD lv_calculated TO lv_calculated_total. WRITE: /(42) '', (8) 'Total:', (8) lv_calculated_total DECIMALS 2 EXPONENT 0, 'h'. ULINE. ENDMETHOD. ENDCLASS. *--------------------------------------------------------------------- * I N I T I A L I Z A T I O N *--------------------------------------------------------------------- INITIALIZATION. * All texts for this report have been set up as hard-coded texts (no use * of the report text-pool). Reason: easy copying of report source code. lbl_01 = 'Sapscript form name'. lbl_02 = 'Language'. lbl_03 = 'Source client'. lbl_04 = 'Search words'. lbl_10 = 'Hardcoded reference'. lbl_11 = 'Text reference change'. lbl_12 = 'Text with variables'. lbl_13 = 'Use of bitmap'. lbl_14 = 'Sapscript form overhead'. lbl_hrs = lbl_hr2 = lbl_hr3 = lbl_hr4 = lbl_hr5 = 'hours'. lbl_abca = '@N5\QMore on AbapcadabrA.com@'. *--------------------------------------------------------------------- * S T A R T - O F - S E L E C T I O N *--------------------------------------------------------------------- START-OF-SELECTION. IF so_refs[] IS INITIAL. MESSAGE 'No reference words to be checked' TYPE 'S'. ELSE. CLEAR: lcl_controller=>gt_comparison_strings[]. LOOP AT so_refs. APPEND so_refs-low TO lcl_controller=>gt_comparison_strings. ENDLOOP. SELECT TDNAME TDTITLE TDSPRAS FROM STXH INTO TABLE lcl_controller=>gt_forms WHERE TDOBJECT = 'FORM' AND TDNAME IN so_sform AND TDSPRAS IN so_spras. SORT lcl_controller=>gt_forms. DELETE ADJACENT DUPLICATES FROM lcl_controller=>gt_forms. CLEAR: lcl_controller=>gw_totals, lcl_controller=>gv_current_form. LOOP AT lcl_controller=>gt_forms INTO lcl_controller=>gw_form. IF lcl_controller=>gv_current_form IS INITIAL. lcl_controller=>gv_current_form = lcl_controller=>gw_form-tdname. lcl_controller=>gw_form_totals-forms = 1. ELSEIF lcl_controller=>gv_current_form <> lcl_controller=>gw_form-tdname. lcl_controller=>gv_current_form = lcl_controller=>gw_form-tdname. IF lcl_controller=>gw_form_totals-case1 = 0 AND lcl_controller=>gw_form_totals-case2 = 0 AND lcl_controller=>gw_form_totals-case3 = 0 AND lcl_controller=>gw_form_totals-case4 = 0. WRITE: /10 'SapScript is up to date, no changes required'. ELSE. lcl_controller=>print_totals( EXPORTING totals = lcl_controller=>gw_form_totals TITLE = 'SUB TOTAL (single SapScript form, all languages)' ). ADD-CORRESPONDING lcl_controller=>gw_form_totals TO lcl_controller=>gw_totals. ENDIF. CLEAR lcl_controller=>gw_form_totals. lcl_controller=>gw_form_totals-forms = 1. ENDIF. ADD 1 TO lcl_controller=>gw_form_totals-languages. lcl_controller=>check_form( ). ENDLOOP. IF lcl_controller=>gw_form_totals-case1 = 0 AND lcl_controller=>gw_form_totals-case2 = 0 AND lcl_controller=>gw_form_totals-case3 = 0 AND lcl_controller=>gw_form_totals-case4 = 0. WRITE: / '==> SapScript is up to date, no changes required'. ELSE. lcl_controller=>print_totals( EXPORTING totals = lcl_controller=>gw_form_totals TITLE = '=== SUB TOTAL (single SapScript form, all languages)' ). ADD-CORRESPONDING lcl_controller=>gw_form_totals TO lcl_controller=>gw_totals. ENDIF. SKIP. WRITE: / 'The following comparison strings were checked:'. DATA: lv_string TYPE string. LOOP AT lcl_controller=>gt_comparison_strings INTO lv_string. WRITE /(8) ''. FORMAT COLOR 3 INTENSIFIED ON. WRITE (40) lv_string. FORMAT RESET. ENDLOOP. SKIP. lcl_controller=>print_totals( EXPORTING totals = lcl_controller=>gw_totals TITLE = '=== GRAND TOTAL' ). ENDIF.