Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata
 \------------------------------------------------------------------------------\-

REPORT  z_efinder_plus NO STANDARD PAGE HEADING LINE-SIZE 150.

\*&---------------------------------------------------------------------\*
\*& Variables
\*&---------------------------------------------------------------------\*
DATA : t_jtab TYPE STANDARD TABLE OF tadir,
       wa_jtab TYPE tadir.

DATA : v_devclass TYPE tadir-devclass,
       v_smod TYPE i ,
       v_badi TYPE i ,
       v_object TYPE trobjtype.

\*&---------------------------------------------------------------------\*
\*& Constants
\*&---------------------------------------------------------------------\*
CONSTANTS : c_x TYPE c VALUE 'X',
            c_e TYPE c VALUE 'E',
            c_l TYPE c VALUE 'L',
            c_enha(16) TYPE c VALUE 'WA_FINAL-ENHNAME',
            c_prog_saplsexo(8) TYPE c VALUE  'SAPLSEXO',
            c_dyn_num1(4) TYPE c VALUE '0100',
            c_dyn_num(4) TYPE c VALUE '0120',
            c_fname_bdc(10) TYPE c VALUE 'BDC_OKCODE',
            c_fname_bdc1(10) TYPE c VALUE 'BDC_CURSOR',
            c_fval_imp(9) TYPE c VALUE '=IMP_SHOW',
            c_fval_genha(9) TYPE c VALUE 'G_ENHNAME',
            c_fnam_new1(10) TYPE c VALUE 'G_IS_NEW_1',
            c_fnam_new2(10) TYPE c VALUE 'G_IS_NEW_2',
            c_fval_enspot(13) TYPE c VALUE 'G_ENHSPOTNAME',
            c_fval_show(5) TYPE c VALUE '=SHOW',
            c_enhspt(16) TYPE c VALUE 'WA_FINAL-ENHSPOT',
            c_fval_isspot(9) TYPE c VALUE 'G_IS_SPOT',
            c_fval_ispot(7) TYPE c VALUE '=ISSPOT',
            c_smod(4) TYPE c VALUE 'SMOD',
            c_fval_badi(9) TYPE c VALUE 'G_IS_BADI',
            c_fnam_badi(10) TYPE c VALUE 'G_BADINAME',
            c_jtab(7) TYPE c VALUE 'WA_JTAB',
            c_sxsd(4) TYPE c VALUE 'SXSD',
            c_mon(3) TYPE c VALUE 'MON',
            c_pgmid_r3tr(4) TYPE c VALUE 'R3TR',
            c_obj_prog(4) TYPE c VALUE 'PROG',
            c_f TYPE c VALUE 'F',
            c_tran(4) TYPE c VALUE 'TRAN',
            c_fugr(4) TYPE c VALUE 'FUGR',
            c_enho(4) TYPE c VALUE 'ENHO',
            c_enhs(4) TYPE c VALUE 'ENHS',
            c_incld(7) TYPE c VALUE 'INCLUDE',
            c_t TYPE c VALUE 'T',
            c_reps(4) TYPE c VALUE 'REPS',
            c_intf(4) TYPE c VALUE 'INTF',
            c_func(4) TYPE c VALUE 'FUNC',
            c_clas(4) TYPE c VALUE 'CLAS',
            c_a TYPE c VALUE 'A',
            c_s TYPE c VALUE 'S'.

CONSTANTS:
     c_obj_typ_prg  TYPE euobj-id VALUE 'PROG',
     c_true         TYPE c VALUE 'X',
     con_separator  TYPE c VALUE '\|',
     c_num(10)      TYPE c VALUE '0123456789',
     c_user_exit(4) TYPE c VALUE 'SMOD',
     c_enh_spot(4)  TYPE c VALUE 'ENHS',
     c_badi_def(4)  TYPE c VALUE 'SXSD'.

\*&---------------------------------------------------------------------\*
\*& Types
\*&---------------------------------------------------------------------\*
TYPES:  BEGIN OF ty_result,
         obj_type       TYPE enhobj-obj_type,
         obj_name       TYPE enhobj-obj_name,
         enhspot        TYPE enhspotobj-enhspot,
         enhname        TYPE enhobj-enhname,
         switch_id TYPE sfw_switch_id,
         state     TYPE  sfw_switchpos,
       END OF ty_result.

TYPES:  BEGIN OF ty_enhnames,
          enhname      TYPE sobj_name,
          main_name    TYPE enhobj-main_name,
       END OF ty_enhnames.

TYPES:  BEGIN OF ty_enhnames_enho,
          enhname      TYPE enhname,
          obj_name     TYPE trobj_name,
          main_type    TYPE trobjtype,
       END OF ty_enhnames_enho.

TYPES:  BEGIN OF ty_es_head_it,
          enhspot       TYPE enhobj-main_name,
       END OF ty_es_head_it.

\**-\- Include program names
TYPES: BEGIN OF ty_includes,
         prog TYPE trobj_name,
       END OF ty_includes.

\**-\- Program ty_content for text download
TYPES: BEGIN OF ty_content,
        line(255) TYPE c,
      END OF ty_content.

\**--  Types for enhancement spots
TYPES: BEGIN OF ty_enhspotobj,
         enhspot   TYPE enhspotname,
         version   TYPE r3state,
         obj_type  TYPE trobjtype,
         obj_name  TYPE trobj_name,
         main_type TYPE trobjtype,
         main_name TYPE eu_aname,
       END OF ty_enhspotobj.

\**--Types for enhancement objects
TYPES: BEGIN OF ty_enho_obj,
         obj_name TYPE trobjtype,
         devclass TYPE devclass,
       END OF ty_enho_obj.

\**--Types for switch
TYPES: BEGIN OF ty_switch,
         switch_id TYPE sfw_switch_id,
         devclass  TYPE packname,
       END OF ty_switch.

\**--Types for switch state
TYPES: BEGIN OF ty_switch_state,
         switch_id TYPE sfw_switch_id,
         state     TYPE  sfw_switchpos,
       END OF ty_switch_state.

\*&---------------------------------------------------------------------\*
\*& Internal Tables
\*&---------------------------------------------------------------------\*
DATA:   t_bdcdata        TYPE STANDARD TABLE OF bdcdata,
        t_eso_it        TYPE STANDARD TABLE OF enhspotobj,
        t_eso_it_1      TYPE STANDARD TABLE OF enhspotobj,
        t_result        TYPE STANDARD TABLE OF ty_result,
        t_final         TYPE STANDARD TABLE OF ty_result,
        t_enhnames      TYPE STANDARD TABLE OF ty_enhnames,
        t_enhnames_enho TYPE STANDARD TABLE OF ty_enhnames_enho,
        t_es_head_it    TYPE STANDARD TABLE OF ty_es_head_it,
        t_itab          TYPE STANDARD TABLE OF tadir,
        t_itab_enho     TYPE STANDARD TABLE OF tadir,
        t_messtab       TYPE STANDARD TABLE OF bdcmsgcoll.  "#EC *

\*&---------------------------------------------------------------------\*
\*& Work Areas
\*&---------------------------------------------------------------------\*
DATA :  wa_bdcdata       TYPE bdcdata,
        wa_result        TYPE ty_result,
        wa_final         TYPE ty_result,
        wa_enhnames      TYPE ty_enhnames,
        wa_enhnames_enho TYPE ty_enhnames_enho,
        wa_jtab_enho     TYPE tadir,
        wa_eso_it        LIKE LINE OF t_eso_it,
        wa_tstc          TYPE tstc,
        wa_tstct         TYPE tstct,
        wa_tlibg         TYPE tlibg,
        wa_tlibt         TYPE tlibt,
        wa_tdevc         TYPE tdevc,
        wa_tadir         TYPE tadir,
        wa_trdir         TYPE trdir,
        wa_tfdir         TYPE tfdir,
        wa_enlfdir       TYPE enlfdir,
        wa_modsapt       TYPE modsapt,
        wa_sxs_attrt     TYPE sxs_attrt,
        wa_messages       TYPE bdcmsgcoll.

\*&---------------------------------------------------------------------\*
\*& Variables
\*&---------------------------------------------------------------------\*
DATA : v_enhname       TYPE enhobj-enhname,
       v_fld           TYPE enhname,
\*"A: show all dynpros "E: show dynpro on error only N:
"do not display dynpro
       v_ctumode TYPE ctu_params-dismode VALUE c_e,
\*"S: synchronously \*"A: asynchronously \*"L: local
       v_cupdate TYPE ctu_params-updmode VALUE c_l.

\**-\- Names of function modules used within programmes
DATA: t_prog_includes TYPE STANDARD TABLE OF  ty_includes,
      wa_prog_includes TYPE ty_includes.

\**-\- Internal table for enhancement spots
DATA: t_enhspotobj TYPE STANDARD TABLE OF  ty_enhspotobj,
      wa_enhspotobj    TYPE ty_enhspotobj,
\**-\- Development classes for implimentation
      t_enho_obj TYPE STANDARD TABLE OF  ty_enho_obj,
      wa_enho_obj TYPE ty_enho_obj,
\**--  Switch
      t_switch   TYPE STANDARD TABLE OF ty_switch,
      wa_switch   TYPE ty_switch,
\**-\- Switch state
      t_switch_state TYPE STANDARD TABLE OF ty_switch_state,
      wa_switch_state TYPE ty_switch_state.

TYPES: BEGIN OF l_trace_result,
        one  TYPE string,
        two  TYPE string,
        obj_name  TYPE string, "needed
        four TYPE string,
        five TYPE string,
        six TYPE string,
        seven TYPE string,
        statement TYPE string, "needed
        nine TYPE string,
\*        ten TYPE string,
END OF l_trace_result.

TYPES: BEGIN OF li_file,
        string TYPE string,
END OF li_file.

TYPES: BEGIN OF l_obj_stat,
        obj_name  TYPE string,
        statement  TYPE string,
  END OF l_obj_stat.

TYPES: BEGIN OF l_obj_exit,
        statement  TYPE string,
  END OF l_obj_exit.

TYPES: BEGIN OF l_tadir,
        object    TYPE trobjtype,
        obj_name  TYPE sobj_name,
  END OF l_tadir.

DATA:
\* Work areas
    lwa_trdir         TYPE trdir,
    lw_bdcdata        TYPE bdcdata,
    l_wa_file         TYPE li_file,
    l_wa_trace_result TYPE l_trace_result,
    l_wa_badi_obj     TYPE l_obj_exit,
    l_wa_exit_obj     TYPE l_obj_exit,
    l_wa_final        TYPE l_obj_stat,
    l_wa_tadir        TYPE l_tadir,

\* Internal Tables
    li_bdcdata          TYPE STANDARD TABLE OF bdcdata,
    li_bdcdata_dis      TYPE STANDARD TABLE OF bdcdata,
    li_bdcdata_off      TYPE STANDARD TABLE OF bdcdata,
    li_bdcdata_on       TYPE STANDARD TABLE OF bdcdata,
    l_tab_file          TYPE TABLE OF li_file,
    l_tab_trace_result  TYPE TABLE OF l_trace_result,
    l_tab_badi_obj      TYPE TABLE OF l_obj_exit,
    l_tab_badi_obj_temp TYPE TABLE OF l_obj_exit,
    l_tab_exit_obj      TYPE TABLE OF l_obj_exit,
    l_tab_exit_obj_temp TYPE TABLE OF l_obj_exit,
    l_tab_final         TYPE TABLE OF l_obj_stat,
    i_messages          TYPE TABLE OF bdcmsgcoll,
    l_tab_tadir         TYPE TABLE OF l_tadir,

\* Variables
    lv_program(40)   TYPE c,
    lv_time_start(8) TYPE c,
    lv_time_end(8)   TYPE c,
    lv_filename      TYPE string,
    lv_path          TYPE string,
    lv_fullpath      TYPE string,
    lv_lenght        TYPE i,
    lv_offset        TYPE i,
    lv_offset_end    TYPE i,
    d_mode           TYPE c VALUE 'N',
    lv_badi_obj      TYPE string,
    lv_exit_obj      TYPE string,
    lv_find          TYPE c VALUE ' ',
    lv_object2(30)   TYPE c,
    lv_txt(60)       TYPE c,
    lv_file          TYPE c VALUE ' ',
    lv_tfdir_funcname TYPE rs38l_fnam.

\*&---------------------------------------------------------------------\*
\*& Field Symbols
\*&---------------------------------------------------------------------\*

FIELD-SYMBOLS : %LTfs_eso%GT TYPE enhspotobj,
                %LTfs_enhspotobj%GT TYPE ty_enhspotobj.

\*&---------------------------------------------------------------------\*
\*& Selection Screen
\*&---------------------------------------------------------------------\*
\* FIRST TAB
\* SELECTION SCREEN to search user-exits that have been called
\* in a process executed by user

SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK 001 WITH FRAME TITLE text-036.
PARAMETERS: p_tcode TYPE tstc-tcode,
            p_progra TYPE programm.

SELECTION-SCREEN END OF BLOCK 001.

SELECTION-SCREEN END OF SCREEN 100.

\* SECOND TAB
\* SELECTION SCREEN to search user-exits in Packages
\* or in the same Development Class of a Program or Transaction

SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-036.
SELECTION-SCREEN INCLUDE PARAMETERS: p_tcode.
PARAMETERS: p_dev TYPE devclass ,
            p_fun TYPE tlibg-area.

PARAMETERS: p_exit RADIOBUTTON GROUP g1 USER-COMMAND u1,
             p_espot RADIOBUTTON GROUP g1.

SELECTION-SCREEN BEGIN OF LINE .

SELECTION-SCREEN POSITION 5.
PARAMETERS: p_prog RADIOBUTTON GROUP g2 MODIF ID sc1.
SELECTION-SCREEN COMMENT 8(20) text-001 FOR FIELD p_prog MODIF ID sc1.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE .

SELECTION-SCREEN POSITION 5.
PARAMETERS :  p_devl RADIOBUTTON GROUP g2 MODIF ID sc1.
SELECTION-SCREEN COMMENT 8(30) text-002 FOR FIELD p_devl MODIF ID sc1.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN END OF SCREEN 200.

\* TABS DEFINITION: To search by Package or by process
SELECTION-SCREEN: BEGIN OF TABBED BLOCK sub FOR 25 LINES,
                    TAB (20) button1 USER-COMMAND push1,
                    TAB (20) button2 USER-COMMAND push2,
                  END OF BLOCK sub.

\*---------------------------------------------------------------------\*
\* INITIALIZATION                                                      *
\*---------------------------------------------------------------------\*
INITIALIZATION.

  sub-prog = sy-repid.
\* Find user-exits & enhacement in a process as initial screen
  sub-dynnr = 100.
\* Set title for Search in a Process or in a Package
  IF sy-dynnr EQ 1000.
\*   Set tab names
    button1 = text-037.         "In Process
    button2 = text-038.         "In Package
\*   Set button to Search exits in a Process
    IF sub-dynnr EQ 100.
      sub-activetab = 'PUSH1'.
\*   Set button to Search exits in a Package
    ELSEIF sub-dynnr EQ 200.
      sub-activetab = 'PUSH2'.
    ENDIF.
  ENDIF.

AT SELECTION-SCREEN.

  CASE sy-ucomm.
    WHEN 'PUSH1'.
      CLEAR: p_tcode,
             p_progra.

      sub-dynnr = 100.
    WHEN 'PUSH2'.
      CLEAR: p_tcode,
             p_dev,
             p_fun.
      sub-dynnr = 200.
    WHEN OTHERS.
      IF sub-dynnr EQ 100.
        PERFORM  f_param_check_100.

      ELSEIF sub-dynnr EQ 200.
        PERFORM f_param_check_200.

      ENDIF.
  ENDCASE.

\**********************************************************************\*
\* AT SELECTION-SCREEN  VALUE-REQUEST                                  *
\**********************************************************************\*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_progra.

\* Value request for the name of program
  CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
    EXPORTING
      object_type          = c_obj_typ_prg
      object_name          = p_progra
      suppress_selection   = c_x
    IMPORTING
      object_name_selected = p_progra
    EXCEPTIONS
      cancel               = 1.

  IF sy-subrc NE 0.
    CLEAR p_prog.
  ENDIF.

\**-\-
AT SELECTION-SCREEN OUTPUT.
\**-\-
  IF sub-dynnr = 200.
    LOOP AT SCREEN.
      IF p_espot = c_x.
        IF screen-group1 = 'SC1'.
          screen-input = '1'.
          MODIFY SCREEN.
        ENDIF.
      ELSE.
        IF screen-group1 = 'SC1'.
          screen-input = '0'.
          MODIFY SCREEN.
        ENDIF.
      ENDIF.
    ENDLOOP.
  ENDIF.

START-OF-SELECTION.

  CASE sub-dynnr.
\* When PROCESS TAB is active
    WHEN 100.
      PERFORM f_run_badi_in_process.

\* When PACKAGE TAB is active
    WHEN 200.
      PERFORM f_run_badi_in_package.

    WHEN OTHERS.
\*     Do nothing
  ENDCASE.

\*--------------------------------------------------------------------\-
\* AT LINE-SELECTION
\*--------------------------------------------------------------------\-
\**-\- Take the user to SE19 for the Enhancement that was selected.

AT LINE-SELECTION.
  CASE sub-dynnr.
\* When PROCESS TAB is active
    WHEN 100.
\* Navegation
      PERFORM f_line_selection_online.

\* When PACKAGE TAB is active
    WHEN 200.
      PERFORM f_line_selection_package.

    WHEN OTHERS.
\*     Do nothing
  ENDCASE.

\*--------------------------------------------------------------------\-
\* END-OF-SELECTION
\*--------------------------------------------------------------------\-
END-OF-SELECTION.
  REFRESH: t_result,
           t_final,
           t_enhnames,
           t_es_head_it,
           t_itab,
           t_bdcdata,
           t_messtab.

  FREE: t_result,
        t_final,
        t_enhnames,
        t_es_head_it,
        t_itab,
        t_bdcdata,
        t_messtab.
\**-\-
\*&---------------------------------------------------------------------\*
\*&      Form  f_fuehtiwedoctroegakcap
\*&---------------------------------------------------------------------\*
\*     Validate T.Code and find SAP modifications
\*----------------------------------------------------------------------\*
FORM f_fuehtiwedoctroegakcap.

\**--If no T.Code is selected.
  IF NOT p_tcode IS INITIAL.
\**-\- Validate Transaction Code
    SELECT SINGLE * FROM tstc INTO wa_tstc
     WHERE tcode EQ p_tcode.
\**-\- Find Repository Objects for transaction code
    IF sy-subrc EQ 0.
      SELECT SINGLE devclass  FROM tadir INTO wa_tadir-devclass
       WHERE pgmid = c_pgmid_r3tr
         AND object = c_obj_prog
         AND obj_name = wa_tstc-pgmna.

      IF sy-subrc NE 0.
        SELECT SINGLE devclass FROM tadir INTO wa_tadir-devclass
         WHERE pgmid  = c_pgmid_r3tr
           AND object = c_tran
           AND obj_name = p_tcode.
      ENDIF.
      v_devclass = wa_tadir-devclass.

      IF sy-subrc NE 0.
        SELECT SINGLE * FROM trdir INTO wa_trdir
         WHERE name = wa_tstc-pgmna.
        IF sy-subrc = 0.
          IF wa_trdir-subc EQ c_f.
            SELECT SINGLE * FROM tfdir INTO wa_tfdir
             WHERE pname = wa_tstc-pgmna.                   "#EC *
            IF sy-subrc = 0.
              SELECT SINGLE * FROM enlfdir INTO wa_enlfdir
               WHERE funcname = wa_tfdir-funcname.
              IF sy-subrc = 0.
                SELECT SINGLE devclass FROM tadir INTO wa_tadir-devclass
                 WHERE pgmid = c_pgmid_r3tr
                   AND object = c_fugr
                   AND obj_name = wa_enlfdir-area.
                v_devclass = wa_tadir-devclass.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
    ELSE.
      FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
      WRITE:/(105) text-006.
    ENDIF.
  ELSEIF NOT p_dev IS INITIAL.

    v_devclass = p_dev.

  ELSEIF NOT p_fun IS INITIAL.

    SELECT SINGLE devclass FROM tadir INTO wa_tadir-devclass
    WHERE pgmid = c_pgmid_r3tr
      AND object = c_fugr
      AND obj_name = p_fun.
    IF sy-subrc = 0.

      v_devclass = wa_tadir-devclass.
    ENDIF.
  ENDIF.

\* Find SAP Modifactions
  SELECT * FROM tadir
    INTO TABLE t_jtab
   WHERE pgmid = c_pgmid_r3tr
     AND object IN (c_smod,c_sxsd)
     AND devclass = v_devclass.
  IF sy-subrc = 0.

    SELECT SINGLE * FROM tstct INTO wa_tstct
     WHERE sprsl EQ sy-langu
       AND tcode EQ p_tcode.
    IF sy-subrc = 0.

      FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
      IF NOT p_tcode IS INITIAL.
        WRITE:/(19) text-007,
              20(20) p_tcode,
              45(50) wa_tstct-ttext.
      ELSEIF NOT p_dev IS INITIAL.
        WRITE:/(19) text-012,
              20(20) p_dev.
      ELSEIF NOT p_fun IS INITIAL.
        WRITE:/(15) text-023,
              20(20) p_fun,
              45(50) wa_tlibt-areat.
      ENDIF.
    ENDIF.
  ENDIF.
  SKIP.

  IF NOT t_jtab\[\] IS INITIAL.
    WRITE:/(105) sy-uline.
    FORMAT COLOR COL_HEADING INTENSIFIED ON.
    WRITE:/1 sy-vline,
           2 text-008,
           41 sy-vline,
           42 text-009,
           105 sy-vline.
    WRITE:/(105) sy-uline.

    SORT t_jtab BY obj_name.
    LOOP AT t_jtab INTO wa_jtab.
      AT NEW object.
        IF wa_jtab-object = c_smod.
          FORMAT COLOR COL_GROUP INTENSIFIED ON.
          WRITE:/1 sy-vline,
              2 text-024,
             105 sy-vline.
        ELSEIF wa_jtab-object = c_sxsd.
          FORMAT COLOR COL_GROUP INTENSIFIED ON.
          WRITE:/1 sy-vline,
              2  text-025,
             105 sy-vline.
        ENDIF.
      ENDAT.

      CASE wa_jtab-object.
        WHEN c_smod.
          v_smod = v_smod + 1.

          SELECT SINGLE * FROM modsapt INTO wa_modsapt
           WHERE sprsl = sy-langu
             AND name = wa_jtab-obj_name.

          IF sy-subrc = 0.

            FORMAT COLOR COL_NORMAL INTENSIFIED ON.

            WRITE:/1 sy-vline,
                   2 wa_jtab-obj_name HOTSPOT ON,
                  41 sy-vline ,
                  42 wa_modsapt-modtext,
                  105 sy-vline.

          ENDIF.
        WHEN c_sxsd.
          v_badi = v_badi + 1 .
          SELECT SINGLE * FROM sxs_attrt INTO wa_sxs_attrt
                            WHERE sprsl     = sy-langu
                              AND exit_name = wa_jtab-obj_name.
          IF sy-subrc = 0.
            FORMAT COLOR COL_NORMAL INTENSIFIED ON.

            WRITE:/1 sy-vline,
                   2 wa_jtab-obj_name HOTSPOT ON,
                  41 sy-vline ,
                  42 wa_sxs_attrt-text,
                  105 sy-vline.
          ENDIF.
      ENDCASE.

      AT END OF object.
        WRITE : /(105) sy-uline.
      ENDAT.

      CLEAR : wa_jtab,wa_sxs_attrt.

    ENDLOOP.
    WRITE:/(105) sy-uline.
    DESCRIBE TABLE t_jtab.
    SKIP.

    FORMAT COLOR COL_TOTAL INTENSIFIED ON.
    WRITE:/ text-010,  v_smod.
    WRITE:/  text-019, v_badi.
  ELSE.
    FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
    WRITE:/(95) text-011.
  ENDIF.

ENDFORM.                    " f_fuehtiwedoctroegakcap
\*&---------------------------------------------------------------------\*
\*&      Form  ftnemecnahenybmargorpeman
\*&---------------------------------------------------------------------\*
\*       Get the Enhancement spot Details
\*----------------------------------------------------------------------\*

FORM ftnemecnahenybmargorpeman .

  IF NOT p_tcode IS INITIAL.

    SELECT SINGLE * FROM tstc INTO wa_tstc
     WHERE tcode EQ p_tcode.

  ELSEIF p_fun IS NOT INITIAL.
\**--If no function group is selected.
    SELECT SINGLE * FROM enlfdir INTO wa_enlfdir
       WHERE area = p_fun.                                  "#EC *
    IF sy-subrc = 0.
      SELECT SINGLE * FROM tfdir INTO wa_tfdir
       WHERE funcname = wa_enlfdir-funcname.
      IF sy-subrc = 0.
\**-\- move the value to tstc-PGMNA
        wa_tstc-pgmna = wa_tfdir-pname.
      ENDIF.
    ENDIF.
  ENDIF.

  IF sy-subrc EQ 0.

    IF NOT wa_tstc-pgmna IS INITIAL.
\**-\- Select the include programs which are there in the main program
      PERFORM f_find_include_programs USING wa_tstc-pgmna.
\**-\- Append the main program also into internal table t_prog_includes
      wa_prog_includes-prog = wa_tstc-pgmna.
      APPEND wa_prog_includes TO t_prog_includes.
      IF NOT t_prog_includes\[\] IS INITIAL.
\**-\- Select the enhancement spot's data from ENHSPOTOBJ
\**-\- All the includes in itab t_prog_includes
        SELECT enhspot
               version
               obj_type
               obj_name
               main_type
               main_name
          INTO TABLE t_enhspotobj
          FROM enhspotobj
          FOR ALL ENTRIES IN t_prog_includes
          WHERE obj_name = t_prog_includes-prog AND
                version  = c_a.

        IF sy-subrc = 0.
          IF NOT t_enhspotobj\[\] IS INITIAL.

            SELECT SINGLE * FROM tstct INTO wa_tstct
             WHERE sprsl EQ sy-langu
               AND tcode EQ p_tcode.

            FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
\**-\- Transaction Code
            IF p_fun IS INITIAL.
              WRITE:/1 text-013,
                     25(20) p_tcode,
                     48(50) wa_tstct-ttext.
            ELSE.
              WRITE:/1 text-022,
                     35(20) p_fun,
                     55(50) wa_tlibt-areat.
            ENDIF.
          ENDIF.
          SKIP.

\**-\- Genral information.
          FORMAT COLOR COL_HEADING INTENSIFIED ON.
          WRITE:/ text-026, text-020.

          WRITE:/(150) sy-uline.
          FORMAT COLOR COL_HEADING INTENSIFIED ON.
          WRITE:/1 sy-vline,
                 2 text-015,
                34 sy-vline,
                36 text-016,
                64 sy-vline,
                66 text-014,
                100 sy-vline,
               101 text-027,
               132 sy-vline,
               133 text-028,
               150 sy-vline.

          WRITE:/(150) sy-uline.
        ELSE.

          WRITE: / text-017.
        ENDIF.
      ENDIF.
    ELSE.
      WRITE: / text-017  .
    ENDIF.
  ELSE.
    FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
    WRITE:/(95) text-004.
  ENDIF.

\**--If enhancement spot table is initial
  IF NOT t_enhspotobj\[\] IS INITIAL.

    LOOP AT t_enhspotobj ASSIGNING %LTfs_enhspotobj%GT.
      wa_result-enhspot = %LTfs_enhspotobj%GT-enhspot.
      APPEND wa_result TO t_result.
      CLEAR wa_result.
    ENDLOOP.

    IF NOT t_result\[\] IS INITIAL.

      DELETE ADJACENT DUPLICATES FROM t_result.

      SORT t_enhspotobj BY enhspot.

      LOOP AT t_result INTO wa_result.

        READ TABLE t_enhspotobj INTO wa_enhspotobj WITH KEY enhspot =
wa_result-enhspot
                                     BINARY SEARCH.
        IF sy-subrc = 0.
          wa_result-obj_name = wa_enhspotobj-obj_name.
          wa_result-obj_type = wa_enhspotobj-main_type. " obj_type.
        ENDIF.
        MODIFY t_result FROM wa_result.
        CLEAR wa_result.
      ENDLOOP.

\**--Get the enhancement spot
      IF NOT t_result\[\] IS INITIAL.
        SELECT enhspot
          INTO TABLE t_es_head_it
          FROM enhspotheader
           FOR ALL ENTRIES IN t_result
         WHERE enhspot = t_result-enhspot
           AND   version = c_a.
        IF sy-subrc = 0.
          IF NOT t_es_head_it\[\] IS INITIAL.
\**-\- Get the enhancement id data from ENHOBJ
            SELECT enhname
                   main_name
              APPENDING TABLE t_enhnames
              FROM enhobj
               FOR ALL ENTRIES IN t_es_head_it
             WHERE main_type = c_enhs
               AND main_name = t_es_head_it-enhspot.
            IF sy-subrc = 0.
              SORT t_enhnames BY main_name.
              DELETE ADJACENT DUPLICATES FROM t_enhnames COMPARING
enhname main_name.
\**-\- Get the development calss for the enhacement spots & implimentation
              IF NOT t_enhnames\[\] IS INITIAL.
                SELECT obj_name
                       devclass
                  INTO TABLE t_enho_obj
                  FROM tadir
                  FOR ALL ENTRIES IN t_enhnames
                  WHERE obj_name = t_enhnames-enhname AND
                        object   = c_enho.
                IF sy-subrc = 0.
                  IF NOT t_enho_obj\[\] IS INITIAL.
\**-\- Get the switch details
                    SELECT switch_id
                           devclass
                      INTO TABLE  t_switch
                      FROM sfw_package
                      FOR ALL ENTRIES IN t_enho_obj
                      WHERE devclass = t_enho_obj-devclass.
                    IF sy-subrc = 0.
                      IF NOT t_switch IS INITIAL.
\**-\- Get the switch status
                        SELECT switch_id
                               state
                          INTO TABLE  t_switch_state
                          FROM sfw_switch_state
                          FOR ALL ENTRIES IN t_switch
                          WHERE  switch_id = t_switch-switch_id.
                      ENDIF.
                    ENDIF.
                  ENDIF.
                ENDIF.
              ENDIF.
            ENDIF.
            LOOP AT t_result INTO wa_result.
              wa_final-obj_type  = wa_result-obj_type.
              wa_final-obj_name  = wa_result-obj_name.
              wa_final-enhspot   = wa_result-enhspot.
              LOOP AT t_enhnames INTO wa_enhnames WHERE main_name =
wa_result-enhspot.
\**-\- Populate the switch
                READ TABLE t_enho_obj INTO wa_enho_obj WITH KEY obj_name
 = wa_enhnames-enhname."#EC *
                IF sy-subrc = 0.
                  READ TABLE t_switch INTO wa_switch WITH KEY devclass =
 wa_enho_obj-devclass.
                  IF sy-subrc = 0.
                    READ TABLE t_switch_state INTO wa_switch_state WITH
KEY switch_id = wa_switch-switch_id.
                    IF sy-subrc = 0.
                      wa_final-switch_id = wa_switch_state-switch_id.
                      wa_final-state     = wa_switch_state-state.
                    ENDIF.
                  ENDIF.
                ENDIF.

                wa_final-enhname  =  wa_enhnames-enhname.
                APPEND wa_final TO t_final.
              ENDLOOP.
              CLEAR wa_final.
            ENDLOOP.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.

    LOOP AT t_final INTO wa_final.
      FORMAT COLOR COL_NORMAL INTENSIFIED ON.
      WRITE: /1 sy-vline,
              2 wa_final-enhspot HOTSPOT ON,
              34 sy-vline.

      CASE  wa_final-obj_type.
        WHEN c_reps OR c_obj_prog.
          WRITE:  36 text-029.
        WHEN c_intf OR c_sxsd.
          WRITE:  36 text-030.
        WHEN c_func OR c_fugr .
          WRITE:  36 text-031.
        WHEN c_clas.
          WRITE:  36 text-032.
        WHEN OTHERS.
          WRITE:  36 wa_final-obj_type.
      ENDCASE.

      WRITE:  64 sy-vline,
              66 wa_final-enhname HOTSPOT ON,
             100 sy-vline,
             101 wa_final-switch_id,
             132 sy-vline.

      CASE wa_final-state.
        WHEN c_t.
          WRITE 133 text-033.
        WHEN c_s.
          WRITE 133 text-034.
        WHEN c_f.
          WRITE 133 text-035.
      ENDCASE.

      WRITE: 150 sy-vline.
      CLEAR : wa_final.

    ENDLOOP.
    WRITE:/(150) sy-uline.

  ENDIF.

ENDFORM.                    " ftnemecnahenybmargorpeman
\*&---------------------------------------------------------------------\*
\*&      Form  f_FIND_INCLUDE_PROGRAMS
\*&---------------------------------------------------------------------\*
\*       Desc: Get the include names into internal table
\*----------------------------------------------------------------------\*
FORM f_find_include_programs  USING    ip_tstc_pgmna TYPE any.

  DATA: l_fip_prog(255),
        l_tail(255).                                        "#EC *

\*--\- Lines for include
  DATA: lt_inc_lines  TYPE STANDARD TABLE OF ty_content,
        lwa_inc_lines TYPE ty_content.

\**-\- Read ABAP
  READ REPORT ip_tstc_pgmna INTO lt_inc_lines.

\**-\- Examine each line of ABAP
  LOOP AT lt_inc_lines INTO lwa_inc_lines.
\**-\- find include programs.
    IF lwa_inc_lines(1) = '*' OR lwa_inc_lines IS INITIAL.
      CONTINUE.
    ENDIF.

    TRANSLATE lwa_inc_lines-line TO UPPER CASE.
    SHIFT lwa_inc_lines-line UP TO c_incld.

    IF ( lwa_inc_lines-line(7) EQ c_incld ) OR
       ( lwa_inc_lines-line(7) EQ c_incld )
    AND lwa_inc_lines-line+8(9) NE space
    AND sy-tabix %LT%GT 1.
      l_fip_prog = lwa_inc_lines-line+8(64).
      SPLIT l_fip_prog AT '.' INTO l_fip_prog l_tail.
\**-       Append program name to list of include programs
      SELECT SINGLE * FROM trdir INTO wa_trdir WHERE name EQ l_fip_prog.
      CHECK sy-subrc EQ 0.
      wa_prog_includes-prog = l_fip_prog.
      APPEND wa_prog_includes TO t_prog_includes.
\*--\- Recursively look for other includes.
      PERFORM f_find_include_programs USING l_fip_prog.
    ENDIF.
    CLEAR wa_prog_includes.
  ENDLOOP.

ENDFORM.                    " f_FIND_INCLUDE_PROGRAMS
\*&---------------------------------------------------------------------\*
\*&      Form  ftnemecnahenyegakcapeman
\*&---------------------------------------------------------------------\*
\*      Get enhacement spots & implementation details and switch details
\*----------------------------------------------------------------------\*

FORM ftnemecnahenyegakcapeman .

  IF NOT p_tcode IS INITIAL.

    SELECT SINGLE * FROM tstc INTO wa_tstc
     WHERE tcode EQ p_tcode.
    IF sy-subrc EQ 0.
      SELECT SINGLE devclass FROM tadir INTO wa_tadir-devclass
       WHERE pgmid = c_pgmid_r3tr
         AND object = c_obj_prog
         AND obj_name = wa_tstc-pgmna.

      v_devclass = wa_tadir-devclass.
      IF sy-subrc NE 0.
        SELECT SINGLE * FROM trdir INTO wa_trdir
         WHERE name = wa_tstc-pgmna.

        IF wa_trdir-subc EQ c_f.

          SELECT SINGLE * FROM tfdir INTO wa_tfdir
           WHERE pname = wa_tstc-pgmna.                     "#EC *

          SELECT SINGLE * FROM enlfdir INTO wa_enlfdir
           WHERE funcname = wa_tfdir-funcname.

          SELECT SINGLE devclass FROM tadir INTO wa_tadir-devclass
           WHERE pgmid = c_pgmid_r3tr
             AND object = c_fugr
             AND obj_name EQ wa_enlfdir-area.

          v_devclass = wa_tadir-devclass.
        ENDIF.
      ENDIF.
    ELSE.
      FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
      WRITE:/(95) text-006.
    ENDIF.
\**-\- Get the required fields from the repository
    PERFORM get_from_tadir.

  ELSEIF NOT p_dev IS INITIAL.
\**--Assign the development package to the development class of
"repository.
    v_devclass = p_dev.
    PERFORM get_from_tadir.

  ELSEIF NOT p_fun IS INITIAL.

    SELECT SINGLE devclass FROM tadir INTO wa_tadir-devclass
    WHERE pgmid = c_pgmid_r3tr
      AND object = c_fugr
      AND obj_name = p_fun.
    v_devclass = wa_tadir-devclass.

\**--Get the required fields from the repository
    PERFORM get_from_tadir.
  ENDIF.

  LOOP AT t_eso_it ASSIGNING %LTfs_eso%GT.
    wa_result-enhspot = %LTfs_eso%GT-enhspot.
    APPEND wa_result TO t_result.
    CLEAR wa_result.
  ENDLOOP.

  IF NOT t_result\[\] IS INITIAL.
    DELETE ADJACENT DUPLICATES FROM t_result.

    SORT t_itab BY obj_name.
    LOOP AT t_result INTO wa_result.
      READ TABLE t_itab  INTO wa_jtab WITH KEY obj_name  =
wa_result-enhspot
                                   BINARY SEARCH.
      IF sy-subrc = 0.
        wa_result-obj_name  =  wa_jtab-obj_name.
        READ TABLE t_eso_it INTO wa_eso_it WITH KEY enhspot =
wa_jtab-obj_name+0(30)
                                     BINARY SEARCH.
        IF sy-subrc = 0.
          wa_result-obj_type = wa_eso_it-obj_type.
        ENDIF.
        MODIFY t_result FROM wa_result.
      ENDIF.
      CLEAR wa_result.
    ENDLOOP.

    IF NOT t_result\[\] IS INITIAL.
      SELECT enhspot
        INTO TABLE t_es_head_it
        FROM enhspotheader
         FOR ALL ENTRIES IN t_result
       WHERE enhspot = t_result-enhspot
         AND   version = c_a.

      IF sy-subrc = 0.
        IF NOT t_es_head_it\[\] IS INITIAL.
          SELECT enhname
                 main_name
            APPENDING TABLE t_enhnames
            FROM enhobj
             FOR ALL ENTRIES IN t_es_head_it
           WHERE main_type = c_enhs
             AND main_name = t_es_head_it-enhspot.
          IF sy-subrc = 0.
            SORT t_enhnames BY main_name.
            DELETE ADJACENT DUPLICATES FROM t_enhnames COMPARING enhname
 main_name.
\**-\- Get the development calss for the enhacement spots & implementation
            SELECT obj_name
                   devclass
              INTO TABLE t_enho_obj
              FROM tadir
              FOR ALL ENTRIES IN t_enhnames
              WHERE obj_name = t_enhnames-enhname AND
                    object   = c_enho.
            IF sy-subrc = 0.
\**-\- Get the switch details
              SELECT switch_id
                     devclass
                INTO TABLE  t_switch
                FROM sfw_package
                FOR ALL ENTRIES IN t_enho_obj
                WHERE devclass = t_enho_obj-devclass.
              IF sy-subrc = 0.
\**-\- Get the switch status
                SELECT switch_id
                       state
                  INTO TABLE  t_switch_state
                  FROM sfw_switch_state
                  FOR ALL ENTRIES IN t_switch
                  WHERE  switch_id = t_switch-switch_id.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.

        LOOP AT t_result INTO wa_result.
          wa_final-obj_type  = wa_result-obj_type.
          wa_final-obj_name  = wa_result-obj_name.
          wa_final-enhspot   = wa_result-enhspot.
          LOOP AT t_enhnames INTO wa_enhnames WHERE main_name =
wa_result-enhspot.
\**-\- Populate the switch
            READ TABLE t_enho_obj INTO wa_enho_obj WITH KEY obj_name =
wa_enhnames-enhname."#EC *
            IF sy-subrc = 0.
              READ TABLE t_switch INTO wa_switch WITH KEY devclass =
wa_enho_obj-devclass.
              IF sy-subrc = 0.
                READ TABLE t_switch_state INTO wa_switch_state WITH KEY
switch_id = wa_switch-switch_id.
                IF sy-subrc = 0.
                  wa_final-switch_id = wa_switch_state-switch_id.
                  wa_final-state     = wa_switch_state-state.
                ENDIF.
              ENDIF.
            ENDIF.

            wa_final-enhname  =  wa_enhnames-enhname.
            APPEND wa_final TO t_final.
            CLEAR wa_final.
          ENDLOOP.
          IF sy-subrc %LT%GT 0.
            APPEND wa_final TO t_final.
          ENDIF.
          CLEAR wa_final.
        ENDLOOP.
      ENDIF.
    ENDIF.
\**-\- Also consider the Enhancement implementation which are not part of
" enhancement spot's
    LOOP AT t_itab INTO wa_jtab WHERE object = c_enho.
      wa_jtab_enho = wa_jtab.
      APPEND wa_jtab_enho TO t_itab_enho.
      CLEAR wa_jtab_enho.
    ENDLOOP.

    IF NOT t_itab_enho\[\] IS INITIAL.
      SELECT enhname
             obj_name
             main_type
        INTO TABLE t_enhnames_enho
        FROM enhobj
         FOR ALL ENTRIES IN t_itab_enho
       WHERE enhname = t_itab_enho-obj_name+0(30) AND
             obj_type = c_enhs.
      IF sy-subrc = 0.
\**-\- Select the enhancement spot object
        IF NOT t_enhnames_enho\[\] IS INITIAL.
          SELECT *
            FROM enhspotobj
            INTO CORRESPONDING FIELDS OF TABLE t_eso_it_1
             FOR ALL ENTRIES IN t_enhnames_enho
           WHERE enhspot = t_enhnames_enho-obj_name+0(30).
          IF sy-subrc = 0.
            SORT t_eso_it_1 BY enhspot.
          ENDIF.
        ENDIF.

\**-\- Populate the final table
        DELETE ADJACENT DUPLICATES FROM t_enhnames_enho COMPARING
enhname.
        LOOP AT t_enhnames_enho INTO wa_enhnames_enho.
          READ TABLE t_final INTO wa_final WITH KEY enhname  =
wa_enhnames_enho-enhname.
          IF sy-subrc %LT%GT 0.
            CLEAR: wa_final.

            CLEAR: wa_eso_it.
            READ TABLE t_eso_it_1 INTO wa_eso_it WITH KEY
               enhspot = wa_enhnames_enho-obj_name+0(30)  BINARY SEARCH.
            IF sy-subrc = 0.
              wa_final-obj_type = wa_eso_it-obj_type.
            ENDIF.
            wa_final-enhspot  =  wa_enhnames_enho-obj_name.
            wa_final-enhname  =  wa_enhnames_enho-enhname.
            APPEND wa_final TO t_final.
          ENDIF.
          CLEAR wa_final.
        ENDLOOP.
      ENDIF.
    ENDIF.

    LOOP AT t_final INTO wa_final.

      FORMAT COLOR COL_NORMAL INTENSIFIED ON.
      WRITE: /1 sy-vline,
              2 wa_final-enhspot HOTSPOT ON,
              34 sy-vline.

      CASE  wa_final-obj_type.
        WHEN c_reps OR c_obj_prog.
          WRITE:  36 text-029.
        WHEN c_intf OR c_sxsd.
          WRITE:  36 text-030.
        WHEN c_func OR c_fugr.
          WRITE:  36 text-031.
        WHEN c_clas.
          WRITE:  36 text-032.

        WHEN OTHERS.
          WRITE:  36 wa_final-obj_type.
      ENDCASE.

      WRITE:  64 sy-vline,
              66 wa_final-enhname HOTSPOT ON,
             100 sy-vline,
              66 wa_final-enhname HOTSPOT ON,
             100 sy-vline,
             101 wa_final-switch_id,
             132 sy-vline.

      CASE wa_final-state.
        WHEN c_t.
          WRITE 133 text-033.
        WHEN c_s.
          WRITE 133 text-034.
        WHEN c_f.
          WRITE 133 text-035.
      ENDCASE.

      WRITE: 150 sy-vline.

    ENDLOOP.
    WRITE:/(150) sy-uline.
  ELSE.
    WRITE: / text-017 COLOR COL_BACKGROUND .
  ENDIF.\\

ENDFORM.                    " ftnemecnahenyegakcapeman
\*&---------------------------------------------------------------------\*
\*&      Form  get_from_tadir
\*&---------------------------------------------------------------------\*
\*      Get the required fields from the repository
\*----------------------------------------------------------------------\*

FORM get_from_tadir .

  SELECT * FROM tadir
    INTO TABLE t_itab
   WHERE pgmid = c_pgmid_r3tr
     AND object IN (c_enhs,c_enho)
     AND devclass = v_devclass.

  SELECT SINGLE * FROM tstct INTO wa_tstct
   WHERE sprsl EQ sy-langu
     AND tcode EQ p_tcode.

  FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
\* Transaction Code
  WRITE:/1 text-018.
  IF NOT p_tcode IS INITIAL.
    WRITE:         30(20) p_tcode.
    WRITE: 55(50) wa_tstct-ttext.
  ELSEIF NOT p_dev IS INITIAL.
    WRITE:         30(20) p_dev.
    WRITE: 55(50) wa_tstct-ttext.
  ELSEIF NOT p_fun IS INITIAL.
    WRITE:         30(20) p_fun.
    WRITE: 55(50)   wa_tlibt-areat.
  ENDIF.

  SKIP.
  IF NOT t_itab\[\] IS INITIAL.

\**-\- Genral information.
    FORMAT COLOR COL_HEADING INTENSIFIED ON.
    WRITE:/ text-026, text-020.

    WRITE:/(150) sy-uline.
    FORMAT COLOR COL_HEADING INTENSIFIED ON.
    WRITE:/1 sy-vline,
           2 text-015,
          34 sy-vline,
          36 text-016,
          64 sy-vline,
          66 text-014,
         100 sy-vline,
         101 text-027,
         132 sy-vline,
         133 text-028,
         150 sy-vline.

    WRITE:/(150) sy-uline.
    IF NOT t_itab\[\] IS INITIAL.

      SELECT *
       FROM enhspotobj
       INTO CORRESPONDING FIELDS OF TABLE t_eso_it
        FOR ALL ENTRIES IN t_itab
      WHERE enhspot = t_itab-obj_name+0(30).

      IF sy-subrc %LT%GT 0.
        WRITE: / text-017.
      ELSE.
        SORT t_eso_it BY enhspot.
      ENDIF.
    ENDIF.

  ENDIF.
ENDFORM.                    " get_from_tadir
\*----------------------------------------------------------------------\*
\*        Start new screen                                              *
\*----------------------------------------------------------------------\*
FORM fbdc_dynpro USING ip_program ip_dynpro TYPE any.       "#EC *
  CLEAR wa_bdcdata.
  wa_bdcdata-program  = ip_program.
  wa_bdcdata-dynpro   = ip_dynpro.
  wa_bdcdata-dynbegin = c_x.
  APPEND wa_bdcdata TO t_bdcdata.
ENDFORM.                    "FBDC_DYNPRO

\*----------------------------------------------------------------------\*
\*        Insert field                                                  *
\*----------------------------------------------------------------------\*
FORM fbdc_field USING ip_fnam ip_fval TYPE any.             "#EC *
  CLEAR wa_bdcdata.
  wa_bdcdata-fnam = ip_fnam.
  wa_bdcdata-fval = ip_fval.
  APPEND wa_bdcdata TO t_bdcdata.
ENDFORM.                    "FBDC_FIELD

\*----------------------------------------------------------------------\*
\*        Start new transaction according to parameters                 *
\*----------------------------------------------------------------------\*
FORM fbdc_transaction USING value(l_tcode) TYPE tstc-tcode.
  REFRESH t_messtab.
  CALL TRANSACTION l_tcode USING t_bdcdata
                               MODE   v_ctumode
                               UPDATE v_cupdate
                               MESSAGES INTO t_messtab.

  REFRESH t_bdcdata.

ENDFORM.                    "fBDC_TRANSACTIO

\* include ztl_bce011l_efinder_f01.

\*----------------------------------------------------------------------\*
\***INCLUDE ZTL_BCE011L_EFINDER_F_PARAMF01 .
\*----------------------------------------------------------------------\*
\*&---------------------------------------------------------------------\*
\*&      Form  F_PARAM_CHECK_200
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
FORM f_param_check_200.

  IF ( p_tcode IS INITIAL AND
       p_dev   IS INITIAL AND
       p_fun   IS INITIAL ) OR
     ( NOT p_tcode IS INITIAL AND
       NOT p_dev   IS INITIAL AND
       NOT p_fun  IS INITIAL ) OR
      ( NOT p_tcode IS INITIAL AND
       NOT p_dev   IS INITIAL ) OR
      ( NOT p_dev   IS INITIAL AND
         NOT p_fun  IS INITIAL ) OR
      ( NOT p_tcode IS INITIAL AND
        NOT p_fun   IS INITIAL ) .
\**-\- Enter either Tcode or Package or Function group
    MESSAGE e001(00) WITH text-003.
  ENDIF.

\**-\- Tcode validation
  IF NOT p_tcode IS INITIAL.
    SELECT SINGLE * FROM tstc INTO wa_tstc
     WHERE tcode EQ p_tcode.
    IF sy-subrc %LT%GT 0.
\**-\- Transaction Code Does Not Exist
      MESSAGE e001(00) WITH text-004.
    ENDIF.
  ENDIF.

\**-\- Package validation
  IF NOT p_dev IS INITIAL.
    SELECT SINGLE * FROM tdevc INTO wa_tdevc
     WHERE devclass EQ p_dev.
    IF sy-subrc %LT%GT 0.
\**-\- Package Does Not Exist
      MESSAGE e001(00) WITH text-005.
    ENDIF.
  ENDIF.

\**-\- Function group validation
  IF NOT p_fun IS INITIAL.
    SELECT SINGLE * FROM tlibg INTO wa_tlibg
     WHERE area EQ p_fun.
    IF sy-subrc %LT%GT 0.
\**-\- Function group Does Not Exist
      MESSAGE e001(00) WITH text-021.
    ENDIF.

    SELECT SINGLE *
      FROM tlibt INTO wa_tlibt
      WHERE area = p_fun AND
            spras = sy-langu.
    IF sy-subrc %LT%GT 0.
\**-\- Function group Does Not Exist
      MESSAGE e001(00) WITH text-021.
    ENDIF.
  ENDIF.

ENDFORM.                    " F_PARAM_CHECK_200
\*&---------------------------------------------------------------------\*
\*&      Form  F_PARAM_CHECK_100
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
\*  \--%GT  p1        text
\*  %LT--  p2        text
\*----------------------------------------------------------------------\*
FORM f_param_check_100 .

  IF ( p_progra IS INITIAL AND
       p_tcode   IS INITIAL ) OR
     ( NOT p_progra  IS INITIAL AND
       NOT p_tcode IS INITIAL ) .
\**--Enter either Tcode or Executable Program
    MESSAGE e001(00) WITH text-039.
  ENDIF.\\

\**-\- Tcode validation
  IF NOT p_tcode IS INITIAL
  AND p_progra IS INITIAL .
    SELECT SINGLE * FROM tstc INTO wa_tstc
     WHERE tcode EQ p_tcode.
    IF sy-subrc %LT%GT 0.
\**-\- Transaction Code Does Not Exist
      MESSAGE e001(00) WITH text-004.
    ENDIF.
  ENDIF.

\**-\- Program validation
  IF p_progra IS NOT INITIAL AND
     p_tcode IS INITIAL.
    SELECT SINGLE * FROM trdir
      INTO lwa_trdir
      WHERE name EQ p_progra.

    IF sy-subrc EQ 0.
      IF lwa_trdir-subc NE '1'.
\*     &1 is not an 'Executable Program'
        MESSAGE e001(00) WITH p_progra text-040.
      ENDIF.
    ELSE. "sy-subrc ne 0.
\*     Program does not exist
      MESSAGE e001(00) WITH text-041.
    ENDIF.
  ENDIF.

ENDFORM.                    " F_PARAM_CHECK_100
\*&---------------------------------------------------------------------\*
\*&      Form  F_RUN_BADI_IN_PACKAGE
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
\*  \--%GT  p1        text
\*  %LT--  p2        text
\*----------------------------------------------------------------------\*
FORM f_run_badi_in_package .

  IF p_exit = c_x.
\**-\- Validate T.Code and find SAP Modifications
    PERFORM f_fuehtiwedoctroegakcap.

  ELSE.
    IF p_prog = c_x AND
      ( NOT p_tcode IS INITIAL OR
        NOT p_fun IS INITIAL ) .
\**--Get the Enhancement Details
      PERFORM ftnemecnahenybmargorpeman.

    ELSEIF p_devl = c_x OR
           ( p_prog = c_x AND
             NOT p_dev IS INITIAL )  OR
           ( NOT p_fun IS INITIAL ).
\**--Get enhacement spots & implementation details and switch details
      PERFORM ftnemecnahenyegakcapeman.

    ENDIF.
  ENDIF.
ENDFORM.                    " F_RUN_BADI_IN_PACKAGE
\*&---------------------------------------------------------------------\*
\*&      Form  F_RUN_BADI_IN_PROCESS
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
\*  \--%GT  p1        text
\*  %LT--  p2        text
\*----------------------------------------------------------------------\*
FORM f_run_badi_in_process .

\*  Deactivate trace for process that don't has been finished yet.
  PERFORM switch_trace_off.

  CONCATENATE sy-timlo+0(2)
              sy-timlo+2(2)
              sy-timlo+4(2)
        INTO lv_time_start  SEPARATED BY ':'.

  d_mode = 'N'.

\* Activate Trace
  PERFORM switch_trace_on.

\* Run user Process
  PERFORM run_process.

\* Deactivate Trace
  PERFORM switch_trace_off.

\* Get Trace Results
  PERFORM get_trace_result.

\* Get trace result from file to system
  PERFORM convert_trace_result.

\* Show result on screen
  PERFORM print_result_on_screen.

ENDFORM.                    " F_RUN_BADI_IN_PROCESS
\*&---------------------------------------------------------------------\*
\*&      Form  switch_trace_on
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
FORM switch_trace_on .

  CALL FUNCTION 'SQLT_TRACE_ON'
   EXPORTING
\*   CLIENT                  = ' '
     TRACE_USER              = SY-UNAME
     SQL_TRACE_ON            = 'X'
\*   ENQ_TRACE_ON            = ' '
\*   RFC_TRACE_ON            = ' '
     BUF_TRACE_ON            = 'X'
\*   PROC_NR                 = ' '
\*   TCODE                   = ' '
\*   PROGNAME                = ' '
\*   TAB_INC                 =
\*   TAB_EXC                 =
\* IMPORTING
\*   LAST_MOD_DAT            =
\*   LAST_MOD_TIME           =
\*   ACT_TRACE_USER          =
   EXCEPTIONS
     ERROR_TRACE_ON          = 1
     TRACE_ON_FOR_ALL        = 2
     TRACE_ON_FOR_USER       = 3
     OTHERS                  = 4.

  IF SY-SUBRC %LT%GT 0.
    MESSAGE ID SY-MSGID
    TYPE SY-MSGTY
    NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    " switch_trace_on
\*&---------------------------------------------------------------------\*
\*&      Form  run_process
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
FORM run_process.

\* Run programs
  IF p_progra IS NOT INITIAL AND
     p_tcode IS INITIAL.

    MOVE p_progra TO lv_program.

    SUBMIT (lv_program) VIA SELECTION-SCREEN AND RETURN.
    IF sy-subrc NE 0.
    ENDIF.
  ENDIF.

\* Run transactions
  IF p_progra IS INITIAL AND
     p_tcode IS NOT INITIAL.

    CLEAR i_messages.
    CALL TRANSACTION p_tcode .

    IF sy-subrc NE 0.
\*    Do nothing
    ENDIF.
  ENDIF.

ENDFORM.                    "run_process                  " run_process
\*&---------------------------------------------------------------------\*
\*&      Form  switch_trace_off
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
FORM switch_trace_off .

  CALL FUNCTION 'SQLT_TRACE_OFF'
   EXPORTING
     TRACE_USER            = SY-UNAME
     SQL_TRACE_OFF         = 'X'
\*   ENQ_TRACE_OFF         = ' '
\*   RFC_TRACE_OFF         = ' '
     BUF_TRACE_OFF         = 'X'
\*   CHECK_USER            = ' '
\* IMPORTING
\*   LAST_MOD_DAT          =
\*   LAST_MOD_TIME         =
\*   LAST_MOD_USER         =
   EXCEPTIONS
     ERROR_TRACE_OFF       = 1
     ERROR_MOD_USER        = 2
     OTHERS                = 3.

  IF SY-SUBRC %LT%GT 0.
    MESSAGE ID SY-MSGID
    TYPE SY-MSGTY
    NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    "switch_trace_off
\*&---------------------------------------------------------------------\*
\*&      Form  get_trace_result
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
FORM get_trace_result .

\* Batch input 'ST05' Transaction
\* Display trace and save result in a local file to deal with the data

\* Fill trace dates
  DATA: ld_date(10)  TYPE c.

\*  Load correct format
\*  CONCATENATE sy-datum+6(2)
\*              sy-datum+4(2)
\*              sy-datum+0(4)
\*         INTO ld_date
\*         SEPARATED BY '.'.

  PERFORM f_get_date_correct_format CHANGING ld_date.

  PERFORM f_bdc_insert TABLES li_bdcdata_dis
                       USING: 'X' 'SAPLSSQ0' '0010',
                              ' ' 'BDC_CURSOR' 'SQLTFIELDS-STATE',
                              ' ' 'BDC_OKCODE' '=LIST',
                              ' ' 'SQL_TRACE' c_x,
                              ' ' 'BUF_TRACE' c_x.

\* Fill End time Trace
\*  CONCATENATE sy-uzeit+0(2)
\*              sy-uzeit+2(2)
\*              sy-uzeit+4(2)
\*         INTO lv_time_end
\*         SEPARATED BY ':'.

  CONCATENATE sy-timlo+0(2)
              sy-timlo+2(2)
              sy-timlo+4(2)
         INTO lv_time_end
         SEPARATED BY ':'.

  PERFORM f_bdc_insert TABLES li_bdcdata_dis
               USING: 'X' 'SAPLSSQ0'              '0210',
                      ' ' 'BDC_CURSOR'            'SQLTFIELDS-DATE',
                      ' ' 'BDC_OKCODE'            '=EXEC',
                      ' ' 'SQL_TRACE_ON'          c_x,
                      ' ' 'BASIC_LIST'            c_x,
                      ' ' 'BUF_TRACE_ON'          c_x,
                      ' ' 'SQLTFIELDS-DATE'       ld_date,
                      ' ' 'SQLTFIELDS-END_DATE'   ld_date,
                      ' ' 'SQLTFIELDS-TIME'       lv_time_start,
                      ' ' 'SQLTFIELDS-END_TIME'   lv_time_end,
                      ' ' 'CHECK_TRACE_MAX'       '99999999'.

  PERFORM f_bdc_insert TABLES li_bdcdata_dis
                       USING: 'X' 'SAPMSSY0' '0120',
                              ' ' 'BDC_CURSOR' '01/02',
                              ' ' 'BDC_OKCODE' '=%PC'.

\*  PERFORM f_bdc_insert TABLES li_bdcdata_dis
\*                       USING: 'X' 'SAPLSPO5' '0101',
\*                              ' ' 'BDC_CURSOR' 'SPOPLI-SELFLAG(02)',
\*                              ' ' 'BDC_OKCODE' '=OK',
\*                              ' ' 'SPOPLI-SELFLAG(01)' c_x.
"unconverted file

  PERFORM f_bdc_insert TABLES li_bdcdata_dis
                       USING: 'X' 'SAPLSPO5' '0110',
     ' ' 'BDC_SUBSCR' 'SAPLSPO5 0180 SUBSCREEN_CONTROL',
     ' ' 'BDC_SUBSCR' 'SAPLSPO5 0150SUBSCREEN_STEPLOOP',
                              ' ' 'BDC_CURSOR' 'SPOPLI-SELFLAG(01)',
                              ' ' 'BDC_OKCODE' '=OK',
                              ' ' 'SPOPLI-SELFLAG(01)' c_x.
                              "unconverted file

\* Fill file's parameters:
  lv_filename = 'trace.txt'.
  lv_path     = 'c:\'.
  CONCATENATE lv_path lv_filename INTO lv_fullpath.

\* Check file exists in Pc.
  PERFORM check_file.

  IF lv_file IS INITIAL.
\*   File does not exist
    PERFORM file_no_exist_in_pc.
  ELSE.
\*   File already exist
    PERFORM file_exist_in_pc.
  ENDIF.

  d_mode = 'N'.

\* Display trace
  CALL TRANSACTION 'ST05' USING         li_bdcdata_dis
                          MODE          d_mode
                          UPDATE        'A'
                          MESSAGES INTO i_messages.

  LOOP AT i_messages  INTO wa_messages WHERE msgtyp EQ c_e.
    MESSAGE ID wa_messages-msgid
   TYPE wa_messages-msgtyp
   NUMBER wa_messages-msgnr
   WITH wa_messages-msgv1 wa_messages-msgv2 wa_messages-msgv3
wa_messages-msgv4.
    lv_find = c_x.
  ENDLOOP.

  IF lv_find = c_x.
    EXIT.
  ENDIF.
ENDFORM.                    "get_trace_result
\*&---------------------------------------------------------------------\*
\*&      Form  convert_trace_result
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
\*  \--%GT  p1        text
\*  %LT--  p2        text
\*----------------------------------------------------------------------\*
FORM convert_trace_result .
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = lv_fullpath
      filetype                = 'ASC'
      has_field_separator     = c_x
    TABLES
      data_tab                = l_tab_file
    EXCEPTIONS
      file_open_error         = 1
      file_read_error         = 2
      no_batch                = 3
      gui_refuse_filetransfer = 4
      invalid_type            = 5
      no_authority            = 6
      unknown_error           = 7
      bad_data_format         = 8
      header_not_allowed      = 9
      separator_not_allowed   = 10
      header_too_long         = 11
      unknown_dp_error        = 12
      access_denied           = 13
      dp_out_of_memory        = 14
      disk_full               = 15
      dp_timeout              = 16
      OTHERS                  = 17.

  IF sy-subrc %LT%GT 0.
    MESSAGE ID sy-msgid
    TYPE sy-msgty
    NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

\* Read file's lines
  CLEAR: l_wa_file, l_wa_trace_result.
  LOOP AT l_tab_file INTO l_wa_file.

    SPLIT l_wa_file-string AT con_separator INTO:
        l_wa_trace_result-one
        l_wa_trace_result-two
        l_wa_trace_result-obj_name   "needed
        l_wa_trace_result-five
        l_wa_trace_result-six
        l_wa_trace_result-seven
        l_wa_trace_result-statement  "needed
        l_wa_trace_result-nine.

    CONDENSE l_wa_trace_result-obj_name NO-GAPS.
    CONDENSE l_wa_trace_result-statement NO-GAPS.

    APPEND l_wa_trace_result TO l_tab_trace_result.

    CLEAR: l_wa_file, l_wa_trace_result.
  ENDLOOP.

\*
\*\* BADI's Process
  PERFORM get_badis.

\*
\*\* User-exits Process
  PERFORM get_exits.

ENDFORM.                    " convert_trace_result
\*&---------------------------------------------------------------------\*
\*&      Form  print_result_on_screen
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
FORM print_result_on_screen .

\* Building final table
\* Add Business Add-in/Enhacements to final table
  IF l_tab_badi_obj  IS NOT INITIAL.

    CLEAR: l_wa_final, l_wa_badi_obj.

    LOOP AT l_tab_badi_obj INTO l_wa_badi_obj.

      SELECT * FROM tadir
        INTO CORRESPONDING FIELDS OF TABLE l_tab_tadir
        WHERE obj_name EQ l_wa_badi_obj-statement.

      IF sy-subrc EQ 0.
        CLEAR: l_wa_tadir, l_wa_final.
        LOOP AT l_tab_tadir INTO l_wa_tadir.
          CASE l_wa_tadir-object.
            WHEN 'ENHS'.
\*             Add to final table
              l_wa_final-obj_name = c_enh_spot.
              l_wa_final-statement = l_wa_badi_obj-statement.
              APPEND l_wa_final TO l_tab_final.
              CLEAR: l_wa_tadir, l_wa_final.
            WHEN 'SXSD'.
\*              Add to final table
              l_wa_final-obj_name = c_badi_def.
              l_wa_final-statement = l_wa_badi_obj-statement.
              APPEND l_wa_final TO l_tab_final.
              CLEAR: l_wa_tadir, l_wa_final.
            WHEN OTHERS.
\*             Do nothing
          ENDCASE.
        ENDLOOP.
      ENDIF.
      CLEAR: l_wa_final, l_wa_badi_obj.
    ENDLOOP.
  ENDIF.

\* Add User-exits to final table
  IF l_tab_exit_obj  IS NOT INITIAL.

    CLEAR: l_wa_final, l_wa_exit_obj.
    LOOP AT l_tab_exit_obj INTO l_wa_exit_obj.

      SELECT funcname FROM tfdir
        INTO lv_tfdir_funcname
        WHERE funcname EQ l_wa_exit_obj-statement.    "#EC CI_SGLSELECT
      ENDSELECT.
      IF sy-subrc EQ 0.
        l_wa_final-obj_name = c_user_exit.
        l_wa_final-statement = l_wa_exit_obj-statement.
        APPEND l_wa_final TO l_tab_final.
      ENDIF.
      CLEAR: l_wa_final, l_wa_exit_obj.
    ENDLOOP.
  ENDIF.

\* Print Results

  CLEAR: l_wa_final, l_wa_badi_obj.
  SORT l_tab_final BY obj_name.
  IF l_tab_final IS INITIAL.
\* If no results are found
\* Print header
    FORMAT COLOR COL_HEADING INTENSIFIED ON.
    WRITE:/1 sy-vline,
    2 'Enhancement/ Business Add-in',
    41 sy-vline ,
    42 'Description',
    105 sy-vline.

\* Print: 'No Enhancement/ Business Add-in found in process'
    WRITE:/(105) sy-uline.
    FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
    WRITE:/ 'No Enhancement/ Business Add-in found in process'.
    EXIT.
  ELSE.

    CLEAR: l_wa_final.
    LOOP AT l_tab_final INTO l_wa_final.
      AT FIRST.
\* Print header
        FORMAT COLOR COL_HEADING INTENSIFIED ON.
        WRITE:/1 sy-vline,
        2 'Enhancement/ Business Add-in',
        41 sy-vline ,
        42 'Description',
        105 sy-vline.
        WRITE:/(105) sy-uline.
      ENDAT.
      AT NEW obj_name.
\* Print header object
        IF l_wa_final-obj_name EQ c_user_exit.
          lv_object2 = 'User Exit'.
        ELSEIF l_wa_final-obj_name EQ c_badi_def.
          lv_object2 = 'Business Add-in'.
        ELSEIF l_wa_final-obj_name EQ c_enh_spot.
          lv_object2 = 'Enhacements spot'.
        ENDIF.
        FORMAT COLOR COL_GROUP INTENSIFIED ON.
        WRITE:/1 sy-vline,
        2 lv_object2,
        105 sy-vline.
      ENDAT.

\* Get & print description of the object
      CASE l_wa_final-obj_name.
        WHEN c_badi_def OR
             c_enh_spot.

          IF l_wa_final-obj_name EQ c_badi_def OR
             l_wa_final-obj_name EQ c_enh_spot.
\*            Description of Definition
            CLEAR lv_txt.
            SELECT SINGLE text INTO lv_txt
            FROM sxs_attrt
            WHERE exit_name EQ l_wa_final-statement AND
              sprsl EQ sy-langu.
            IF sy-subrc NE 0.
              CLEAR lv_txt.
            ENDIF.
          ENDIF.
          FORMAT COLOR COL_NORMAL INTENSIFIED ON.

        WHEN c_user_exit.
          CLEAR lv_txt.
          SELECT SINGLE modtext INTO lv_txt
          FROM modsapt
          WHERE sprsl EQ sy-langu
          AND name EQ l_wa_final-statement.
          IF sy-subrc NE 0.
            CLEAR lv_txt.
          ENDIF.
          FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
        WHEN OTHERS.
      ENDCASE.

      WRITE:/1 sy-vline,
      2 l_wa_final-statement HOTSPOT ON,
      41 sy-vline ,
      42 lv_txt,
      105 sy-vline.
      AT END OF obj_name.
        WRITE : /(105) sy-uline.
      ENDAT.
      CLEAR: l_wa_final.
    ENDLOOP.
    WRITE:/(105) sy-uline.
  ENDIF.

ENDFORM.                    " print_result_on_screen
\*&---------------------------------------------------------------------\*
\*&      Form  f_bdc_insert
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
FORM f_bdc_insert TABLES li_bdcdata STRUCTURE bdcdata
                  USING  value(p_dynbegin) TYPE any
                         value(p_fnam)     TYPE any
                         value(p_fval)     TYPE any.
  CLEAR lw_bdcdata.

\* flag screen
  lw_bdcdata-dynbegin = p_dynbegin.

\* Screen
  IF  p_dynbegin EQ c_true.
    lw_bdcdata-program = p_fnam.
    lw_bdcdata-dynpro  = p_fval.
\* Fiel
  ELSE.
    lw_bdcdata-fnam = p_fnam.
    lw_bdcdata-fval = p_fval.
  ENDIF.

  APPEND lw_bdcdata TO li_bdcdata.

ENDFORM.        " f_bdc_insert                " f_bdc_insert
\*&---------------------------------------------------------------------\*
\*&      Form  CHECK_FILE
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
FORM check_file .

  DATA rc.
  CALL METHOD cl_gui_frontend_services=%GTfile_exist
    EXPORTING
      file   = lv_fullpath
    RECEIVING
      result = rc.

  IF rc = space.
\*   File does not exist
    CLEAR lv_file.
  ELSE.
\*   File already exists
    lv_file = c_x.
  ENDIF.
ENDFORM.                    " CHECK_FILE
\*&---------------------------------------------------------------------\*
\*&      Form  FILE_NO_EXIST_IN_PC
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
FORM file_no_exist_in_pc .
  PERFORM f_bdc_insert TABLES li_bdcdata_dis
                       USING: 'X' 'SAPLSFES' '0200',
                              ' ' 'BDC_CURSOR' 'DY_FILENAME',
                              ' ' 'DY_PATH' lv_path,
                              ' ' 'DY_FILENAME' lv_filename,
                              ' ' 'BDC_OKCODE' '=FILE'.

  PERFORM f_bdc_insert TABLES li_bdcdata_dis
                       USING: 'X' 'SAPMSSY0' '0120',
                              ' ' 'BDC_CURSOR' '01/02',
                              ' ' 'BDC_OKCODE' '=BACK'.

  PERFORM f_bdc_insert TABLES li_bdcdata_dis
                       USING: 'X' 'SAPLSSQ0' '0010',
                              ' ' 'BDC_CURSOR' 'SQLTFIELDS-STATE',
                              ' ' 'BDC_OKCODE' '=BACK'.
ENDFORM.                    " FILE_NO_EXIST_IN_PC
\*&---------------------------------------------------------------------\*
\*&      Form  FILE_EXIST_IN_PC
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
\*  \--%GT  p1        text
\*  %LT--  p2        text
\*----------------------------------------------------------------------\*
FORM file_exist_in_pc .
  PERFORM f_bdc_insert TABLES li_bdcdata_dis
                         USING: 'X' 'SAPLSFES' '0200',
                                ' ' 'BDC_CURSOR' 'DY_FILENAME',
                                ' ' 'DY_PATH' lv_path,
                                ' ' 'DY_FILENAME' lv_filename,
                                ' ' 'BDC_OKCODE' '=FILE'.

  PERFORM f_bdc_insert TABLES li_bdcdata_dis
                       USING: 'X' 'SAPLSFES' '0200',
                              ' ' 'BDC_CURSOR' 'DY_FILENAME',
                              ' ' 'DY_PATH' lv_path,
                              ' ' 'DY_FILENAME' lv_filename,
                              ' ' 'BDC_OKCODE' '=REPL'.

  PERFORM f_bdc_insert TABLES li_bdcdata_dis
                       USING: 'X' 'SAPMSSY0' '0120',
                              ' ' 'BDC_CURSOR' '01/02',
                              ' ' 'BDC_OKCODE' '=BACK'.

  PERFORM f_bdc_insert TABLES li_bdcdata_dis
                       USING: 'X' 'SAPLSSQ0' '0010',
                              ' ' 'BDC_CURSOR' 'SQLTFIELDS-STATE',
                              ' ' 'BDC_OKCODE' '=BACK'.

ENDFORM.                    " FILE_EXIST_IN_PC
\*&---------------------------------------------------------------------\*
\*&      Form  GET_BADIS
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
FORM get_badis .

  CLEAR: l_wa_trace_result. "l_wa_obj_stat,

  LOOP AT l_tab_trace_result INTO l_wa_trace_result
    WHERE obj_name EQ 'SXS_ATTR'
    OR obj_name EQ 'SXS_MLCO'
    OR obj_name EQ 'V_EXT_ACT'
    OR obj_name EQ 'V_EXT_IMP'.

    IF l_wa_trace_result-statement IS NOT INITIAL AND
       l_wa_trace_result-statement+0(6) NE 'SELECT'.
      MOVE l_wa_trace_result-statement TO l_wa_badi_obj-statement.
      APPEND l_wa_badi_obj TO l_tab_badi_obj_temp.
    ENDIF.
    CLEAR: l_wa_trace_result. "l_wa_obj_stat,
  ENDLOOP.

  IF l_tab_badi_obj_temp IS NOT INITIAL.
    CLEAR: l_wa_badi_obj, lv_offset, lv_offset_end,
           lv_lenght, lv_find, lv_badi_obj.

    LOOP AT l_tab_badi_obj_temp INTO l_wa_badi_obj.

      lv_lenght = STRLEN( l_wa_badi_obj-statement ).

      lv_offset = '3'.

      IF l_wa_badi_obj-statement+3(1) CA c_num.
        lv_find = ' '.
      ELSE.
        lv_find = c_true.
        lv_offset_end = lv_lenght - 3.
        lv_badi_obj = l_wa_badi_obj-statement+3(lv_offset_end).
        l_wa_badi_obj-statement = lv_badi_obj.
        APPEND l_wa_badi_obj TO l_tab_badi_obj.
      ENDIF.

      WHILE lv_find NE c_true
         OR lv_offset GT lv_lenght.

        IF l_wa_badi_obj-statement+lv_offset(1) CA c_num.
          lv_offset = lv_offset + 1.
          lv_find = ' '.
        ELSE.
          lv_find = c_true.
          lv_offset_end = lv_lenght - lv_offset.
          lv_badi_obj = l_wa_badi_obj-statement+lv_offset(lv_offset_end)
.
          l_wa_badi_obj-statement = lv_badi_obj.
          APPEND l_wa_badi_obj TO l_tab_badi_obj.
        ENDIF.
      ENDWHILE.

      CLEAR: l_wa_badi_obj, lv_offset, lv_offset_end,
             lv_lenght, lv_find, lv_badi_obj.
    ENDLOOP.
  ENDIF.

  IF l_tab_badi_obj IS NOT INITIAL.
    SORT l_tab_badi_obj BY statement ASCENDING.

    DELETE ADJACENT DUPLICATES FROM l_tab_badi_obj. "BADIS final table
    IF sy-subrc EQ 0.
    ENDIF.
  ENDIF.

ENDFORM.                    " GET_BADIS
\*&---------------------------------------------------------------------\*
\*&      Form  GET_EXITS
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
\*  \--%GT  p1        text
\*  %LT--  p2        text
\*----------------------------------------------------------------------\*
FORM get_exits .

  LOOP AT l_tab_trace_result INTO l_wa_trace_result
    WHERE obj_name EQ 'TFDIR'
    AND statement CS 'EXIT_'.

    MOVE l_wa_trace_result-statement TO l_wa_exit_obj-statement.
    APPEND l_wa_exit_obj TO l_tab_exit_obj_temp.
  ENDLOOP.

  IF l_tab_exit_obj_temp IS NOT INITIAL.

    CLEAR: l_wa_exit_obj, lv_offset, lv_offset_end,
           lv_lenght, lv_find, lv_exit_obj.

    LOOP AT l_tab_exit_obj_temp INTO l_wa_exit_obj.

      lv_lenght = STRLEN( l_wa_exit_obj-statement ).

      lv_offset = '3'.

      IF l_wa_exit_obj-statement+3(1) CA c_num.
        lv_find = ' '.
      ELSE.
        IF l_wa_exit_obj-statement+3(5) CO 'EXIT_'.
          lv_find = c_true.
          lv_offset_end = lv_lenght - 3.
          lv_exit_obj = l_wa_exit_obj-statement+3(lv_offset_end).
          l_wa_exit_obj-statement = lv_exit_obj.
          APPEND l_wa_exit_obj TO l_tab_exit_obj.
        ENDIF.
      ENDIF.

      WHILE lv_find NE c_true
         OR lv_offset GT lv_lenght.

        IF l_wa_exit_obj-statement+lv_offset(1) CA c_num.
          lv_offset = lv_offset + 1.
          lv_find = ' '.
        ELSE.
          IF l_wa_exit_obj-statement+lv_offset(5) CO 'EXIT_'.
            lv_find = c_true.
            lv_offset_end = lv_lenght - lv_offset.
            lv_exit_obj =
l_wa_exit_obj-statement+lv_offset(lv_offset_end).
            l_wa_exit_obj-statement = lv_exit_obj.
            APPEND l_wa_exit_obj TO l_tab_exit_obj.
          ELSE.
            lv_find = c_true.
            EXIT.
          ENDIF.
        ENDIF.
      ENDWHILE.

      CLEAR: l_wa_exit_obj, lv_offset, lv_offset_end,
             lv_lenght, lv_find, lv_exit_obj.
    ENDLOOP.
  ENDIF.

  IF l_tab_exit_obj IS NOT INITIAL.
    SORT l_tab_exit_obj BY statement ASCENDING.

    DELETE ADJACENT DUPLICATES FROM l_tab_exit_obj. "EXITS final table
    IF sy-subrc EQ 0.
    ENDIF.
  ENDIF.
ENDFORM.                    " GET_EXITS
\*&---------------------------------------------------------------------\*
\*&      Form  F_GET_DATE_CORRECT_FORMAT
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
\*      %LT--P_LD_DATE  text
\*----------------------------------------------------------------------\*
FORM f_get_date_correct_format  CHANGING p_date.

  DATA: l_format_date(10).

  CALL FUNCTION 'SLS_MISC_GET_USER_DATE_FORMAT'
    IMPORTING
      p_date_format                  = l_format_date
    EXCEPTIONS
      error_reading_user_master      = 1
      error_reading_date_format_text = 2
      OTHERS                         = 3.

  IF sy-subrc %LT%GT 0.
    MESSAGE ID sy-msgid
    TYPE sy-msgty
    NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  CALL FUNCTION 'SLS_MISC_CONVERT_TO_DATE'
    EXPORTING
      p_date                        = sy-datum
      p_date_format                 = l_format_date
    IMPORTING
      p_date_string                 = p_date
    EXCEPTIONS
      error_selecting_user_defaults = 1
      OTHERS                        = 2.

  IF sy-subrc %LT%GT 0.
    MESSAGE ID sy-msgid
    TYPE sy-msgty
    NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

ENDFORM.                    " F_GET_DATE_CORRECT_FORMAT
\*&---------------------------------------------------------------------\*
\*&      Form  F_LINE_SELECTION_ONLINE
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
\*  \--%GT  p1        text
\*  %LT--  p2        text
\*----------------------------------------------------------------------\*
FORM f_line_selection_online .
  DATA: l_name TYPE smodname.

  CLEAR: v_fld,
         v_enhname.

  GET CURSOR FIELD v_fld VALUE v_enhname.

  CLEAR l_wa_final.
  READ TABLE l_tab_final INTO l_wa_final WITH KEY statement = v_enhname.

\*  sy-lisel+1(39).
  IF sy-subrc NE 0.
    CLEAR l_wa_final.
  ENDIF.

  CASE l_wa_final-obj_name.
    WHEN c_user_exit.

      SELECT SINGLE name
      FROM modsap
      INTO l_name
      WHERE member EQ v_enhname.
      IF sy-subrc EQ 0.
        clear v_enhname.
      ENDIF.

      SET PARAMETER ID 'MON' FIELD l_name.   "sy-lisel+1(10).
      PERFORM fbdc_dynpro      USING 'SAPMSMOD'    '2010'.
      PERFORM fbdc_field       USING 'BDC_OKCODE'  '=SHOW'.
      PERFORM fbdc_field       USING 'MODF-CHAM'   c_x.
      PERFORM fbdc_transaction USING 'SMOD'.

    WHEN  c_enh_spot.

      PERFORM fbdc_dynpro      USING 'SAPLSEXO' '0100'.
      PERFORM fbdc_field       USING 'BDC_OKCODE' '=SHOW'.
      PERFORM fbdc_field       USING 'BDC_CURSOR' 'G_ENHSPOTNAME'.
      PERFORM fbdc_field       USING 'G_IS_SPOT' c_true.
      PERFORM fbdc_field       USING 'G_ENHSPOTNAME'  v_enhname.
"sy-lisel+1(39).
      PERFORM fbdc_transaction USING 'SE18'.

    WHEN c_badi_def.

      PERFORM fbdc_dynpro      USING 'SAPLSEXO' '0100'.
      PERFORM fbdc_field       USING 'BDC_OKCODE' '=ISSPOT'.
      PERFORM fbdc_field       USING 'BDC_CURSOR' 'G_IS_BADI'.
      PERFORM fbdc_field       USING 'G_IS_BADI' c_true.

      PERFORM fbdc_dynpro      USING 'SAPLSEXO' '0100'.
      PERFORM fbdc_field       USING 'BDC_OKCODE' '=SHOW'.
      PERFORM fbdc_field       USING 'G_BADINAME'  v_enhname.
"sy-lisel+1(39).
      PERFORM fbdc_transaction USING 'SE18'.

    WHEN OTHERS.
\*     Do Nothing
  ENDCASE.\\

ENDFORM.                    " F_LINE_SELECTION_ONLINE
\*&---------------------------------------------------------------------\*
\*&      Form  F_LINE_SELECTION_PACKAGE
\*&---------------------------------------------------------------------\*
\*       text
\*----------------------------------------------------------------------\*
\*  \--%GT  p1        text
\*  %LT--  p2        text
\*----------------------------------------------------------------------\*
FORM f_line_selection_package .

  CLEAR: v_fld,
         v_enhname.

  GET CURSOR FIELD v_fld VALUE v_enhname.
  IF v_fld = c_enha.
    IF v_enhname IS NOT INITIAL.
      PERFORM fbdc_dynpro      USING c_prog_saplsexo  c_dyn_num.
      PERFORM fbdc_field       USING c_fname_bdc c_fval_imp.
      PERFORM fbdc_field       USING c_fname_bdc1 c_fval_genha.
      PERFORM fbdc_field       USING c_fnam_new1 c_x.
      PERFORM fbdc_field       USING c_fval_genha  v_enhname.
      PERFORM fbdc_field       USING c_fnam_new2 c_x.
      PERFORM fbdc_transaction USING 'SE19'.
    ENDIF.
  ELSEIF v_fld = c_enhspt.
    PERFORM fbdc_dynpro      USING c_prog_saplsexo  c_dyn_num1.
    PERFORM fbdc_field       USING c_fname_bdc  c_fval_show.
    PERFORM fbdc_field       USING c_fname_bdc1 c_fval_enspot.
    PERFORM fbdc_field       USING c_fval_isspot c_x.
    PERFORM fbdc_field       USING c_fval_enspot  sy-lisel+1(29).
    PERFORM fbdc_transaction USING 'SE18'.
  ELSEIF v_fld(7) EQ c_jtab.

    READ TABLE t_jtab INTO wa_jtab WITH KEY obj_name = sy-lisel+1(20).
    v_object = wa_jtab-object .
    CASE v_object.
      WHEN c_smod.
        SET PARAMETER ID c_mon FIELD sy-lisel+1(10).

        CALL TRANSACTION c_smod AND SKIP FIRST   SCREEN.
      WHEN c_sxsd.

        PERFORM fbdc_dynpro      USING  c_prog_saplsexo  c_dyn_num1.
        PERFORM fbdc_field       USING  c_fname_bdc c_fval_ispot.
        PERFORM fbdc_field       USING  c_fname_bdc1  c_fval_badi.
        PERFORM fbdc_field       USING  c_fval_badi c_x.

        PERFORM fbdc_dynpro      USING c_prog_saplsexo  c_dyn_num1.
        PERFORM fbdc_field       USING c_fname_bdc c_fval_show.
        PERFORM fbdc_field       USING c_fnam_badi  sy-lisel+1(29).

        PERFORM fbdc_transaction USING 'SE18'.
    ENDCASE.
  ENDIF.

ENDFORM.                    " F_LINE_SELECTION_PACKAGE

\*Text elements
\*---------------------------------------------------------\-
\* 001 Find by program name
\* 002 Find by package
\* 003 Enter either Tcode or Package or Function group
\* 004 Transaction Code Does Not Exist
\* 005 Package Does Not Exist
\* 006 Transaction Code Does Not Exist
\* 007 Transaction Code
\* 008 Exit Name
\* 009 Description
\* 010 No of Exits:
\* 011 No User Exit Exists
\* 012 Package
\* 013 Enhancements for tcode
\* 014 Enhancement Implementation
\* 015 Enhancement Spot Name
\* 016 Enhancement Type
\* 017 No Enhancement Spots Found
\* 018 Enhancement Spot Name for
\* 019 No.of BADis:
\* 020 Enhancement Spot / Implementation
\* 021 Function group Does Not Exist
\* 022 Enhancements for Function group
\* 023 Function group
\* 024 Enhancement
\* 025 Business Add-in
\* 026 To see Enhancement spot/Implementation in detail, please click on
\*     values under column
\* 027 Switch
\* 028 Switch State
\* 029 Source Code Enhancement
\* 030 BADI Enhancement
\* 031 Function group Enhancement
\* 032 Class Enhancement
\* 033 On
\* 034 Stand-by
\* 035 Off
\* 036 Selection Parameters
\* 037 In Process
\* 038 In Package
\* 039 Enter either Tcode or Executable Program
\* 040 is not an 'Executable Program'
\* 041 Program does not exist

\*Selection texts
\*---------------------------------------------------------\-
\* P_DEV         Package
\* P_DEVL         Package
\* P_ESPOT         Enhancement Spots
\* P_EXIT         Exits
\* P_FUN         Function group
\* P_PROG         Program
\* P_PROGRA         Program
\* P_TCODE         Transaction Code

\*Messages
\*---------------------------------------------------------\-
\*
\* Message class: 00
\*001   &1&2&3&4&5&6&7&8
\*
\* Message class: WA_MESSAGES-MSGID
\*WA\_

\*Text elements
\*---------------------------------------------------------\-
\* 001 Find by program name
\* 002 Find by package
\* 003 Enter either Tcode or Package or Function group
\* 004 Transaction Code Does Not Exist
\* 005 Package Does Not Exist
\* 006 Transaction Code Does Not Exist
\* 007 Transaction Code
\* 008 Exit Name
\* 009 Description
\* 010 No of Exits:
\* 011 No User Exit Exists
\* 012 Package
\* 013 Enhancements for tcode
\* 014 Enhancement Implementation
\* 015 Enhancement Spot Name
\* 016 Enhancement Type
\* 017 No Enhancement Spots Found
\* 018 Enhancement Spot Name for
\* 019 No.of BADis:
\* 020 Enhancement Spot / Implementation
\* 021 Function group Does Not Exist
\* 022 Enhancements for Function group
\* 023 Function group
\* 024 Enhancement
\* 025 Business Add-in
\* 026 To see Enhancement spot/Implementation in detail, please click on  values under column
\* 027 In Process
\* 028 Switch State
\* 029 Source Code Enhancement
\* 030 BADI Enhancement
\* 031 Function group Enhancement
\* 032 Class Enhancement
\* 033 On
\* 034 Stand-by
\* 035 Off
\* 036 Selection Parameters
\* 038 In Package
\* 039 Enter either Tcode or Executable Program
\* 040 is not an 'Executable Program'
\* 041 Program does not exist

\*Selection texts
\*---------------------------------------------------------\-
\* P_DEV         Package
\* P_DEVL         Package
\* P_ESPOT         Enhancement Spots
\* P_EXIT         Exits
\* P_FUN         Function group
\* P_PROG         Program
\* P_PROGRA         Program
\* P_TCODE         Transaction Code

\*Messages
\*---------------------------------------------------------\-
\*
\* Message class: 00
\*001   &1&2&3&4&5&6&7&8
\*
\* Message class: WA_MESSAGES-MSGID
\*WA\_

\*Text elements
\*---------------------------------------------------------\-
\* 001 Find by program name
\* 002 Find by package
\* 003 Enter either Tcode or Package or Function group
\* 004 Transaction Code Does Not Exist
\* 005 Package Does Not Exist
\* 006 Transaction Code Does Not Exist
\* 007 Transaction Code
\* 008 Exit Name
\* 009 Description
\* 010 No of Exits:
\* 011 No User Exit Exists
\* 012 Package
\* 013 Enhancements for tcode
\* 014 Enhancement Implementation
\* 015 Enhancement Spot Name
\* 016 Enhancement Type
\* 017 No Enhancement Spots Found
\* 018 Enhancement Spot Name for
\* 019 No.of BADis:
\* 020 Enhancement Spot / Implementation
\* 021 Function group Does Not Exist
\* 022 Enhancements for Function group
\* 023 Function group
\* 024 Enhancement
\* 025 Business Add-in
\* 026 To see Enhancement spot/Implementation in detail, please click on values
\* 027 Switch
\* 028 Switch State
\* 029 Source Code Enhancement
\* 030 BADI Enhancement
\* 031 Function group Enhancement
\* 032 Class Enhancement
\* 033 On
\* 034 Stand-by
\* 035 Off
\* 036 Selection Parameters
\* 037 In Process
\* 038 In Package
\* 039 Enter either Tcode or Executable Program
\* 040 is not an 'Executable Program'
\* 041 Program does not exist

\*Selection texts
\*---------------------------------------------------------\-
\* P_DEV         Package
\* P_DEVL         Package
\* P_ESPOT         Enhancement Spots
\* P_EXIT         Exits
\* P_FUN         Function group
\* P_PROG         Program
\* P_PROGRA         Program
\* P_TCODE         Transaction Code

\*Messages
\*---------------------------------------------------------\-
\*
\* Message class: 00
\*001   &1&2&3&4&5&6&7&8
\*
\* Message class: WA_MESSAGES-MSGID
\*WA\_

\-------------------------------------------------------------------------------\-
  • No labels