REPORT ZZUTIL12 MESSAGE-ID Z1 NO STANDARD PAGE HEADING LINE-COUNT 65 LINE-SIZE 80. *---------------------------------------------------------------------* * Topic: Browse file on Unix. * * * * Beskrivelse: 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. * * * * Autorisation: None * * * * Customisering: None * * * * Parametre: Filename and path * * * * Releaseskifte: Check that you are allowed to use C-calls * * * * Release: 3.0F * * * * Programmør: John B. Lauridsen, DSB data. * * * *---------------------------------------------------------------------* DATA: BEGIN OF TABL OCCURS 0, LINE(560), END OF TABL. DATA: PARCOM_LOC(100) TYPE C. DATA: COLOR TYPE I. DATA: COUNT(16) TYPE C. *-------------------------------------------------------------------* * Parameters. * *-------------------------------------------------------------------* SELECTION-SCREEN SKIP 2. PARAMETERS: PARCOM(45) TYPE C LOWER CASE. *-------------------------------------------------------------------* * Validering af parametre. * *-------------------------------------------------------------------* *-------------------------------------------------------------------* * TOP-OF-PAGE. * *-------------------------------------------------------------------* TOP-OF-PAGE. PERFORM WRITE_PAGE_HEADING. *-------------------------------------------------------------------* * INITIALIZATION. * *-------------------------------------------------------------------* INITIALIZATION. PARCOM = '/usr/sap/trans/* '. *-------------------------------------------------------------------* * START-OF-SELECTION. * *-------------------------------------------------------------------* START-OF-SELECTION. PERFORM MAKE_LOC. PERFORM COLLECT_DATA. PERFORM WRITE_FILE_CONTENT. PERFORM WRITE_NUMBER_OF_CONTENT. *---------------------------------------------------------------------* * FORM MAKE_LOC. * *---------------------------------------------------------------------* FORM MAKE_LOC. CLEAR: PARCOM_LOC. PARCOM_LOC(4) = 'cat '. PARCOM_LOC+4(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 WRITE_FILE_CONTENT. * *-------------------------------------------------------------------* FORM WRITE_FILE_CONTENT. DATA: LÆNGDE LIKE SY-FDPOS. LOOP AT TABL. LÆNGDE = STRLEN( TABL-LINE ). IF LÆNGDE GE 0. PERFORM COLORLINE USING ' 0' TABL-LINE+0(69). PERFORM STREGER_3. ENDIF. IF LÆNGDE GE 70. PERFORM COLORLINE USING ' 70' TABL-LINE+69(70). PERFORM STREGER_3. ENDIF. IF LÆNGDE GE 140. PERFORM COLORLINE USING '140' TABL-LINE+139(70). PERFORM STREGER_3. ENDIF. IF LÆNGDE GE 210. PERFORM COLORLINE USING '210' TABL-LINE+209(70). PERFORM STREGER_3. ENDIF. IF LÆNGDE GE 280. PERFORM COLORLINE USING '280' TABL-LINE+279(70). PERFORM STREGER_3. ENDIF. IF LÆNGDE GE 350. PERFORM COLORLINE USING '350' TABL-LINE+349(70). PERFORM STREGER_3. ENDIF. IF LÆNGDE GE 420. PERFORM COLORLINE USING '420' TABL-LINE+419(70). PERFORM STREGER_3. ENDIF. IF LÆNGDE GE 490. PERFORM COLORLINE USING '490' TABL-LINE+489(70). PERFORM STREGER_3. ENDIF. IF LÆNGDE GE 560. PERFORM COLORLINE USING '560' TABL-LINE+559(70). 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(45) 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: /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.