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

Unix File Manager in ABAP/4 via Unix OS Calls



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



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Nov 17, 2007 7:16 pm    Post subject: Unix File Manager in ABAP/4 via Unix OS Calls Reply with quote

Code:
REPORT ZZBGS002 MESSAGE-ID Z1
                NO STANDARD PAGE HEADING
                LINE-COUNT 65
                LINE-SIZE  132.

*---------------------------------------------------------------------*
* Emne:            Program Mananager, showing directory list from Unix*
*                  and posibility to select and do things with the    *
*                  selected file                                      *
*                                                                     *
* Beskrivelse:     With an C-call you have access to UNIX. thes is    *
*                  used to call standad unix operating system calls   *
*                  'ls'.                                              *
*                  Remember that you have SAP authorization on Unix   *
*                  so be careful out there.                           *
*                                                                     *
* Autorisation:    None                                               *
*                                                                     *
* Customisering:   No customizing                                     *
*                                                                     *
* Parametre:       Filename incl. path                                *
*                                                                     *
* Releaseskifte:   Check you are alowed to use C calls                *
*                                                                     *
* Programmør:      Benny G. Sørensen                                  *
*                                                                     *
* SAP Release:     3.0x                                               *
*---------------------------------------------------------------------*

*---------------------------------------------------------------------*
* Global Variables.                                                   *
*---------------------------------------------------------------------*
DATA: BEGIN OF TABL OCCURS 0,
          LINE(132),
      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/tmp/*'.            "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 ZZBGS002
       WITH PARCOM = PATH
       AND RETURN.
  ENDIF.

  IF SY-LISEL+1(1) NE '-'   .
    EXIT.
  ENDIF.
*  SUBMIT < your own file browser, not included on this Web page >
*     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.

 
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 -> Connect to External system, Unix и Perl 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.