ALV: Template maintenance

SAP Tech Pro

SAP Technical Blog
Magzter [CPS] IN

ALV: Template maintenance

ALV: Template maintenance

Text Elements:
004     Action canceled by user
005     Process cancelled due to internal conversion problems
500     Error in flush
801     Really delete entries?
802     Delete
803     Y
804     No
805     Unreferenced
806     Temporary
807     Cus_Standard_Templates
808     SAP_Standard_Templates
809     All
812     Delete templates
813     Delete
814     Variant
815     Report
816     User
817     Or
818     to
819     Processing the option(s) you have selected may take some time.
820     Do you want to continue?
822     Display: All / unreferenced - templates
823     No Windows system. Log cannot be executed
824     Upload templates
825     Transport Template
826     Transport Request
827     CUS_STANDARD_TEMPLATES
828     SAP_STANDARD_TEMPLATES
829     Delete temporary ones
830     Delete unreferenced ones
841     Template cannot be deleted
842     Template can be deleted
843     Template cannot be deleted
899     An error occurred!
Selection Texts:
PA_ALL          All
PA_CUS          CUS_STANDARD_TEMPLATES
PA_DIS          List templates
PA_GUID         Delete templates
PA_LIST         Log
PA_SAP          SAP_STANDARD_TEMPLATES
PA_TMP          Temporary
PA_TRAPO        Transport Templates
PA_UNRF         Unreferenced
PA_UPLD         Import templates
SO_REP          Report Name
SO_USER         User name
SO_VRNT         Variant name
TRAPO           Transport Templates


*&---------------------------------------------------------------------*
*& Report  BCALV_BDS_MAINTENANCE                                       *
*&                                                                     *
*&---------------------------------------------------------------------*
*& Only use in the ALV-Context !!!!!!!!!!!!                            *
*&                                                                     *
*&---------------------------------------------------------------------*


report bcalv_bds_maintance .


class lcl_event_receiver definition deferred.


*--------------------------------------------------------
*                    general part
*--------------------------------------------------------

* data parameters
type-pools: sbdst,slis,icon,abap.
tables: t002.

constants: gc_classname(30)     value 'ALVLAYOUTTEMPLATES',
           gc_classtype(2)      value 'OT',
           gc_sap_template(30)  value 'SAP_STANDARD_TEMPLATE',
           gc_cus_template(30)  value 'CUS_STANDARD_TEMPLATE'.

data: begin of gs_display.
data: lights(4) type c.
        include structure disvariant.
        include structure lvc_s_bds.
data  end of gs_display.

data: gs_alv_bds                type lvc_s_bds,
      gs_alv_bds_check          type lvc_s_bds,
      gs_alv_bds_del            type lvc_s_bds,
      gs_alv_bds_tmp            type lvc_s_bds,
      gt_alv_bds                type lvc_t_bds,
      gt_alv_bds_check          type lvc_t_bds,
      gt_alv_bds_del            type lvc_t_bds,
      gt_alv_bds_choose         type lvc_t_bds,
      ea_bds_state              type bds_state,
      all_object_key            type bds_typeid,
      temp_object_key           type bds_typeid,
      cus_object_key            type bds_typeid,
      sap_object_key            type bds_typeid,
      g_object_key              type bds_typeid,
      gt_components             type sbdst_components,
      gs_components             type bapicompon,
      gt_signature              type sbdst_signature,
      gs_signature              type bapisignat,
      gt_files                  type sbdst_files,
      gs_files                  type bapifiles,
      gt_properties             type sbdst_properties,
      gs_properties             type bapiproper,
      gt_commfile_entries       type sbdst_commfile_entries,
      gs_commfile_entries       type bapicomfil,
      gt_e071                   type tr_objects,
      gs_e071                   type e071,
      gt_variant                type ltvariants,
      gs_variant                type ltvariant,
      gs_disvariant             type disvariant,
      gs_layout                 type lvc_s_layo,
      gt_fieldcat               type lvc_t_fcat,
      gs_fieldcat               type lvc_s_fcat,
      gs_filter                 type lvc_s_filt,
      gt_filter                 type lvc_t_filt,
      gt_sel_rows               type lvc_t_row,
      gs_sel_rows               type lvc_s_row,
      gs_cols                   type lvc_s_stbl,
      g_ref_to_cl_alv_variant   type ref to cl_alv_variant,
      g_ref_to_cl_bds_document  type ref to cl_bds_document_set,
      grid                      type ref to cl_gui_alv_grid,
      g_cus_container           type ref to cl_gui_custom_container,
      gr_to_lcl_event_receiver  type ref to lcl_event_receiver,
      g_tabix                   type sy-tabix,
      ok_code                   type sy-ucomm,
      save_ok_code              type sy-ucomm,
      ok_code_del               type sy-ucomm,
      save_ok_code_del          type sy-ucomm,
      gs_var_display            like gs_display,
      gt_alv_display            like gs_display occurs 0,
      gt_alv_display_new        like gs_display occurs 0,
      gt_alv_display_del        like gs_display occurs 0,
      gs_alv_display_del        like gs_display,
      gt_var_display            like gs_display occurs 0,
      temp_date                 type i,
      container(10)             type c,
      cb_unref(1)               type c,
      cb_temp(1)                type c,
      cb_checked(1)             type c,
      g_answer(1)               type c value '1',
      answer_to_show            type c value '1',
      del_flag(1)               type c value ' ',
      g_exit                    type c,
      gflg_find                 type c,
      refresh_flag(1)           type c,
      upld_sap                  type c value ' ',
      trapo_sap                 type c value ' ',
      cur_date                  type i,
      change_date               type i,
*      filename(30)           type c value '\maintenance_protokoll.xls',
*      dir(10)                   type c,
*      g_filename                like rlgrap-filename,
      filename                  type string,                "B5AK006349
      dir                       type string,                "B5AK006349
      g_filename                type string,                "B5AK006349
      winsys(2)                 type c value 'WN'.

"file save dialog >>B5AK006349
data:
  l_rstring(80)   type c,
  l_fname_rev(80) type c,
  l_fdir_rev(80)  type c,
  ret_val type i,
  l_user_action type i,
  s_title type string,
  s_mask type string,
  s_loc_fn type string,
  s_loc_dir type string,
  lt_file_table type filetable,
  ls_file_table type file_table,
  l_result type abap_bool.  "<>> Y7AK099270
* check selection-screen for chosen variants
          if not so_vrnt is initial
          or not so_rep is initial
          or not so_user is initial.

          translate so_vrnt to upper case.
          translate so_rep to upper case.
          translate so_user to upper case.


          gs_variant-variant = so_vrnt-low.
          gs_variant-report = so_rep-low.
          gs_variant-username = so_user-low.

          call method g_ref_to_cl_alv_variant->get_variant_from_db
            exporting
              is_variant  = gs_variant
            importing
              et_variants = gt_variant.

          loop at gt_variant into gs_variant.
            clear: gs_disvariant,gs_layout.
            move-corresponding gs_variant to gs_disvariant.
            call method g_ref_to_cl_alv_variant->get_variant_layo_from_db
              exporting
                is_variant = gs_disvariant
              importing
                es_layout  = gs_layout.

            if not gs_layout-object_key is initial.
              gs_alv_bds-object_key = gs_layout-object_key.
              append gs_alv_bds to gt_alv_bds_choose.

              clear gs_display.
              move-corresponding gs_disvariant to gs_display.
              move-corresponding gs_layout to gs_display.
              gs_display-client = sy-mandt.                 "B20K8A0MOD
              append gs_display to gt_var_display.
            else.                                           "B20K8A0N5B
              clear gs_display.                             "B20K8A0N5B
              move-corresponding gs_variant to gs_display.  "B20K8A0N5B
              gs_display-client = sy-mandt.                 "B20K8A0N5B
              append gs_display to gt_var_display.          "B20K8A0N5B
            endif.
          endloop.

        else.
*   check selection-screen for chosen templates
          all_object_key = '*'.
          temp_object_key(5) = '_200*'.
          cus_object_key = gc_cus_template.
          sap_object_key = gc_sap_template.

          if not pa_all is initial or not pa_unrf is initial.
*       ask in cause of performance
            call function 'POPUP_TO_DECIDE'
              exporting
               defaultoption           = '1'
                textline1               = text-819
               textline2               = text-820
*               TEXTLINE3               = text-821
                  text_option1            = text-803
                  text_option2            = text-804
*               ICON_TEXT_OPTION1       = ' '
*               ICON_TEXT_OPTION2       = ' '
                  titel                   = text-822
*               START_COLUMN            = 25
*               START_ROW               = 6
*               CANCEL_DISPLAY          = 'X'
             importing
               answer                  = answer_to_show.

            if answer_to_show = '1'.
              gs_alv_bds-object_key = all_object_key.
              append gs_alv_bds to gt_alv_bds_choose.
            else.
              exit.
            endif.

          else.
            if not pa_tmp is initial.
              gs_alv_bds-object_key(5) = temp_object_key.
              append gs_alv_bds to gt_alv_bds_choose.
            endif.
            if not pa_cus is initial.
              gs_alv_bds-object_key = cus_object_key.
              append gs_alv_bds to gt_alv_bds_choose.
            endif.
            if not pa_sap is initial.
              gs_alv_bds-object_key = sap_object_key.
              append gs_alv_bds to gt_alv_bds_choose.
            endif.
          endif.
          endif.                        "Y7AK099270
        endif.
      endif.                           " in case of upload

      if gt_alv_bds_choose is initial
      and gt_var_display is initial.
                                                            "B20K8A0N5B
        message i895(0k).
        exit.
      endif.

      clear: gs_alv_bds.
      loop at gt_alv_bds_choose into gs_alv_bds.
* get templates
*  get doc_id and object_key from BDS
*  REFRESH gt_alv_bds[].
        refresh: gt_components[], gt_signature[].
        call function 'ALV_BDS_GET_TEMPLATE'
          exporting
            i_classname              = gc_classname
            i_classtype              = gc_classtype
            i_object_key             = gs_alv_bds-object_key
            i_mimetype               = ' '
            i_ref_to_cl_bds_document = g_ref_to_cl_bds_document
          changing
            ct_alv_bds               = gt_alv_bds
            ct_components            = gt_components
            ct_signature             = gt_signature
          exceptions
            error_kpro               = 1
            internal_error           = 2
            nothing_found            = 3
            not_allowed              = 4
            not_authorized           = 5
            parameter_error          = 6
            others                   = 7.
        if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.
      endloop.


* only for layout inputs
      if not so_vrnt is initial or not so_rep is initial
         or not so_user is initial.

        clear gs_alv_bds-bds_deflt.
        loop at gt_alv_bds into gs_alv_bds.
          gs_alv_bds-bds_deflt = 'X'.
          modify gt_alv_bds from gs_alv_bds index sy-tabix
                                 transporting bds_deflt.
        endloop.

        loop at gt_alv_bds into gs_alv_bds.
          append gs_alv_bds to gt_alv_bds_check.
        endloop.
      endif.


* only for bds checkboxes
      if so_vrnt is initial and so_rep is initial and so_user is initial.
        call method g_ref_to_cl_alv_variant->get_variant_from_db
          exporting
            is_variant  = gs_variant
          importing
            et_variants = gt_variant.

*    get to every variant the layout
        loop at gt_variant into gs_variant.
          clear gs_disvariant.
          move-corresponding gs_variant to gs_disvariant.
          call method g_ref_to_cl_alv_variant->get_variant_layo_from_db
            exporting
              is_variant = gs_disvariant
            importing
              es_layout  = gs_layout.

          clear gs_alv_bds-bds_deflt.


          loop at gt_alv_bds into gs_alv_bds where
                             object_key = gs_layout-object_key.
            gs_alv_bds-bds_deflt = 'X'.
*    object_key exists then mark the record in the table gt_alv_bds
            modify gt_alv_bds from gs_alv_bds index sy-tabix
                                   transporting bds_deflt.
          endloop.

          clear gs_display.
          move-corresponding gs_disvariant to gs_display.
          move-corresponding gs_layout to gs_display.
          gs_display-client = sy-mandt.                     "B20K8A0MOD
          append gs_display to gt_var_display.
        endloop.


*     check checkboxes for chosen templates: unrefs / all
        loop at gt_alv_bds into gs_alv_bds_check.
          if not pa_all is initial.
            append gs_alv_bds_check to gt_alv_bds_check.

          else.

            if not gs_alv_bds_check-object_key(1) = '_'
            and not gs_alv_bds_check-object_key(4) cs 'SAP_'
            and not gs_alv_bds_check-object_key(4) cs 'CUS_'.
              check not pa_unrf is initial.
              if gs_alv_bds_check-bds_deflt is initial.
                append gs_alv_bds_check to gt_alv_bds_check.
              endif.
            endif.
            if gs_alv_bds_check-object_key(1) = '_'.
              check not pa_tmp is initial.
              append gs_alv_bds_check to gt_alv_bds_check.
            endif.
            if gs_alv_bds_check-object_key(4) cs 'CUS_'.
              check not pa_cus is initial.
              append gs_alv_bds_check to gt_alv_bds_check.
            endif.
            if gs_alv_bds_check-object_key(4) cs 'SAP_'.
              check not pa_sap is initial.
              append gs_alv_bds_check to gt_alv_bds_check.
            endif.
          endif.
        endloop.
      endif.

* for both
      loop at gt_alv_bds_check into gs_alv_bds.
        clear gs_display.
        move-corresponding gs_alv_bds to gs_display.
        append gs_display to gt_alv_display.
      endloop.

*   fill gt_alv_display
      loop at gt_alv_display into gs_display.
        g_tabix = sy-tabix.
        read table gt_var_display into gs_var_display with key
                   object_key = gs_display-object_key.
        if sy-subrc = 0.
          move-corresponding gs_var_display to gs_disvariant.
          move-corresponding gs_disvariant to gs_display.
          gs_display-bds_deflt  = 'X'.
          modify gt_alv_display from gs_display index g_tabix.
        endif.
      endloop.

*   delete all items from lt_var_display which have take place
*   in lt_alv_display
*************************************************************

      loop at gt_var_display into gs_display.
        g_tabix = sy-tabix.
*        if so_rep is initial
*        and so_vrnt is initial
*       and so_user is initial.                              "B20K8A0N5B
*          if not pa_all = 'X'.
        read table gt_alv_display into gs_var_display with key
                   object_key = gs_display-object_key.
        if sy-subrc ne 0.
          delete gt_var_display index g_tabix.
        endif.
*          endif.
*        endif.
                                                            "B20K8A0N5B
      endloop.

*****************************************************

*   fill lt_var_display-bds_deflt where frontend <> space and
*   object_key = space
      loop at gt_var_display into gs_display.
        if gs_display-frontend <> ' '.
          gs_display-bds_deflt = 'X'.
          modify gt_var_display from gs_display index sy-tabix.
        endif.
      endloop.

      append lines of gt_var_display to gt_alv_display.

      sort gt_alv_display by bds_deflt descending
                             report
                             object_key descending.



*  modify for lights to get templates without layout
      if pa_all = 'X'.
        loop at gt_alv_display into gs_var_display where
                         object_key = gs_layout-object_key.
          gs_var_display-bds_deflt = 'X'.
          modify gt_alv_display from gs_var_display index sy-tabix
                               transporting bds_deflt.
        endloop.
      endif.

*count records
      loop at gt_alv_display into gs_var_display.
        gs_var_display-doc_count = 1.
        modify gt_alv_display from gs_var_display index sy-tabix
                             transporting doc_count.
      endloop.



      if pa_upld is initial.
*  48 hours check and set lights
        loop at gt_alv_display into gs_var_display.
          clear: temp_date,cur_date,change_date.
          cur_date = sy-datum.
          change_date = gs_var_display-date_chang.
          temp_date = cur_date - change_date.

          if not gs_var_display-object_key(1) = '_'
          and gs_var_display-bds_deflt = 'X'.
            gs_var_display-lights = '1'.
          else.
            if gs_var_display-object_key(4) cs 'CUS_'
            or gs_var_display-object_key(4) cs 'SAP_'
            or gs_var_display-object_key(4) cs ' '.
*              gs_var_display-lights = '1'.                    "red
              gs_var_display-lights = '@[email protected]'.                  "YI3K111673
            else.
              if temp_date > '2'.
*                gs_var_display-lights = '3'.                  "green
                gs_var_display-lights = '@[email protected]'.                "YI3K111673
              endif.

              if temp_date <= '2'.
*                gs_var_display-lights = '2'.                  "yellow
                gs_var_display-lights = '@[email protected]'.                "YI3K111673
              endif.
            endif.
          endif.
          modify gt_alv_display from gs_var_display
                                      index sy-tabix.
        endloop.
      endif.

* add lights and tooltips instead of exceptions:  YI3K111673
      data: ls_fieldcat type lvc_s_fcat.
      ls_fieldcat-fieldname = 'LIGHTS'.
      ls_fieldcat-inttype   = 'C'.
      ls_fieldcat-datatype  = 'CHAR'.
      ls_fieldcat-intlen    = '40'.
      ls_fieldcat-icon      = 'X'.
      ls_fieldcat-scrtext_m = 'Exceptions'.
      ls_fieldcat-scrtext_s = 'Except.'.
      append ls_fieldcat to gt_fieldcat.

* fill fieldcatalog
      call function 'LVC_FIELDCATALOG_MERGE'
        exporting
*         I_BUFFER_ACTIVE              =
          i_structure_name             = 'LVC_S_BDS'
*         I_CLIENT_NEVER_DISPLAY       = 'X'
*         I_BYPASSING_BUFFER           =
        changing
           ct_fieldcat                 = gt_fieldcat.


      call function 'LVC_FIELDCATALOG_MERGE'
        exporting
*         I_BUFFER_ACTIVE              =
          i_structure_name             = 'DISVARIANT'
*         I_CLIENT_NEVER_DISPLAY       = 'X'
*         I_BYPASSING_BUFFER           =
        changing
          ct_fieldcat                  = gt_fieldcat.


      loop at gt_fieldcat into gs_fieldcat.
        gs_fieldcat-col_pos = sy-tabix.
        modify gt_fieldcat from gs_fieldcat index sy-tabix
                           transporting col_pos.
      endloop.

      clear gs_disvariant.
      gs_disvariant-variant = '/BDS'.
      gs_disvariant-report  = 'BCALV_BDS_MAINTENANCE'.

      gs_filter-fieldname = 'CLIENT'.
      gs_filter-sign      = 'I'.
      gs_filter-option    = 'EQ'.
      gs_filter-low       = sy-mandt.
      append gs_filter to gt_filter.

      call screen 100.

*  ----------------------------------------------------------------
*                          guid
*  ----------------------------------------------------------------

    when pa_guid.

      if pa_delr is initial and pa_delt is initial
      and pa_delc is initial and pa_dels is initial.
        message i894(0k).
        exit.
      endif.

* get templates
*  get doc_id and object_key from BDS
      refresh gt_alv_bds[].
      refresh: gt_components[], gt_signature[].
      call function 'ALV_BDS_GET_TEMPLATE'
        exporting
          i_classname              = gc_classname
          i_classtype              = gc_classtype
          i_object_key             = gs_alv_bds-object_key
          i_mimetype               = ' '
          i_ref_to_cl_bds_document = g_ref_to_cl_bds_document
        changing
          ct_alv_bds               = gt_alv_bds
          ct_components            = gt_components
          ct_signature             = gt_signature
        exceptions
          error_kpro               = 1
          internal_error           = 2
          nothing_found            = 3
          not_allowed              = 4
          not_authorized           = 5
          parameter_error          = 6
          others                   = 7.
      if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.

      call method g_ref_to_cl_alv_variant->get_variant_from_db
        exporting
          is_variant  = gs_variant
        importing
          et_variants = gt_variant.

*   get to every variant the layout
      loop at gt_variant into gs_variant.
        clear gs_disvariant.
        move-corresponding gs_variant to gs_disvariant.
        call method g_ref_to_cl_alv_variant->get_variant_layo_from_db
          exporting
            is_variant = gs_disvariant
          importing
            es_layout  = gs_layout.

        clear gs_alv_bds-bds_deflt.

        loop at gt_alv_bds into gs_alv_bds where
                           object_key = gs_layout-object_key.
          gs_alv_bds-bds_deflt = 'X'.
*  object_key exists then mark the record in the table gt_alv_bds
          modify gt_alv_bds from gs_alv_bds index sy-tabix
                                 transporting bds_deflt.
        endloop.
      endloop.

      sort gt_alv_bds by object_key.

      clear gt_alv_bds_del.

      loop at gt_alv_bds into gs_alv_bds.
        if pa_delc is initial.
          check not gs_alv_bds-object_key = gc_cus_template.
        else.
          if gs_alv_bds-object_key eq gc_cus_template.
            append gs_alv_bds to gt_alv_bds_del.
            continue.
          endif.
        endif.
        if pa_dels is initial.
          check not gs_alv_bds-object_key = gc_sap_template.
        else.
          if gs_alv_bds-object_key eq gc_sap_template.
            append gs_alv_bds to gt_alv_bds_del.
            continue.
          endif.
        endif.
* 48 h check before delete
        clear: temp_date,cur_date,change_date.
        cur_date = sy-datum.
        change_date = gs_alv_bds-date_chang.
        temp_date = cur_date - change_date.
        if temp_date > '2'.
          if pa_delr = ' ' or pa_delt = ' '.

            if pa_delt = ' ' and pa_delr = 'X'.
              check not gs_alv_bds-object_key(1) = '_'.
              if gs_alv_bds-bds_deflt is initial.
                append gs_alv_bds to gt_alv_bds_del.
              endif.
            endif.

            if pa_delr = ' ' and pa_delt = 'X'.
              check gs_alv_bds-object_key(1) = '_'.
              append gs_alv_bds to gt_alv_bds_del.
            endif.

          else.

            if not gs_alv_bds-object_key(1) = '_'.
              if gs_alv_bds-bds_deflt is initial.
                append gs_alv_bds to gt_alv_bds_del.
              endif.
            else.
              append gs_alv_bds to gt_alv_bds_del.
            endif.

          endif.
        endif.
      endloop.

      loop at gt_alv_bds_del into gs_alv_bds_del.
        gs_alv_bds_del-doc_count = sy-tabix.
        modify gt_alv_bds_del from gs_alv_bds_del index sy-tabix
                              transporting doc_count.
      endloop.

* form for popup and in case 'yes' call function bds_delete_template
      perform del_popup.

*      if g_answer = '1'.
*        message i896(0k) with gs_alv_bds_del-doc_count.
*      endif.
*
  endcase.

*--------------------------------------------------------------------
*                        endcase
*--------------------------------------------------------------------
  if g_answer <> '1'.   "Cancel on Del_POPUP
    exit.
  endif.

  if cb_unref = 'X' or cb_temp = 'X' or cb_checked = 'X'.
    del_flag = 'X'.
  endif.

* protokoll erstellen
  if pa_list = 'X'.
    if pa_guid = 'X' or del_flag = 'X'.

* check if not batch is activated
      if sy-batch is initial.

* check system --> windows

        data: l_platform type i.  ">>Y9DK011534
        call method cl_gui_frontend_services=>get_platform
          receiving
            platform     = l_platform
          exceptions
            error_no_gui = 1
            cntl_error   = 2
            others       = 3.
        if sy-subrc <> 0.
          message e000(0k) with
          'cl_gui_frontend_services=>get_platform failed'   "#EC NOTEXT
          raising error.
        else.
          if l_platform eq cl_gui_frontend_services=>platform_windows95
          or l_platform eq cl_gui_frontend_services=>platform_windows98
          or l_platform eq cl_gui_frontend_services=>platform_nt351
          or l_platform eq cl_gui_frontend_services=>platform_nt40
          or l_platform eq cl_gui_frontend_services=>platform_nt50.
          else.
            write: / text-823.           "// windows required
            exit.
          endif.
        endif.

        call method cl_gui_frontend_services=>get_temp_directory
          changing
            temp_dir             = dir
          exceptions
            cntl_error           = 1
            error_no_gui         = 2
*            NOT_SUPPORTED_BY_GUI = 3
            others               = 3.
        if sy-subrc <> 0.
          message id 'PC' type 'E' number 1.
          exit.
        endif.

        call method cl_gui_cfw=>flush
          exceptions
            cntl_system_error = 1
            cntl_error        = 2
            others            = 3.

        filename = 'maintenance_protokoll.xls'.
        call method cl_gui_frontend_services=>file_save_dialog
          exporting
            window_title         = s_title
*            DEFAULT_EXTENSION    = 'rpt'           "#EC NOTEXT
            default_file_name    = filename
            file_filter          = '*.XLS'
            initial_directory    = dir
          changing
            filename             = s_loc_fn
            path                 = s_loc_dir
            fullpath             = s_loc_dir
            user_action          = l_user_action
          exceptions
            cntl_error           = 1
            error_no_gui         = 2
*            NOT_SUPPORTED_BY_GUI = 3
            others               = 4.
        ret_val = 1.
        if l_user_action eq cl_gui_frontend_services=>action_cancel.
*          raise cancel.
          exit.
        endif.
        if sy-subrc <> 0 or ret_val = 0.
          raise error.
        endif.

        concatenate s_loc_dir '\' s_loc_fn into g_filename.

        data: l_filetype(10) type c.
        l_filetype = cl_gui_frontend_services=>filetype_excel.
        call method cl_gui_frontend_services=>gui_download
          exporting
*            BIN_FILESIZE            =
            filename                 = g_filename
            filetype                 = 'ASC'
*            APPEND                  = SPACE
            write_field_separator   = ';'
*            HEADER                  = '00'
*            TRUNC_TRAILING_BLANKS   = SPACE
*            WRITE_LF                = 'X'
*            COL_SELECT              = SPACE
*            COL_SELECT_MASK         = SPACE
*          IMPORTING
*            FILELENGTH              =
          changing
            data_tab                = gt_alv_bds_del
          exceptions
            file_write_error        = 1
            no_batch                = 2
            gui_refuse_filetransfer = 3
            invalid_type            = 4
            no_authority            = 5
            unknown_error           = 6
            header_not_allowed      = 7
            separator_not_allowed   = 8
            filesize_not_allowed    = 9
            header_too_long         = 10
            dp_error_create         = 11
            dp_error_send           = 12
            dp_error_write          = 13
            unknown_dp_error        = 14
            access_denied           = 15
            dp_out_of_memory        = 16
            disk_full               = 17
            dp_timeout              = 18
            file_not_found          = 19
            dataprovider_exception  = 20
            control_flush_error     = 21
*            NOT_SUPPORTED_BY_GUI    = 22
            others                  = 22.
        "< 0.
          message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        endif.
      else.

* write list in case of batch
        clear gs_alv_bds_del.
        loop at gt_alv_bds_del into gs_alv_bds_del.
          write: / gs_alv_bds_del-date_chang,
                   gs_alv_bds_del-time_chang,
                   gs_alv_bds_del-changed_by,
                   gs_alv_bds_del-date_creat,
                   gs_alv_bds_del-time_creat,
                   gs_alv_bds_del-created_by,
                   gs_alv_bds_del-object_key,
                   gs_alv_bds_del-filename,
                   gs_alv_bds_del-template.
        endloop.
      endif.
    else.
*     MESSAGE s892(0k).
    endif.
  endif.

*======================================================================*
*======================================================================*
*======================================================================*



*&---------------------------------------------------------------------*
*&        LOCAL CLASS LCL_EVENT_RECEIVER FOR TOOLBAR-BUTTON
*&---------------------------------------------------------------------*
*&                        DEFINITION
*&---------------------------------------------------------------------*
class lcl_event_receiver definition.
  public section.
    class-methods:

             handle_toolbar
                   for event toolbar of cl_gui_alv_grid
                   importing e_object
                             e_interactive,

             handle_menu_button
                   for event menu_button of cl_gui_alv_grid
                   importing e_object
                             e_ucomm,

             handle_user_command
                   for event user_command of cl_gui_alv_grid
                   importing e_ucomm.

  private section.
endclass.                    "lcl_event_receiver DEFINITION

*&---------------------------------------------------------------------*
*&        LOCAL CLASS LCL_EVENT_RECEIVER FOR TOOLBAR-BUTTON
*&---------------------------------------------------------------------*
*&                        IMPLEMENTATION
*&---------------------------------------------------------------------*
class lcl_event_receiver implementation.
  method: handle_toolbar.
    data: ls_toolbar     type stb_button,
          ls_trapo       type stb_button,
          ls_upload      type stb_button,
          l_allowed(1)   type C.           "Y7AK099270

*<<< Y7AK099270 check authorizations
    clear l_allowed.
    authority-check object 'S_BDS_DS'
                      ID  'CLASSNAME' FIELD 'ALVLAYOUTTEMPLATES'      "Y7AK108148
                      ID  'CLASSTYPE' FIELD 'OT'
                      ID  'ACTVT' FIELD '01'.     "Hinzuf�gen
    if sy-subrc eq 0.

      authority-check object 'S_BDS_DS'
                        ID  'CLASSNAME' FIELD 'ALVLAYOUTTEMPLATES'    "Y7AK108148
                        ID  'CLASSTYPE' FIELD 'OT'
                        ID  'ACTVT' FIELD '02'.     "�ndern
       if sy-subrc eq 0.

         authority-check object 'S_BDS_DS'
                          ID  'CLASSNAME' FIELD 'ALVLAYOUTTEMPLATES'  "Y7AK108148
                          ID  'CLASSTYPE' FIELD 'OT'
                          ID  'ACTVT' FIELD '06'.     "L�schen
         if sy-subrc eq 0.
           l_allowed = 'X'.
         endif.
       endif.
    endif.
*>>> Y7AK099270

    if not pa_upld is initial.
      if l_allowed eq 'X'.            "Y7AK099270
      clear ls_upload.
      move 3 to ls_upload-butn_type.
      append ls_upload to e_object->mt_toolbar.

      clear ls_upload.
      move 'UPLOAD' to ls_upload-function.
      move icon_import to ls_upload-icon.
      move 'Upload Templates'(824) to ls_upload-quickinfo.
      move 1 to ls_upload-butn_type.
      move space to ls_upload-disabled.
      append ls_upload to e_object->mt_toolbar.
      else.
        message i413(0K) with 'S_BDS_DS'.
      endif.                          "Y7AK099270
    endif.

*>>TRAPO
    if not pa_trapo is initial.
      clear ls_trapo.
      move 3 to ls_trapo-butn_type.
      append ls_trapo to e_object->mt_toolbar.

      clear ls_trapo.
      move 'TRAPO' to ls_trapo-function.
      move icon_transport to ls_trapo-icon.
      move 'Tranport Templates'(825) to ls_trapo-quickinfo.
      move 1 to ls_trapo-butn_type.
      move space to ls_trapo-disabled.
      append ls_trapo to e_object->mt_toolbar.
    endif.
*<mt_toolbar.

    clear ls_toolbar.
    move 'DELETE' to ls_toolbar-function.
    move icon_delete_row to ls_toolbar-icon.
    move 'Delete Templates'(812) to ls_toolbar-quickinfo.
    if pa_upld is initial.
      move 1 to ls_toolbar-butn_type.
      move space to ls_toolbar-disabled.
    endif.
    append ls_toolbar to e_object->mt_toolbar.
    endif.
  endmethod.                    "handle_toolbar

  method handle_menu_button.
    if e_ucomm = 'UPLOAD'.
      call method e_object->add_function
        exporting
          fcode = 'UPLOAD_CUS'
          text  = text-827. " cus-templates

      call method e_object->add_function
        exporting
          fcode = 'UPLOAD_SAP'
          text  = text-828. " sap-templates
    endif.
    if e_ucomm = 'DELETE'.
      call method e_object->add_function
        exporting
          fcode = 'DEL_TEMP'
          text  = text-829."alle temps l�schen

      call method e_object->add_function
        exporting
          fcode = 'DEL_UNREF'
          text  = text-830."alle unrefs l�schen
    endif.
*>>TRAPO
    if e_ucomm = 'TRAPO'.
      call method e_object->add_function
        exporting
          fcode = 'TRAPO_CUS'
          text  = text-827. " cus-templates

      call method e_object->add_function
        exporting
          fcode = 'TRAPO_SAP'
          text  = text-828. " sap-templates
    endif.
*<set_table_for_first_display
      exporting
        i_default       = 'X'
        i_save          = 'A'
        is_layout       = gs_layout
        is_variant      = gs_disvariant
        it_except_qinfo = gt_except_qinfo
      changing
        it_filter       = gt_filter
        it_fieldcatalog = gt_fieldcat
        it_outtab       = gt_alv_display.

    create object gr_to_lcl_event_receiver.
    set handler gr_to_lcl_event_receiver->handle_user_command for grid.
    set handler gr_to_lcl_event_receiver->handle_menu_button for grid.
    set handler gr_to_lcl_event_receiver->handle_toolbar for grid.

    call method grid->set_toolbar_interactive.
  else.
    if not refresh_flag is initial.
      clear refresh_flag.
      call method grid->refresh_table_display.
    endif.
  endif.
endmodule.                    "status_0100 OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*            FOR DISPLAY 100
*----------------------------------------------------------------------*
module user_command_0100 input.
  ok_code = sy-ucomm.
  save_ok_code = ok_code.
  clear ok_code.
  if save_ok_code = 'EXIT'.
    leave to screen 0.
  endif.
  call method cl_gui_cfw=>dispatch.
endmodule.                             " USER_COMMAND_0100  INPUT


*&---------------------------------------------------------------------*
*&      Form  del_popup
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form del_popup.

*<<< Y7AK099270 authorization check for deleting templates
 authority-check object 'S_BDS_DS'
                      ID  'CLASSNAME' FIELD 'ALVLAYOUTTEMPLATES'
                      ID  'CLASSTYPE' FIELD 'OT'
                      ID  'ACTVT' FIELD '06'.

  if sy-subrc ne 0.
     message i413(0K) with 'S_BDS_DS'.
     exit.
  endif.
*>>> Y7AK099270

  call function 'POPUP_TO_DECIDE'                   "#EC FB_OLDED
          exporting
            defaultoption           = '2'
     textline1               = text-801"Eintr�ge wirklich l�schen?
*         TEXTLINE2               = ' '
*         TEXTLINE3               = ' '
            text_option1            = text-803              "Ja
            text_option2            = text-804 "Nein
*         ICON_TEXT_OPTION1       = ' '
*         ICON_TEXT_OPTION2       = ' '
            titel                   = text-802 "L�schen
*         START_COLUMN            = 25
*         START_ROW               = 6
*         CANCEL_DISPLAY          = 'X'
          importing
            answer                  = g_answer.

  if not sy-batch is initial.
    g_answer = '1'.
  endif.

  if g_answer = '1'.
    loop at gt_alv_bds_del into gs_alv_bds.
      refresh gt_signature[].
      gs_signature-doc_id = gs_alv_bds-doc_id.
      append gs_signature to gt_signature.
      call function 'ALV_BDS_DELETE_TEMPLATE'
        exporting
          i_classname              = gc_classname
          i_classtype              = gc_classtype
          is_alv_bds               = gs_alv_bds
          i_ref_to_cl_bds_document = g_ref_to_cl_bds_document
        changing
          ct_signature             = gt_signature
        exceptions
          error_kpro               = 1
          internal_error           = 2
          nothing_found            = 3
          not_allowed              = 4
          not_authorized           = 5
          parameter_error          = 6
          others                   = 7.
      if sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endloop.
    message i896(0k) with gs_alv_bds_del-doc_count.
  endif.
endform.                               " del_popup
*&---------------------------------------------------------------------*
*&      Form  load_up
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form load_up.

*  set flag for refresh
  refresh_flag = 'X'.

*  ok_code = sy-ucomm.
*  save_ok_code = ok_code.
*  clear ok_code.
  if t002-spras is initial.
    t002-spras = sy-langu.
  endif.
  clear g_object_key.
  if upld_sap = 'X'.
    g_object_key = gc_sap_template.
  else.
    g_object_key = gc_cus_template.
  endif.

  gs_disvariant-username = 'SAP'.
  if not g_object_key is initial.
    call function 'ALV_BDS_LVC_OS_DLOG'
         exporting
              i_dlog_mode = 'O'
*                 I_MASK      =
*                 I_TITLE     =
         changing
              c_loc_dir   = gs_files-directory
              c_loc_fname = gs_files-filename
         exceptions
              cancel      = 1
              error       = 2
              others      = 3.
    if sy-subrc <> 0.
      case sy-subrc.
        when 1.
          message s000(0k) with text-004.
        when 2.
          message s000(0k) with text-005.
      endcase.
      exit.
    endif.

    clear g_exit.
    do 1 times.
      if upld_sap = 'X'.
        t002-spras = 'E'.
        check not gs_files-filename(4) cs 'SAP_'.
        message i409(0k). "Template falsch, nur SAP_ erl.'
        g_exit = 'X'.
      else.
        check not gs_files-filename(4) cs 'CUS_'.
        message i405(0k). "Template falsch, nur CUS_ erlaubt'
        g_exit = 'X'.
      endif.
    enddo.

    if g_exit = 'X'.
      exit.
    endif
    .
*       load values from BDS
    clear gflg_find.
    clear: gt_alv_bds[].
    clear: gt_components[],gt_signature[].
    call function 'ALV_BDS_GET_TEMPLATE'
      exporting
        i_classname              = gc_classname
        i_classtype              = gc_classtype
        i_object_key             = g_object_key
        i_mimetype               = ' '
        i_ref_to_cl_bds_document = g_ref_to_cl_bds_document
      changing
        ct_alv_bds               = gt_alv_bds
        ct_components            = gt_components
        ct_signature             = gt_signature
      exceptions
        error_kpro               = 1
        internal_error           = 2
        nothing_found            = 3
        not_allowed              = 4
        not_authorized           = 5
        parameter_error          = 6
        others                   = 7.

    if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.

*       create item
    refresh: gt_signature[], gt_files[].
    call function 'ALV_BDS_CREATE_ITEM'
      exporting
        is_files     = gs_files
        is_variant   = gs_disvariant
        i_language   = t002-spras
      importing
        es_alv_bds   = gs_alv_bds
        et_signature = gt_signature
        et_files     = gt_files.

*       compare existing item with new item
    loop at gt_alv_bds into gs_alv_bds_tmp.
      if gs_alv_bds_tmp-template cs gs_files-filename
         and gs_alv_bds_tmp-language = t002-spras.
        gflg_find = 'X'.
        exit.
      endif.
    endloop.
    clear gs_alv_bds_tmp.
    if gflg_find = 'X'.
      message i408(0k).
      exit.
    else.
*       Upload Template
      call function 'ALV_BDS_UPLOAD_TEMPLATE'
        exporting
          i_classname              = gc_classname
          i_classtype              = gc_classtype
          i_object_key             = g_object_key
          i_ref_to_cl_bds_document = g_ref_to_cl_bds_document
        importing
          es_alv_bds               = gs_alv_bds
        changing
          ct_signature             = gt_signature
          ct_files                 = gt_files
        exceptions
          error_kpro               = 1
          internal_error           = 2
          nothing_found            = 3
          not_allowed              = 4
          not_authorized           = 5
          parameter_error          = 6
          others                   = 7.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
          with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      else.
        message s403(0k). "Upload erfolgreich

*         change propertie bds_state f.e. test trapo
        clear gt_properties[].
        concatenate sy-sysid sy-saprl sy-mandt into ea_bds_state.
        gs_properties-prop_name  = 'BDS_STATE'.
        gs_properties-prop_value = ea_bds_state.
        append gs_properties to gt_properties.
        call function 'ALV_BDS_CHANGE_PROPERTIES'
          exporting
            i_classname           = gc_classname
            i_classtype           = gc_classtype
            is_alv_bds            = gs_alv_bds
            ir_to_cl_bds_document = g_ref_to_cl_bds_document
          changing
            ct_properties         = gt_properties
          exceptions
            error_kpro            = 1
            internal_error        = 2
            nothing_found         = 3
            not_allowed           = 4
            not_authorized        = 5
            parameter_error       = 6
            others                = 7.
        if sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.
      endif.
    endif.
    clear gs_display.
    move-corresponding gs_alv_bds to gs_display.
    append gs_display to gt_alv_display.
  endif.
  clear t002-spras.

* if trapo is activated
  if trapo = 'X'.
    create object g_ref_to_cl_alv_variant.
    gs_layout-object_key = g_object_key.
    call method g_ref_to_cl_alv_variant->bds_transport
      exporting
        is_variant          = gs_disvariant
        is_layout           = gs_layout
      changing
        ct_commfile_entries = gt_commfile_entries.
    loop at gt_commfile_entries into gs_commfile_entries.
      gs_e071-trkorr     = gs_commfile_entries-trkorr.
*          gs_e071-trkorr     = 'CUST'.
      gs_e071-as4pos     = gs_commfile_entries-as4pos.
      gs_e071-pgmid      = gs_commfile_entries-pgmid.
      gs_e071-object     = gs_commfile_entries-object.
      gs_e071-obj_name   = gs_commfile_entries-obj_name.
      gs_e071-objfunc    = gs_commfile_entries-objfunc.
      gs_e071-lockflag   = gs_commfile_entries-lockflag.
      gs_e071-gennum     = gs_commfile_entries-gennum.
      append gs_e071 to gt_e071.
    endloop.
    call function 'TR_REQUEST_CHOICE'
         exporting
*                 iv_suppress_dialog   = ' '
              iv_request_types     = 'W'
*                 iv_request           = ' '
              it_e071              = gt_e071
*                  it_e071k             = lt_e071k
*            IMPORTING
*                 es_request           =
         exceptions
              others               = 1.
    if sy-subrc <> 0.
      message id sy-msgid type sy-msgty number sy-msgno
      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
  endif.


endform.                               " load_up
*&---------------------------------------------------------------------*
*&      Form  sel_del_templates
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form sel_del_templates.

data: l_allowed(1) type C.        "Y7AK099270

  save_ok_code_del = ok_code_del.
  clear ok_code_del.

  clear: gt_alv_display_del,gt_alv_bds_del,
               gt_sel_rows,gs_sel_rows,
               gt_alv_display_new.


*<<< Y7AK099270 check authorization
  clear l_allowed.
  authority-check object 'S_BDS_DS'
                    ID  'CLASSNAME' FIELD 'ALVLAYOUTTEMPLATES'        "Y7AK108148
                    ID  'CLASSTYPE' FIELD 'OT'
                    ID  'ACTVT' FIELD '06'.     "Hinzuf�gen
  if sy-subrc eq 0.

      authority-check object 'S_BDS_DS'
                        ID  'CLASSNAME' FIELD 'ALVLAYOUTTEMPLATES'    "Y7AK108148
                        ID  'CLASSTYPE' FIELD 'OT'
                        ID  'ACTVT' FIELD '02'.     "�ndern
      if sy-subrc eq 0.
         l_allowed = 'X'.
      endif.
  endif.

  if l_allowed = 'X'.
    case save_ok_code_del.

    when 'DELETE'.

*      set flag for refresh
      refresh_flag = 'X'.

      call method grid->get_selected_rows
        importing
          et_index_rows = gt_sel_rows.

      loop at gt_sel_rows into  gs_sel_rows.
        read table gt_alv_display into gs_var_display index
                                         gs_sel_rows-index.
        if ( sy-subrc ne 0 ).
          message x000(0k) with
            'Table Entry not found, fatal!'.                "#EC NOTEXT
        endif.

        if not pa_upld is initial.     " check if not upload is initial
          append gs_var_display to gt_alv_display_del.
          gs_var_display-bds_del = 'X'.
          modify gt_alv_display from gs_var_display
                                index gs_sel_rows-index
                                transporting bds_del.
        else.
          check not gs_var_display-object_key(4) cs 'CUS_'.
          check not gs_var_display-object_key(4) cs 'SAP_'.
          if gs_var_display-object_key(1) = '_'.
            append gs_var_display to gt_alv_display_del.
            gs_var_display-bds_del = 'X'.
            modify gt_alv_display from gs_var_display
                                  index gs_sel_rows-index
                                  transporting bds_del.
          else.
            if gs_var_display-bds_deflt is initial.
              append gs_var_display to gt_alv_display_del.
              gs_var_display-bds_del = 'X'.
              modify gt_alv_display from gs_var_display
                                    index gs_sel_rows-index
                                    transporting bds_del.
            endif.
          endif.
        endif.
      endloop.

    when 'DEL_TEMP'.

      refresh_flag = 'X'.
      loop at gt_alv_display into gs_var_display.
        check not gs_var_display-object_key(4) cs 'CUS_'.
        check not gs_var_display-object_key(4) cs 'SAP_'.
        if gs_var_display-object_key(1) = '_'.
          append gs_var_display to gt_alv_display_del.
          gs_var_display-bds_del = 'X'.
          modify gt_alv_display from gs_var_display
                                transporting bds_del.
        endif.
      endloop.

    when 'DEL_UNREF'.

      refresh_flag = 'X'.
      loop at gt_alv_display into gs_var_display.
        check not gs_var_display-object_key(4) cs 'CUS_'.
        check not gs_var_display-object_key(4) cs 'SAP_'.
        check not gs_var_display-object_key(1) = '_'.
        if gs_var_display-bds_deflt is initial.
          append gs_var_display to gt_alv_display_del.
          gs_var_display-bds_del = 'X'.
          modify gt_alv_display from gs_var_display
                                transporting bds_del.
        endif.
      endloop.

  endcase.
  else.                       "Y7AK099270
    message i413(0K) with 'S_BDS_DS'.
    exit.
  endif.                      "Y7AK099270

* had to loop to use form del_popup
  loop at gt_alv_display_del into gs_alv_display_del.
    move-corresponding gs_alv_display_del to gs_alv_bds_del.
    append gs_alv_bds_del to gt_alv_bds_del.
  endloop.

  perform del_popup.

  clear gs_alv_bds_del-doc_count.
  loop at gt_alv_bds_del into gs_alv_bds_del.
    gs_alv_bds_del-doc_count = sy-tabix.
    modify gt_alv_bds_del from gs_alv_bds_del index sy-tabix
                          transporting doc_count.
  endloop.

  if g_answer = '1'.
    message s896(0k) with gs_alv_bds_del-doc_count.
  endif.

  loop at gt_alv_display into gs_var_display.
    if gs_var_display-bds_del is initial.
      append gs_var_display to gt_alv_display_new.
    else.
      if g_answer ne '1'.   "Cancel on DelPopup
        clear gs_var_display-bds_del.
        append gs_var_display to gt_alv_display_new.
      endif.
    endif.
  endloop.

  clear: gs_var_display,gt_alv_display.
  loop at gt_alv_display_new into gs_var_display.
    append gs_var_display to gt_alv_display.
  endloop.

endform.                               " sel_del_templates
*&---------------------------------------------------------------------*
*&      Form  modify_fieldcat
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form modify_fieldcat.
  data: ls_fieldcat type lvc_s_fcat.

  ls_fieldcat-no_out = 'X'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'DOC_ID'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'DOC_VER_NO'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'DOC_VAR_ID'.
  clear ls_fieldcat-no_out.
  clear ls_fieldcat-no_sum.
  ls_fieldcat-do_sum = 'X'.
  modify gt_fieldcat from ls_fieldcat transporting no_out no_sum do_sum
                     where fieldname = 'DOC_COUNT'.
  clear ls_fieldcat.
  ls_fieldcat-no_out = 'X'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'FILENAME'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'COMP_COUNT'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'COMP_ID'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'DIRECTORY'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'MIMETYPE'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'COLOR'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'PROP_NAME'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'PROP_VALUE'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'PROP_NAME1'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'PROP_VALU1'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'URI'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'BDS_DEFLT'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'BDS_DEL'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'BDS_STATE'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'BYTESIZE'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'EXTOBJID'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'HANDLE'.
*  modify gt_fieldcat from ls_fieldcat transporting no_out  B20K8A0N5B
*                     where fieldname = 'REPORT'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'LOG_GROUP'.
  modify gt_fieldcat from ls_fieldcat transporting no_out
                     where fieldname = 'DEPENDVARS'.
endform.                    " modify_fieldcat
*&---------------------------------------------------------------------*
*&      Form  trapo
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form trapo.

*  set flag for refresh
  refresh_flag = 'X'.

*  ok_code = sy-ucomm.
*  save_ok_code = ok_code.
*  clear ok_code.
  if t002-spras is initial.
    t002-spras = sy-langu.
  endif.
  clear g_object_key.
  if trapo_sap = 'X'.
    g_object_key = gc_sap_template.
  else.
    g_object_key = gc_cus_template.
  endif.

*       load values from BDS
  clear gflg_find.
  clear: gt_alv_bds[].
  clear: gt_components[],gt_signature[].
  call function 'ALV_BDS_GET_TEMPLATE'
    exporting
      i_classname              = gc_classname
      i_classtype              = gc_classtype
      i_object_key             = g_object_key
      i_mimetype               = ' '
      i_ref_to_cl_bds_document = g_ref_to_cl_bds_document
    changing
      ct_alv_bds               = gt_alv_bds
      ct_components            = gt_components
      ct_signature             = gt_signature
    exceptions
      error_kpro               = 1
      internal_error           = 2
      nothing_found            = 3
      not_allowed              = 4
      not_authorized           = 5
      parameter_error          = 6
      others                   = 7.

  if sy-subrc <> 0.
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*       WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

  create object g_ref_to_cl_alv_variant.
  gs_layout-object_key = g_object_key.
  call method g_ref_to_cl_alv_variant->bds_transport
    exporting
      is_variant          = gs_disvariant
      is_layout           = gs_layout
    changing
      ct_commfile_entries = gt_commfile_entries.
  loop at gt_commfile_entries into gs_commfile_entries.
*<<< Y7AK097512
*    gs_e071-trkorr     = gs_commfile_entries-trkorr.
**        gs_e071-trkorr     = 'CUST'.
*    gs_e071-as4pos     = gs_commfile_entries-as4pos.
*    gs_e071-pgmid      = gs_commfile_entries-pgmid.
*    gs_e071-object     = gs_commfile_entries-object.
*    gs_e071-obj_name   = gs_commfile_entries-obj_name.
*    gs_e071-objfunc    = gs_commfile_entries-objfunc.
*    gs_e071-lockflag   = gs_commfile_entries-lockflag.
*    gs_e071-gennum     = gs_commfile_entries-gennum.
*    append gs_e071 to gt_e071.

    call function 'TR_OBJECT_CHECK'
      exporting
        wi_ko200                      = gs_commfile_entries
      exceptions
        cancel_edit_other_error       = 1
        show_only_other_error         = 2
        others                        = 3.

    IF sy-subrc <> 0.
      message id sy-msgid type sy-msgty number sy-msgno
      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
  endloop.
*  call function 'TR_REQUEST_CHOICE'
*       exporting
**               iv_suppress_dialog   = ' '
*            iv_request_types     = 'W'
**               iv_request           = ' '
*            it_e071              = gt_e071
**                it_e071k             = lt_e071k
**          IMPORTING
**               es_request           =
*       exceptions
*            others               = 1.

  call function 'TR_OBJECTS_INSERT'
    tables
      wt_ko200                      = gt_commfile_entries
    exceptions
      cancel_edit_other_error       = 1
      show_only_other_error         = 2
      others                        = 3.
*>>> Y7AK097512
  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.

endform.                    "trapo
*&---------------------------------------------------------------------*
*&      Form  SET_TOOLTIPS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form set_tooltips .

*YI3K111673
data: ls_except_qinfo type LVC_S_QINF.

*fill toolteps for exceptions:
   clear ls_except_qinfo.
   ls_except_qinfo-type = cl_salv_tooltip=>C_TYPE_ICON.  "2
   ls_except_qinfo-fieldname = 'LIGHTS'.
   ls_except_qinfo-value = '@[email protected]'.                          "red
   ls_except_qinfo-text = text-841.
   append ls_except_qinfo to gt_except_qinfo.

   clear ls_except_qinfo.
   ls_except_qinfo-type = cl_salv_tooltip=>C_TYPE_ICON.
   ls_except_qinfo-fieldname = 'LIGHTS'.
   ls_except_qinfo-value = '@[email protected]'.                          "green
   ls_except_qinfo-text = text-842.
   append ls_except_qinfo to gt_except_qinfo.

   clear ls_except_qinfo.
   ls_except_qinfo-type = cl_salv_tooltip=>C_TYPE_ICON.
   ls_except_qinfo-fieldname = 'LIGHTS'.
   ls_except_qinfo-value = '@[email protected]'.                          "yellow
   ls_except_qinfo-text = text-843.
   append ls_except_qinfo to gt_except_qinfo.
endform.                    " SET_TOOLTIPS

Add comment

Before Buying, Compare Prices at Topprice.in

Topprice.in