Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report YBC_SOURCE_COMPARE *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ybc_multi_source_compare.
TABLES tnapr.
DATA lt_abaptxt255_1 TYPE TABLE OF abaptxt255 WITH HEADER LINE.
DATA lt_abaptxt255_2 TYPE TABLE OF abaptxt255 WITH HEADER LINE.
DATA lt_res TYPE TABLE OF rsedcresul WITH HEADER LINE.
DATA lv_diff(1).
DATA lv_rep1 TYPE tnapr-pgnam.
DATA: BEGIN OF lt_prog OCCURS 0,
name TYPE syst-repid,
END OF lt_prog.
DATA rc TYPE i.
START-OF-SELECTION.
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-001.
SELECT-OPTIONS p_rep FOR tnapr-pgnam OBLIGATORY DEFAULT 'YTEST1'.
PARAMETERS des1 TYPE rfcdes-rfcdest OBLIGATORY DEFAULT 'NONE'.
SELECTION-SCREEN END OF BLOCK b.
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-002.
PARAMETERS des2 TYPE rfcdes-rfcdest OBLIGATORY DEFAULT 'NONE'.
SELECTION-SCREEN END OF BLOCK a.
END-OF-SELECTION.
SELECT name FROM trdir INTO TABLE lt_prog WHERE
name IN p_rep AND
cnam NE 'SAP' AND
unam NE 'SAP'.
LOOP AT lt_prog INTO lv_rep1.
CLEAR rc.
PERFORM read_d1 CHANGING rc.
PERFORM read_d2 CHANGING rc.
IF rc IS INITIAL.
PERFORM compare_d1_d2.
IF NOT lv_diff IS INITIAL.
MESSAGE s014(fmcy).
ELSE.
* PERFORM dbg2(zdeb00) USING sy-repid 'LT_res'.
*
* IN DER Tabelle LT_RES ist das Ergebnis (aufbereitet) falls Differenzen !!!
*
ENDIF.
ENDIF."rc
ENDLOOP.
EXIT.
*&---------------------------------------------------------------------*
*& Form read_d1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RC text
*----------------------------------------------------------------------*
FORM read_d1 CHANGING rc TYPE i.
DATA ls_pginfo TYPE rpy_prog.
DATA msg_text(80).
DATA lt_rpy_repo TYPE TABLE OF rpy_repo WITH HEADER LINE.
DATA lt_abapsource TYPE TABLE OF abapsource WITH HEADER LINE.
DATA lt_textpool TYPE TABLE OF textpool WITH HEADER LINE.
CALL FUNCTION 'RPY_PROGRAM_READ' DESTINATION des1
EXPORTING
* LANGUAGE = SY-LANGU
program_name = lv_rep1
* WITH_INCLUDELIST = 'X'
* ONLY_SOURCE = ' '
* ONLY_TEXTS = ' '
* READ_LATEST_VERSION = ' '
* WITH_LOWERCASE = ' '
IMPORTING
prog_inf = ls_pginfo
TABLES
include_tab = lt_rpy_repo
SOURCE = lt_abapsource
source_extended = lt_abaptxt255_1
textelements = lt_textpool
EXCEPTIONS
cancelled = 1
not_found = 2
permission_error = 3
communication_failure = 4 MESSAGE msg_text
system_failure = 5 MESSAGE msg_text
OTHERS = 6.
IF sy-subrc <> 0.
rc = sy-subrc.
ENDIF.
ENDFORM. "read_d1
*&---------------------------------------------------------------------*
*& Form read_d2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RC text
*----------------------------------------------------------------------*
FORM read_d2 CHANGING rc TYPE i.
DATA ls_pginfo TYPE rpy_prog.
DATA msg_text(80).
DATA lt_rpy_repo TYPE TABLE OF rpy_repo WITH HEADER LINE.
DATA lt_abapsource TYPE TABLE OF abapsource WITH HEADER LINE.
DATA lt_textpool TYPE TABLE OF textpool WITH HEADER LINE.
DATA lv_rep2 TYPE tnapr-pgnam .
lv_rep2 = lv_rep1.
CALL FUNCTION 'RPY_PROGRAM_READ' DESTINATION des2
EXPORTING
* LANGUAGE = SY-LANGU
program_name = lv_rep2
* WITH_INCLUDELIST = 'X'
* ONLY_SOURCE = ' '
* ONLY_TEXTS = ' '
* READ_LATEST_VERSION = ' '
* WITH_LOWERCASE = ' '
IMPORTING
prog_inf = ls_pginfo
TABLES
include_tab = lt_rpy_repo
SOURCE = lt_abapsource
source_extended = lt_abaptxt255_2
textelements = lt_textpool
EXCEPTIONS
cancelled = 1
not_found = 2
permission_error = 3
communication_failure = 4 MESSAGE msg_text
system_failure = 5 MESSAGE msg_text
OTHERS = 6.
IF sy-subrc <> 0.
rc = sy-subrc.
ENDIF.
ENDFORM. "read_d2
*&---------------------------------------------------------------------*
*& Form compare_d1_d2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM compare_d1_d2.
DATA t1 TYPE rswsourcet.
DATA t2 TYPE rswsourcet.
DATA x TYPE string.
LOOP AT lt_abaptxt255_1 INTO x.
APPEND x TO t1.
ENDLOOP.
LOOP AT lt_abaptxt255_2 INTO x.
APPEND x TO t2.
ENDLOOP.
* *** Die einzelnen Flags ***
*' '
*'M', " So stehts in Liste
*'U', " So stehts im Delta
*'I',
*'D',
*'E'. "eingefügte Leerzeil"HT001
CLEAR lv_diff.
CALL FUNCTION 'RS_CMP_COMPUTE_DELTA'
EXPORTING
compare_mode = '1'
flg_ext_ignore = ' '
ignore_case_differences = 'X'
flg_wb99 = ' '
IMPORTING
flg_equal = lv_diff
TABLES
text_tab1 = t1
text_tab2 = t2
text_tab_res = lt_res
EXCEPTIONS
parameter_invalid = 1
difference_not_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. "compare_d1_d2