REPORT Ycompare MESSAGE-ID Z1
                NO STANDARD PAGE HEADING
*               LINE-COUNT 65
                LINE-SIZE  255.

*---------------------------------------------------------------------*
* Topic:         Compare 2 unix  or pc files and print the differences*
*                                                                     *
* Author:        Sheila Titchener
*                                                                     *
*---------------------------------------------------------------------*
DATA: BEGIN OF TAB1 OCCURS 0,
      LINE(5000),
      END OF TAB1.

DATA: BEGIN OF TAB2 OCCURS 0,
      LINE(5000),
      END OF TAB2.
DATA: PARCOM_LOC(100) TYPE C.
DATA: COLOR TYPE I.
DATA: COUNT(16) TYPE C.

*-------------------------------------------------------------------*
* Parameters.                                                       *
*-------------------------------------------------------------------*
SELECTION-SCREEN SKIP 2.
  PARAMETERS: PARCOM1(45) TYPE C LOWER CASE,
              PARCOM2(45) TYPE C LOWER CASE,
              PARCOM3 LIKE RLGRAP-FILENAME,
              PARCOM4 LIKE RLGRAP-FILENAME ,
              P_PC RADIOBUTTON GROUP ONE,
              P_UNIX RADIOBUTTON GROUP ONE.
*-------------------------------------------------------------------*
* Parameter validation                                              *
*-------------------------------------------------------------------*

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

*-------------------------------------------------------------------*
* INITIALIZATION.                                                   *
*-------------------------------------------------------------------*
INITIALIZATION.
  PARCOM1 = '/usr/sap/trans/* '.
  PARCOM2 = '/usr/sap/trans/* '.
  PARCOM3 = 'C:\TEMP\'.
  PARCOM4 = 'C:\TEMP\'.

*-------------------------------------------------------------------*
* START-OF-SELECTION.                                               *
*-------------------------------------------------------------------*
START-OF-SELECTION.
  IF P_UNIX = 'X'.
  PERFORM COLLECT_DATA.
  ELSE.
  PERFORM COLLECT_PC_DATA.
  ENDIF.
  PERFORM WRITE_FILE_CONTENT.
*  perform write_number_of_content.

*---------------------------------------------------------------------*
* FORM COLLECT_DATA.                                                  *
*---------------------------------------------------------------------*
FORM COLLECT_DATA.
    OPEN DATASET PARCOM1 FOR INPUT IN TEXT MODE.
    DO.
      READ DATASET PARCOM1 INTO TAB1.
      IF SY-SUBRC NE 0.
        EXIT.
      ENDIF.
      APPEND TAB1.
    ENDDO.
    CLOSE DATASET PARCOM1.

    OPEN DATASET PARCOM2 FOR INPUT IN TEXT MODE.
    DO.
      READ DATASET PARCOM2 INTO TAB2.
      IF SY-SUBRC NE 0.
        EXIT.
      ENDIF.
      APPEND TAB2.
    ENDDO.
    CLOSE DATASET PARCOM2.
ENDFORM.

*-------------------------------------------------------------------*
* FORM WRITE_FILE_CONTENT.                                          *
*-------------------------------------------------------------------*
FORM WRITE_FILE_CONTENT.

  LOOP AT TAB1.
    READ TABLE TAB2 INDEX SY-TABIX.
    IF TAB1(7) = 'Element'.
       WRITE: / TAB1.
    ENDIF.
    IF TAB1 NE TAB2 .
       WRITE: / SY-TABIX NO-GAP, TAB1.
       WRITE: /  TAB2.
       WRITE:/1(80) SY-ULINE.

    ENDIF.
  ENDLOOP.
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.
   IF P_UNIX = 'x'.
   WRITE: /    PARCOM1   COLOR 1.
   WRITE: 45    PARCOM2   COLOR 1.
   ELSE.
   WRITE: /    PARCOM3   COLOR 1.
   WRITE: 45    PARCOM4   COLOR 1.
   ENDIF.
   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 TAB1 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.
*&---------------------------------------------------------------------*
*&      Form  COLLECT_PC_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM COLLECT_PC_DATA.

CALL FUNCTION 'WS_UPLOAD'
     EXPORTING
*         CODEPAGE            = ' '
          FILENAME            = PARCOM3
*         FILETYPE            = ' '
*         HEADLEN             = ' '
*         LINE_EXIT           = ' '
*         TRUNCLEN            = ' '
*         USER_FORM           = ' '
*         USER_PROG           = ' '
*    IMPORTING
*         FILELENGTH          =
     TABLES
          DATA_TAB            = TAB1
     EXCEPTIONS
          CONVERSION_ERROR    = 1
          FILE_OPEN_ERROR     = 2
          FILE_READ_ERROR     = 3
          INVALID_TABLE_WIDTH = 4
          INVALID_TYPE        = 5
          NO_BATCH            = 6
          UNKNOWN_ERROR       = 7
          OTHERS              = 8.

CALL FUNCTION 'WS_UPLOAD'
     EXPORTING
*         CODEPAGE            = ' '
          FILENAME            = PARCOM4
*         FILETYPE            = ' '
*         HEADLEN             = ' '
*         LINE_EXIT           = ' '
*         TRUNCLEN            = ' '
*         USER_FORM           = ' '
*         USER_PROG           = ' '
*    IMPORTING
*         FILELENGTH          =
     TABLES
          DATA_TAB            = TAB2
     EXCEPTIONS
          CONVERSION_ERROR    = 1
          FILE_OPEN_ERROR     = 2
          FILE_READ_ERROR     = 3
          INVALID_TABLE_WIDTH = 4
          INVALID_TYPE        = 5
          NO_BATCH            = 6
          UNKNOWN_ERROR       = 7
          OTHERS              = 8.
ENDFORM.                    " COLLECT_PC_DATA