SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Mass delete reports



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP Dictionary
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Wed Oct 31, 2012 10:04 am    Post subject: Mass delete reports Reply with quote

Code:
* This abap reports mass delete is useful if you have lots of unwanted
* program to clean up.
*
* Create a Menu Status 'STANDARD' with the fields
* BACK and DELE
*
* You have to protect this program either by authorization or hardcoded
* user name checks.
*
report zmass_delete_reports.

tables: trdir, trdirt.

type-pools: slis.
data: gt_fieldcat type slis_t_fieldcat_alv with header line,
      gs_layout type slis_layout_alv,
      g_repid like sy-repid.

types: begin of st_output,
        marca(1),
        name  like trdir-name,
        subc  like trdir-subc,
        cnam  like trdir-cnam,
        cdat  like trdir-cdat,
        text  like trdirt-text,
       end of st_output.

data: gt_output type standard table of st_output with header line.
data: alv_events   type slis_t_event.

selection-screen begin of line.
selection-screen comment (35) comment1.
select-options   s_name  for trdir-name OBLIGATORY.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment (35) comment2.
select-options   s_subc  for trdir-subc.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment (35) comment3.
select-options   s_cnam  for trdir-cnam.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment (35) comment4.
select-options   s_cdat  for trdir-cdat.
selection-screen end of line.

initialization.
  comment1 = 'ABAP Program Name'.
  comment2 = 'Program Type'.
  comment3 = 'Author'.
  comment4 = 'Created on'.

  g_repid = sy-repid.


start-of-selection.
  if sy-uname <> 'XXXX'.
     WRITE: 'You are not authorized to run this report', sy-uname.
     exit.
  endif.

  perform toma_datos.

  perform init_fieldcat.
  perform init_layout.
  perform alv_build_eventtab using alv_events[].

  perform listado.


form init_fieldcat.

  gt_fieldcat-fieldname = 'MARCA'.
  gt_fieldcat-ref_tabname = ''.
  gt_fieldcat-input = 'X'.
  gt_fieldcat-checkbox = 'X'.
  gt_fieldcat-outputlen = 3.
  append gt_fieldcat. clear gt_fieldcat.

  gt_fieldcat-fieldname = 'NAME'.
  gt_fieldcat-ref_tabname = 'TRDIR'.
  append gt_fieldcat. clear gt_fieldcat.

  gt_fieldcat-fieldname = 'SUBC'.
  gt_fieldcat-ref_tabname = 'TRDIR'.
  append gt_fieldcat. clear gt_fieldcat.

  gt_fieldcat-fieldname = 'CNAM'.
  gt_fieldcat-ref_tabname = 'TRDIR'.
  append gt_fieldcat. clear gt_fieldcat.

  gt_fieldcat-fieldname = 'CDAT'.
  gt_fieldcat-ref_tabname = 'TRDIR'.
  append gt_fieldcat. clear gt_fieldcat.

endform.

form init_layout.

  gs_layout-zebra = 'X'.
  gs_layout-f2code = '&ETA'.
  gs_layout-detail_popup = 'X'.

endform.


form toma_datos.

  select * from trdir
    into corresponding fields of table  gt_output
   where name in s_name
     and subc in s_subc
     and cnam in s_cnam
     and cdat in s_cdat.

  loop at gt_output.
    select single text from trdirt
      into gt_output-text
     where name  = gt_output-name
       and sprsl = sy-langu.
    modify gt_output.
  endloop.
endform.

form listado.

  call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
*   I_INTERFACE_CHECK              = ' '
*   I_BYPASSING_BUFFER             =
*   I_BUFFER_ACTIVE                = ''
    i_callback_program             = g_repid
*_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_STRUCTURE_NAME =
    is_layout                      = gs_layout
    it_fieldcat                    = gt_fieldcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
 it_events = alv_events[]
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
tables      t_outtab                       = gt_output    exceptions
  program_error                  = 1
  others                         = 2            .

  if sy-subrc ne 0.
    message id sy-msgid type sy-msgty number sy-msgno            with
   sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.
endform.                    " LISTADO


form build_comment using p_heading type slis_t_listheader.
  data: hline type slis_listheader,
        text(60) type c,
        sep(20) type c.
  clear: hline, text.
  hline-typ  = 'H'.
  write: 'List of Pending Deliveries' to text+05.
  hline-info = text.
  append hline to p_heading.
  clear text.
  write: 'User: ' to text,
         sy-uname to text+9,
         'Date: ' to text+30,
         sy-datum to text+37,
         'Page: ' to text+50,
         sy-pagno to text+56.
  hline-info = text.
  append hline to p_heading.

endform.                    " BUILD_COMMENT


form alv_build_eventtab using p_events type slis_t_event.
  data: ls_event type slis_alv_event.
  call function 'REUSE_ALV_EVENTS_GET'
       exporting
            i_list_type = 0
       importing
            et_events   = p_events.
  read table p_events with key name = slis_ev_top_of_page
                           into ls_event.
  if sy-subrc = 0.
    move slis_ev_top_of_page to ls_event-form.
    modify p_events from ls_event index sy-tabix.
  endif.


  read table p_events with key name = slis_ev_pf_status_set
                           into ls_event.
  if sy-subrc = 0.
    move slis_ev_pf_status_set to ls_event-form.
    modify p_events from ls_event index sy-tabix.
  endif.

  read table p_events with key name = slis_ev_user_command
                           into ls_event.
  if sy-subrc = 0.
    move slis_ev_user_command to ls_event-form.
    modify p_events from ls_event index sy-tabix.
  endif.

endform.                               " BUILD_EVENTTAB

form pf_status_set
   using pu_tab_excl_okcode type slis_t_extab.

  set pf-status 'STANDARD' excluding pu_tab_excl_okcode.

endform.

form user_command
  using pu_okcode type syucomm
        pu_selfield type slis_selfield.

  case pu_okcode.
    when 'DELE'.
      loop at gt_output where marca = 'X'.
        delete report gt_output-name.
        write:/ 'Report deleted ', gt_output-name.
      endloop.

    when 'DISP'.
      read table gt_output index pu_selfield-tabindex.
      if sy-subrc = 0.
      endif.
  endcase.
endform.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP Dictionary All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.