Posted: Sat Oct 13, 2007 2:04 pm Post subject: Browse files on 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.
Code:
*---------------------------------------------------------------------*
* 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.
*********************************************************************
*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.
View file on the application server(UNIX). Used in conjunction with ZUNIXFILES which displays all directorys/files on the application server.
Simple copy and paste the following code into a new ABAP report program.
Code:
*....................................................................
*: Title: Browse file on Unix. :
*: :
*: Description: Using internal System Call we gain access to UNIX. :
*: The program uses the standard Unix command 'cat' to:
*: browse the file :
*: :
*: The program lets you browse a file record of up to :
*: 500 chars wide. :
*: :
*:..................................................................:
REPORT ZBROWSEFILE MESSAGE-ID Z1
NO STANDARD PAGE HEADING
LINE-COUNT 65
LINE-SIZE 80.
DATA: BEGIN OF TABL OCCURS 0,
LINE(560),
END OF TABL.
DATA: PARCOM_LOC LIKE RS37A-LINE.
DATA: COLOR TYPE I.
DATA: COUNT(16) TYPE C.
*---------------------------------------------------------------------*
* FORM MAKE_LOC. *
*---------------------------------------------------------------------*
FORM MAKE_LOC.
CLEAR: PARCOM_LOC.
PARCOM_LOC(4) = 'cat '.
PARCOM_LOC+4(245) = PARCOM.
ENDFORM.
*---------------------------------------------------------------------*
* FORM COLLECT_DATA. *
*---------------------------------------------------------------------*
FORM COLLECT_DATA.
REFRESH TABL.
CALL 'SYSTEM' ID 'COMMAND' FIELD PARCOM_LOC
ID 'TAB' FIELD TABL-*SYS*.
ENDFORM.
*-------------------------------------------------------------------*
* FORM WRITE_FILE_CONTENT. *
*-------------------------------------------------------------------*
FORM WRITE_FILE_CONTENT.
* The following data item needs to be renamed as the "DEVK910117
* special character used is no longer valid. "DEVK910117
*DATA: LЖNGDE LIKE SY-FDPOS. "DEVK910117
DATA: LAENGDE LIKE SY-FDPOS. "DEVK910117
LOOP AT TABL.
* LЖNGDE = STRLEN( TABL-LINE ). "DEVK910117
LAENGDE = STRLEN( TABL-LINE ). "DEVK910117
* IF LЖNGDE GE 0. "DEVK910117
IF LAENGDE GE 0. "DEVK910117
PERFORM COLORLINE USING ' 0' TABL-LINE+0(69).
PERFORM STREGER_3.
ENDIF.
* IF LЖNGDE GE 70. "DEVK910117
IF LAENGDE GE 70. "DEVK910117
PERFORM COLORLINE USING ' 70' TABL-LINE+69(70).
PERFORM STREGER_3.
ENDIF.
* IF LЖNGDE GE 140. "DEVK910117
IF LAENGDE GE 140. "DEVK910117
PERFORM COLORLINE USING '140' TABL-LINE+139(70).
PERFORM STREGER_3.
ENDIF.
* IF LЖNGDE GE 210. "DEVK910117
IF LAENGDE GE 210. "DEVK910117
PERFORM COLORLINE USING '210' TABL-LINE+209(70).
PERFORM STREGER_3.
ENDIF.
* IF LЖNGDE GE 280. "DEVK910117
IF LAENGDE GE 280. "DEVK910117
PERFORM COLORLINE USING '280' TABL-LINE+279(70).
PERFORM STREGER_3.
ENDIF.
* IF LЖNGDE GE 350. "DEVK910117
IF LAENGDE GE 350. "DEVK910117
PERFORM COLORLINE USING '350' TABL-LINE+349(70).
PERFORM STREGER_3.
ENDIF.
* IF LЖNGDE GE 420. "DEVK910117
IF LAENGDE GE 420. "DEVK910117
PERFORM COLORLINE USING '420' TABL-LINE+419(70).
PERFORM STREGER_3.
ENDIF.
* IF LЖNGDE GE 490. "DEVK910117
IF LAENGDE GE 490. "DEVK910117
PERFORM COLORLINE USING '490' TABL-LINE+489(70).
PERFORM STREGER_3.
ENDIF.
* IF LЖNGDE GE 560. "DEVK910117
IF LAENGDE GE 560. "DEVK910117
* The following can only pass over at most one byte "DEVK910117
* because the table line length is only 560. An error "DEVK910117
* results on compilation because it is currently "DEVK910117
* trying to pass over something which does not exist. "DEVK910117
* It is better to pass over just the one byte than "DEVK910117
* nothing at all. "DEVK910117
* PERFORM COLORLINE USING '560' TABL-LINE+559(70). "DEVK910117
PERFORM COLORLINE USING '560' TABL-LINE+559(01). "DEVK910117
PERFORM STREGER_3.
ENDIF.
ENDLOOP.
WRITE:/1(80) SY-ULINE.
ENDFORM.
*-------------------------------------------------------------------*
* FORM WRITE_PAGE_HEADING. *
*-------------------------------------------------------------------*
FORM WRITE_PAGE_HEADING.
WRITE:/1(80) SY-ULINE.
PERFORM STREGER_2.
FORMAT INTENSIFIED.
WRITE: /2(79) SPACE COLOR 1.
WRITE: 2 SY-DATUM COLOR 1.
WRITE: 15 PARCOM(65) COLOR 1.
PERFORM STREGER_2.
WRITE:/1(80) SY-ULINE.
PERFORM STREGER_2.
FORMAT INTENSIFIED.
WRITE: /2(79) SPACE COLOR 3.
WRITE: 2 'Offset' COLOR 3,
10 '0....+....1....+....2....+....3....+....' COLOR 3,
50 '4....+....5....+....6....+....' COLOR 3.
PERFORM STREGER_3.
FORMAT RESET.
WRITE:/1(80) SY-ULINE.
ENDFORM.
*-------------------------------------------------------------------*
* FORM STREGER_2. *
*-------------------------------------------------------------------*
FORM STREGER_2.
PERFORM WRITE_VLINE USING ' ' 1.
PERFORM WRITE_VLINE USING ' ' 80.
ENDFORM.
*-------------------------------------------------------------------*
* FORM STREGER_3. *
*-------------------------------------------------------------------*
FORM STREGER_3.
PERFORM WRITE_VLINE USING ' ' 1.
PERFORM WRITE_VLINE USING ' ' 9.
PERFORM WRITE_VLINE USING ' ' 80.
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.
*-------------------------------------------------------------------*
* FORM COLORLINE. *
*-------------------------------------------------------------------*
FORM COLORLINE USING TEXT1 TEXT2.
ON CHANGE OF SY-TABIX.
COLOR = COLOR + 1.
COLOR = COLOR MOD 2.
ENDON.
FORMAT RESET.
IF COLOR = 1.
WRITE: /2(79) SPACE COLOR 2.
IF TEXT1 = ' 0'.
WRITE: 3 TEXT1 COLOR 2, 11 TEXT2 COLOR 2.
ELSE.
WRITE: 3 TEXT1 COLOR 2, 10 TEXT2 COLOR 2.
ENDIF.
ELSE.
WRITE: /2(79) SPACE COLOR 4.
IF TEXT1 = ' 0'.
WRITE: 3 TEXT1 COLOR 4, 11 TEXT2 COLOR 4.
ELSE.
WRITE: 3 TEXT1 COLOR 4, 10 TEXT2 COLOR 4.
ENDIF.
ENDIF.
ENDFORM.
*-------------------------------------------------------------------*
* FORM WRITE_NUMBER_OF_CONTENT. *
*-------------------------------------------------------------------*
FORM WRITE_NUMBER_OF_CONTENT.
DESCRIBE TABLE TABL LINES COUNT.
FORMAT RESET. CONDENSE COUNT.
RESERVE 3 LINES.
WRITE:/1(80) SY-ULINE.
WRITE:/1(80) SY-ULINE.
WRITE: /2(79) SPACE COLOR 2.
WRITE: 2 'Number of records in file:' COLOR 2,
29 COUNT COLOR 2.
PERFORM STREGER_2.
WRITE:/1(80) SY-ULINE.
ENDFORM.
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.