REPORT ZZBGSFMA MESSAGE-ID Z1
                NO STANDARD PAGE HEADING
                LINE-COUNT 65
                LINE-SIZE  132.
*---------------------------------------------------------------------*
* 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.*
*                                                                     *
* Customizing:     No need for customization.                         *
*                                                                     *
* Parametre:       Filename and path.                                 *
*                                                                     *
* Change of        Check that you are able to use the internal system *
* release          command.                                           *
*                                                                     *
* Release:         3.0F                                               *
*                                                                     *
* Programmør:      JBL/BGS                                            *
*                                                                     *
*---------------------------------------------------------------------*

*---------------------------------------------------------------------*
* Global Variables.                                                   *
*---------------------------------------------------------------------*
DATA: BEGIN OF TABL OCCURS 0,
          LINE(2000),
      END OF TABL.

DATA: PARCOM_LOC(100) TYPE C.

*
DATA: NAME(45) TYPE C,
      SIZE(10) TYPE C,
      DATE(12) TYPE C,
      OFFSET   LIKE SY-FDPOS,
      LINE     LIKE TABL-LINE,
      SUM(16)  TYPE C.

DATA: FILE(45) TYPE C.
FIELD-SYMBOLS: <FIELD>.

*-------------------------------------------------------------------*
* Parameters.                                                       *
*-------------------------------------------------------------------*
SELECTION-SCREEN SKIP 2.
PARAMETERS: PARCOM(45) TYPE C LOWER CASE.

*-------------------------------------------------------------------*
* Validate parameter.                                               *
*-------------------------------------------------------------------*
AT SELECTION-SCREEN.
  CONDENSE: PARCOM NO-GAPS.

*-------------------------------------------------------------------*
* TOP-OF-PAGE.                                                      *
*-------------------------------------------------------------------*
TOP-OF-PAGE.
  PERFORM WRITE_PAGE_HEADING.

*-------------------------------------------------------------------*
* INITIALIZATION.                                                   *
*-------------------------------------------------------------------*
INITIALIZATION.
  PARCOM = '/usr/sap/trans/*'       "Only default value

*-------------------------------------------------------------------*
* START-OF-SELECTION.                                               *
*-------------------------------------------------------------------*
START-OF-SELECTION.
  PERFORM MAKE_LOC.
  PERFORM COLLECT_DATA.
  PERFORM FILE_LIST.

*-------------------------------------------------------------------*
* AT LINE-SELECTION.                                                *
*-------------------------------------------------------------------*
AT LINE-SELECTION.
DATA: PATH(255) TYPE C.

  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 ZZBGSFMA
       WITH PARCOM = PATH
       AND RETURN.
  ENDIF.

  SUBMIT ZZUTIL12            "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.