Program to download all the programs present in a Package (Dev. Class) to desktop

By Saikumar Bhagavatula, IBM India

*&--------------------------------------------------------------------*
*& Program To Download All The Programs Present In A Package (Dev. Class) To Desktop
*&--------------------------------------------------------------------*
REPORT  z_downloadall_to_desktop.
***********************************************************************
*                           Table declaration                         *
***********************************************************************
TABLES: tadir.
***********************************************************************
*                           Data declaration                          *
***********************************************************************
TYPES: abapline(255) TYPE c.
TYPES: BEGIN OF ty_reposit,
         pgmid    TYPE tadir-pgmid,
         object   TYPE tadir-object,
         obj_name TYPE tadir-obj_name,
         devclass TYPE tadir-devclass,
      END OF ty_reposit.
DATA: it_reposit TYPE STANDARD TABLE OF ty_reposit,
      wa_reposit TYPE ty_reposit.
DATA: it_repsrc TYPE STANDARD TABLE OF abapline,
      wa_repsrc TYPE abapline.
DATA: prog(60)    TYPE c,
      mc_filename TYPE rlgrap-filename,
      filename    TYPE string.
***********************************************************************
*                           Selection Screen                          *
***********************************************************************
PARAMETERS: p_dev TYPE tadir-devclass.                    "Package Name
*****Program Logic
SELECT pgmid
       object
       obj_name
       devclass
  FROM tadir
  INTO TABLE it_reposit
  WHERE pgmid    = 'R3TR' AND
        object   = 'PROG' AND
        devclass = p_dev. 
IF sy-subrc NE 0.
  MESSAGE s001(00) WITH 'No programs available in the given package'.
  EXIT.
ENDIF.
LOOP AT it_reposit INTO wa_reposit.
  prog = wa_reposit-obj_name.
  READ REPORT prog INTO it_repsrc.
  CONCATENATE 'C:\Documents and Settings\Administrator\Desktop\My ABAP Programs\Report'
              prog
              '.txt'
         INTO mc_filename.
  filename = mc_filename.
*****Function module for download files into local system
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                = filename
    TABLES
      data_tab                = it_repsrc
    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
      OTHERS                  = 22.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  CLEAR prog.
  CLEAR wa_repsrc.
ENDLOOP.
*****After download all the programs to intimate user.
MESSAGE s001(00) WITH 'Check your folder for the Programs downloaded'.

Selection Screen: 

 

Enter your Package Name here and press ‘F8’ (Execute). 

After Execution:  

Now on the Desktop, it creates a Folder “My ABAP Programs”. In this package it saves all your programs that were created in that package in text format (.txt).

These saved reports will be prefixed with name ‘Report’. 

For example, Report<Program Name>.txt will be created.

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image