Browse files on SAP Application Server(UNIX)

When looking at/for files on the application server(UNIX) using AL11 you are restricted to only certian directories. The following ABAP program displays all files/directories on the application server(UNIX). Simple copy and paste the following code into a new ABAP report program. Note will also need to created the following report which displays the actual file ZBROWSEFILE.


*---------------------------------------------------------------------*
* Topic:           File Manager for UNIX environment                  *
*                                                                     *
* Description:     With internal system command you can get access to *
*                  the UNIX. The program list files in the Unix       *
*                  environment and by using at line selecttion you are*
*                  able to browse datasets.                           *
*                                                                     *
* Authorization:   None, be careful you have unlimited access to Unix.*
*                  Check that you are able to use the internal system *
*                  command.                                           *
*                                                                     *
* Parameters:       Filename and path.                                *
*                                                                     *
* Change of        Check that you are able to use the internal system *
* release          command.                                           *
*                                                                     *
* Release:         4.6b                                               *
*                                                                     *
***********************************************************************

REPORT ZUNIXFILES MESSAGE-ID Z1
                  NO STANDARD PAGE HEADING
                  LINE-COUNT 65
                  LINE-SIZE  132.
*---------------------------------------------------------------------*
* Global Variables.                                                   *
*---------------------------------------------------------------------*
DATA: BEGIN OF TABL OCCURS 0,
          LINE(2000),
      END OF TABL.
DATA: PARCOM_LOC LIKE RS37A-LINE.
DATA: SIZE(10) TYPE C,
      LINE     LIKE TABL-LINE,
      SUM(16)  TYPE C.
DATA: FILE LIKE RS37A-LINE.
DATA: PATH(255) TYPE C.
*-------------------------------------------------------------------*
* Parameters.                                                       *
*-------------------------------------------------------------------*
SELECTION-SCREEN SKIP 2.
PARAMETERS: PARCOM LIKE RS37A-LINE.
*********************************************************************
*AT SELECTION-SCREEN.
AT SELECTION-SCREEN.
  CONDENSE: PARCOM NO-GAPS.
*********************************************************************
*TOP-OF-PAGE.
TOP-OF-PAGE.
  PERFORM WRITE_PAGE_HEADING.
*********************************************************************
*INITIALIZATION.
INITIALIZATION.
  PARCOM = '/usr/sap/*'.               "Only default value
*********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
  PERFORM MAKE_LOC.
  PERFORM COLLECT_DATA.
  PERFORM FILE_LIST.
*********************************************************************
*AT LINE-SELECTION.
AT LINE-SELECTION.
  CLEAR FILE.
  FILE = SY-LISEL+55.
  REPLACE '|' WITH SPACE INTO FILE.
  IF SY-LISEL+1(1) = 'd'.
     PATH = FILE.
     PATH+200 = '/*'.
     CONDENSE PATH NO-GAPS.
     SUBMIT ZUNIXFILES
       WITH PARCOM = PATH
       AND RETURN.
  ENDIF.
  SUBMIT ZBROWSEFILE            "Call the browse program
     WITH PARCOM = FILE
     AND RETURN.
*---------------------------------------------------------------------*
* FORM MAKE_LOC.                                                      *
*---------------------------------------------------------------------*
FORM MAKE_LOC.
  CLEAR: PARCOM_LOC.
  PARCOM_LOC(7)    = 'ls -ld '.
  PARCOM_LOC+7(45) = PARCOM.
ENDFORM.
*---------------------------------------------------------------------*
* FORM COLLECT_DATA.                                                  *
*---------------------------------------------------------------------*
FORM COLLECT_DATA.
  REFRESH TABL.
  CALL 'SYSTEM' ID 'COMMAND' FIELD PARCOM_LOC
                ID 'TAB'     FIELD TABL-*SYS*.
ENDFORM.
*-------------------------------------------------------------------*
* FORM FILE_LIST.                                                   *
*-------------------------------------------------------------------*
FORM FILE_LIST.
  FORMAT RESET.
  CLEAR SUM.
  LOOP AT TABL.
    CLEAR LINE.
    LINE = TABL-LINE.
    WRITE /2 LINE.
    PERFORM VERTICAL_LINES.
    SUM = SUM + SIZE.
  ENDLOOP.
  WRITE:/1(132) SY-ULINE.
ENDFORM.
*-------------------------------------------------------------------*
* FORM WRITE_PAGE_HEADING.                                          *
*-------------------------------------------------------------------*
FORM WRITE_PAGE_HEADING.
  WRITE:/1(132) SY-ULINE.
  PERFORM VERTICAL_LINES.
  FORMAT INTENSIFIED.
  WRITE: /2(131) SPACE COLOR 1.
  WRITE:  2    SY-DATUM COLOR 1.
  WRITE: 35 'File Manager' COLOR 1.
  PERFORM VERTICAL_LINES.
  WRITE:/1(132) SY-ULINE.
  PERFORM VERTICAL_LINES.
  FORMAT INTENSIFIED.
  WRITE: /2(131) SPACE  COLOR 3.
  PERFORM VERTICAL_LINES.
  FORMAT RESET.
  WRITE:/1(132) SY-ULINE.
ENDFORM.
*-------------------------------------------------------------------*
* FORM VERTICAL_LINES.                                              *
*-------------------------------------------------------------------*
FORM VERTICAL_LINES.
  PERFORM WRITE_VLINE USING ' '  1.
  PERFORM WRITE_VLINE USING ' '  132.
ENDFORM.
*-------------------------------------------------------------------*
* WRITE_VLINE.                                                      *
*-------------------------------------------------------------------*
FORM WRITE_VLINE USING MODE POS.
  IF MODE NE 'T'.
    FORMAT INTENSIFIED.
  ENDIF.
  POSITION POS.
  WRITE: SY-VLINE.
  IF MODE NE 'T'.
    FORMAT RESET.
  ENDIF.
ENDFORM.

Related Articles

SAP applications and ABAP reports that process data files stored on your PC or within SAP
HEX codes and there associated ABAP declaration within SAP
Display files on SAP Application Server(UNIX)
Downloading files to PC(Presentation Server)
Downloading files to SAP Application Server
Popup window to select a File using function module WS_FILENAME_GET
Get list of files within specific directory or SAP Application server
Directory selection for ABAP report using SAP method DIRECTORY_BROWSE
File Selection for ABAP report using SAP object method FILE_OPEN_DIALOG
Save file location popup on ABAP report selection screen using FILE_SAVE_DIALOG
ABAP Upload and download Function Modules in SAP
SAP File Selection Window - various methods of adding a file selection popup to your ABAP report
Upload Tab delimited file from PC into ABAP internal table
Upload and download files into and out of SAP or your PC
ABAP to check if file exists before downloading from SAP
SAP Upload Excel document into internal table
ABAP to Upload Excel document into internal table on SAP system including .xlsx
Upload Excel document into ABAP internal table
ABAP Uploading files from PC to SAP R/3 system
ABAP to Upload files from SAP Application Server
Upload Tab delimited file from PC into ABAP internal table
Upload Tab delimited file from application server into ABAP internal table
Example Excel Spreadsheet used to demo SAP upload and download using ABAP
Download file from SAP unix system to your desktop using transaction SXDA