segunda-feira, 23 de janeiro de 2023

Review and Validate Tools for SAP Script Forms

 After completing a few cycles of form remediation which includes hundreds of SAP script forms, I keep trying to prepare some tools for self-check and quick validation of SAP script forms. In this article, I wrap up various programs for such purposes.

 

<1> Script Form Break-Down Tools by Michael Keller

  • 1. It can provide different colors for Element, Command, and Comment lines which will much easier to check syntax;
  • 2. Also this tool has Indentation for IF/ELSE/ENDIF/CASE/WHEN statements can help quick identity fundamental flaws;
  • 3. Fold and Unfold pairs of IF/ENDIF, etc.

Please check more details about this program at this.

 

<2> Script Form Scanner post by Sabrina Pinto

  • It will help find where used list of any text string for all SAP scripts in one shot.
  • It can check all included standard texts related to addresses or Logos easier and determine how many forms and which windows are actually sharing the same SO10 text now.

Please check more details about this program at this.

<3> Standard Text SO10 Scanner

May need to update hundreds of standard text especially related to address with conditions, I create this tiny program to check the specific text inside the standard text.

  1. This could be used to check where used list for any specific address and find which could be shared or updated together;
  2. Can be used to validate new standard text maintenance and related remediation.

REPORT z_so10_search.
TABLES: stxh.

*-----------------------------------------------------------------------
* Types& Data Definition
*-----------------------------------------------------------------------
TYPES: BEGIN OF ty_out,
         tdobject TYPE stxl-tdobject,
         tdname   TYPE stxl-tdname,
         tdid     TYPE stxl-tdid,
         tdspras  TYPE stxl-tdspras,
         tdformat TYPE tdformat,
         flag     TYPE flag,
         tdline   TYPE tdline,
       END OF ty_out.
DATA: gt_out TYPE TABLE OF ty_out,
      gs_out TYPE ty_out.

TYPES: BEGIN OF ty_stxh,
        tdobject TYPE stxl-tdobject,
        tdname LIKE stxh-tdname,
        tdspras LIKE stxh-tdspras,
      END OF ty_stxh.
DATA: gt_stxh TYPE TABLE OF ty_stxh,
      gs_stxh TYPE ty_stxh,
      gt_lines LIKE TABLE OF tline,
      gs_lines LIKE LINE OF gt_lines.

*-----------------------------------------------------------------------
* Selection Parameters
*-----------------------------------------------------------------------

SELECTION-SCREEN: BEGIN OF BLOCK a2 WITH FRAME TITLE text-002.
PARAMETERS p_search(80) OBLIGATORY.
PARAMETERS: P_match AS CHECKBOX. "display only specific line
SELECTION-SCREEN: END   OF BLOCK a2.

SELECTION-SCREEN SKIP.
SELECTION-SCREEN: BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_tdname FOR stxh-tdname.
PARAMETERS p_obj   TYPE stxh-tdobject OBLIGATORY DEFAULT 'TEXT'.
PARAMETERS p_id    TYPE stxh-tdid DEFAULT 'ST'.
PARAMETERS p_langu LIKE stxh-tdspras DEFAULT 'EN'.
SELECTION-SCREEN: END   OF BLOCK a1.

*-----------------------------------------------------------------------
* START-OF-SELECTION
*-----------------------------------------------------------------------
START-OF-SELECTION.
  PERFORM get_data.

*-----------------------------------------------------------------------
* FORM GET_DATA
*-----------------------------------------------------------------------
FORM get_data.
  DATA: l_tab_tadir     TYPE TABLE OF tadir,
        l_str_tadir     TYPE tadir,
        l_tabix_str(10) TYPE c,
        l_percentage    TYPE p,
        l_cnt           TYPE i,
        l_text          TYPE itex132,
        l_cnt_str(10)   TYPE c.

  REFRESH gt_stxh.
  SELECT tdobject tdname tdspras
    FROM stxh
    INTO TABLE gt_stxh
    WHERE tdname IN s_tdname
    AND tdobject = p_obj
    AND tdid = p_id
    AND tdspras = p_langu.

* Write count of programs into list
  DESCRIBE TABLE gt_stxh LINES l_cnt.
  IF l_cnt = 0.
    EXIT.
  ENDIF.

  l_cnt_str = l_cnt.
  CONDENSE l_cnt_str.

  REFRESH: gt_out.
  LOOP AT gt_stxh INTO gs_stxh.

    l_tabix_str = sy-tabix.
    CONDENSE l_tabix_str.
    IF l_cnt IS NOT INITIAL.
*   Display progress indicator
      l_percentage = 100 * ( sy-tabix / l_cnt ).

      CONCATENATE '(' 'Processing'(009) l_tabix_str 'of'(010) l_cnt_str ')'
                   'Searching Text object'(008) gs_stxh-tdname
                  INTO l_text SEPARATED BY space.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          percentage = l_percentage
          text       = l_text.
    ENDIF.

    REFRESH gt_lines.
    CALL FUNCTION 'READ_TEXT'
      EXPORTING
*       CLIENT                  = SY-MANDT
        id                      = p_id
        language                = gs_stxh-tdspras
        name                    = gs_stxh-tdname
        object                  = p_obj
      TABLES
        lines                   = gt_lines
      EXCEPTIONS
        id                      = 0
        language                = 0
        name                    = 0
        not_found               = 0
        object                  = 0
        reference_check         = 0
        wrong_access_to_archive = 0
        OTHERS                  = 0.

    FIND ALL OCCURRENCES OF REGEX p_search IN TABLE gt_lines
* RESPECTING CASE
    RESULTS DATA(results).

    SEARCH gt_lines FOR p_search.
    IF sy-subrc EQ 0.
      CONDENSE gs_stxh-tdname.
      CLEAR gs_out.
      MOVE-CORRESPONDING gs_stxh TO gs_out.
      LOOP AT gt_lines INTO gs_lines.
        gs_out-tdformat = gs_lines-tdformat.
        gs_out-tdline   = gs_lines-tdline.
        SEARCH gs_lines FOR p_search.
        IF sy-subrc EQ 0.
          gs_out-flag = 'X'.
        ELSE.
          CLEAR gs_out-flag.
          if P_match = 'X'.
            CONTINUE.
          endif.
        ENDIF.

        APPEND gs_out TO gt_out.
      ENDLOOP.
    ENDIF.
  ENDLOOP.

  IF gt_out[] IS NOT INITIAL.
    cl_demo_output=>display_data( gt_out ).
  ELSE.
    WRITE: / 'String not found!'.
  ENDIF.

ENDFORM.

Hope those tools could help during the work of SAP script forms remediation and new address-related maintenance.


Source: https://blogs.sap.com/2023/01/12/review-and-validate-tools-for-sap-script-forms/

Nenhum comentário:

Postar um comentário