*&---------------------------------------------------------------------*
*& Report : ZCOMPARE_EXCEL
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
REPORT ZCOMPARE_EXCEL NO STANDARD PAGE HEADING LINE-SIZE 200.
DATA : BEGIN OF ITABB OCCURS 0,
1(18) TYPE C ,
2(40) TYPE C ,
3(10) TYPE C ,
4(10) TYPE C ,
5(10) TYPE C ,
6(10) TYPE C ,
7(10) TYPE C ,
8(10) TYPE C ,
9(10) TYPE C ,
10(10) TYPE C ,
END OF ITABB .
DATA : ITABS LIKE ITABB OCCURS 0 WITH HEADER LINE.
DATA : OUTEXCEL LIKE ITABB OCCURS 0 WITH HEADER LINE.
DATA : EXCELSMALL TYPE TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
DATA : EXCELBIG TYPE TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
DATA : SRNO(5) TYPE C.
DATA : FILE1 LIKE RLGRAP-FILENAME.
DATA : FILE2 LIKE RLGRAP-FILENAME.
DATA : A,B TYPE C.
SELECTION-SCREEN : SKIP.
SELECTION-SCREEN : BEGIN OF BLOCK TEST WITH FRAME TITLE NEW. "NO INTERVALS.
SELECTION-SCREEN : SKIP.
PARAMETERS: EXCEL1 RADIOBUTTON GROUP UC1 DEFAULT 'X'.
SELECTION-SCREEN : SKIP .
PARAMETERS: EXCEL2 RADIOBUTTON GROUP UC1.
SELECTION-SCREEN : SKIP.
PARAMETER CL(2) TYPE C DEFAULT '3'.
SELECTION-SCREEN : SKIP.
SELECTION-SCREEN : COMMENT /1(70) COL.
SELECTION-SCREEN : END OF BLOCK TEST.
PARAMETERS : FIRST LIKE RLGRAP-FILENAME OBLIGATORY.
PARAMETERS : SECOND LIKE RLGRAP-FILENAME OBLIGATORY.
*********************************************************************************************************************
* If u want to select value from column 6th of BIG excelsheet, u need to keep 6th column of SMALL excelsheet as blank..
* So put selection parameter CL = 6.
*********************************************************************************************************************
INITIALIZATION.
NEW = 'COMPARE EXCEL SHEETS '.
COL = 'Column1- MaterialNo Column2- Descn are fixed (Max 10columns)' .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR FIRST.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
IMPORTING
FILE_NAME = FIRST.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR SECOND.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
IMPORTING
FILE_NAME = SECOND.
START-OF-SELECTION.
CALL FUNCTION 'GUI_DELETE_FILE'
EXPORTING
FILE_NAME = 'C:\Documents and Settings\admin\Desktop\TEST.XLS'
EXCEPTIONS
FAILED = 1
OTHERS = 2.
FILE1 = FIRST.
FILE2 = SECOND.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = FILE1
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 10
I_END_ROW = 60000
TABLES
INTERN = EXCELBIG.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = FILE2
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 10
I_END_ROW = 60000
TABLES
INTERN = EXCELSMALL.
LOOP AT EXCELSMALL.
CASE EXCELSMALL-COL.
WHEN 1.
MOVE EXCELSMALL-VALUE TO ITABS-1.
WHEN 2.
MOVE EXCELSMALL-VALUE TO ITABS-2.
WHEN 3.
MOVE EXCELSMALL-VALUE TO ITABS-3.
WHEN 4.
MOVE EXCELSMALL-VALUE TO ITABS-4.
WHEN 5.
MOVE EXCELSMALL-VALUE TO ITABS-5.
WHEN 6.
MOVE EXCELSMALL-VALUE TO ITABS-6.
WHEN 7.
MOVE EXCELSMALL-VALUE TO ITABS-7.
WHEN 8.
MOVE EXCELSMALL-VALUE TO ITABS-8.
WHEN 9.
MOVE EXCELSMALL-VALUE TO ITABS-9.
WHEN 10.
MOVE EXCELSMALL-VALUE TO ITABS-10.
WHEN OTHERS.
ENDCASE.
AT END OF ROW.
APPEND ITABS.
CLEAR ITABS.
ENDAT.
ENDLOOP.
SORT ITABS BY 1.
LOOP AT EXCELBIG.
CASE EXCELBIG-COL.
WHEN 1.
MOVE EXCELBIG-VALUE TO ITABB-1.
WHEN 2.
MOVE EXCELBIG-VALUE TO ITABB-2.
WHEN 3.
MOVE EXCELBIG-VALUE TO ITABB-3.
WHEN 4.
MOVE EXCELBIG-VALUE TO ITABB-4.
WHEN 5.
MOVE EXCELBIG-VALUE TO ITABB-5.
WHEN 6.
MOVE EXCELBIG-VALUE TO ITABB-6.
WHEN 7.
MOVE EXCELBIG-VALUE TO ITABB-7.
WHEN 8.
MOVE EXCELBIG-VALUE TO ITABB-8.
WHEN 9.
MOVE EXCELBIG-VALUE TO ITABB-9.
WHEN 10.
MOVE EXCELBIG-VALUE TO ITABB-10.
WHEN OTHERS.
ENDCASE.
AT END OF ROW.
APPEND ITABB.
CLEAR ITABB.
ENDAT.
ENDLOOP.
SORT ITABB BY 1.
LOOP AT ITABB.
IF EXCEL1 = 'X'.
READ TABLE ITABS WITH KEY 1 = ITABB-1
BINARY SEARCH.
IF SY-SUBRC = 0.
CASE CL.
WHEN 1.
MOVE ITABS-1 TO ITABB-1 .
WHEN 2.
MOVE ITABS-2 TO ITABB-2 .
WHEN 3.
MOVE ITABS-3 TO ITABB-3.
WHEN 4.
MOVE ITABS-4 TO ITABB-4 .
WHEN 5.
MOVE ITABS-5 TO ITABB-5 .
WHEN 6.
MOVE ITABS-6 TO ITABB-6 .
WHEN 7.
MOVE ITABS-7 TO ITABB-7 .
WHEN 8.
MOVE ITABS-8 TO ITABB-8 .
WHEN 9.
MOVE ITABS-9 TO ITABB-9 .
WHEN 10.
MOVE ITABS-10 TO ITABB-10 .
WHEN OTHERS.
ENDCASE.
ELSE.
ITABB-5 = ITABB-5.
ENDIF.
MODIFY ITABB.
CLEAR ITABB.
ENDIF.
ENDLOOP.
IF EXCEL2 = 'X'.
EXIT.
ENDIF.
DATA: X TYPE I, Y TYPE I, L TYPE I.
DEFINE WRITE_FRAME.
X = SY-COLNO. Y = SY-LINNO.
* SKIP TO LINE Y.
WRITE: '|' NO-GAP, &1 NO-GAP, '|' NO-GAP.
L = SY-COLNO - X.
Y = Y - 1. SKIP TO LINE Y.
ULINE AT X(L).
Y = Y + 2. SKIP TO LINE Y.
ULINE AT X(L).
Y = Y - 1. X = SY-COLNO. SKIP TO LINE Y. "POSITION X.
END-OF-DEFINITION.
WRITE_FRAME ' EXCEL FILE is generated on Desktop as KD.xls'.
SKIP 2.
********************************************
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
I_FILENAME = 'C:\Documents and Settings\admin\Desktop\TEST.XLS'
TABLES
I_TAB_SAP_DATA = ITABB.
********************************************
LOOP AT ITABB.
WRITE : / ITABB-1, ITABB-2, ITABB-3, ITABB-4, ITABB-5, ITABB-6, ITABB-7, ITABB-8, ITABB-9, ITABB-10.
ENDLOOP.
*& Report : ZCOMPARE_EXCEL
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
REPORT ZCOMPARE_EXCEL NO STANDARD PAGE HEADING LINE-SIZE 200.
DATA : BEGIN OF ITABB OCCURS 0,
1(18) TYPE C ,
2(40) TYPE C ,
3(10) TYPE C ,
4(10) TYPE C ,
5(10) TYPE C ,
6(10) TYPE C ,
7(10) TYPE C ,
8(10) TYPE C ,
9(10) TYPE C ,
10(10) TYPE C ,
END OF ITABB .
DATA : ITABS LIKE ITABB OCCURS 0 WITH HEADER LINE.
DATA : OUTEXCEL LIKE ITABB OCCURS 0 WITH HEADER LINE.
DATA : EXCELSMALL TYPE TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
DATA : EXCELBIG TYPE TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
DATA : SRNO(5) TYPE C.
DATA : FILE1 LIKE RLGRAP-FILENAME.
DATA : FILE2 LIKE RLGRAP-FILENAME.
DATA : A,B TYPE C.
SELECTION-SCREEN : SKIP.
SELECTION-SCREEN : BEGIN OF BLOCK TEST WITH FRAME TITLE NEW. "NO INTERVALS.
SELECTION-SCREEN : SKIP.
PARAMETERS: EXCEL1 RADIOBUTTON GROUP UC1 DEFAULT 'X'.
SELECTION-SCREEN : SKIP .
PARAMETERS: EXCEL2 RADIOBUTTON GROUP UC1.
SELECTION-SCREEN : SKIP.
PARAMETER CL(2) TYPE C DEFAULT '3'.
SELECTION-SCREEN : SKIP.
SELECTION-SCREEN : COMMENT /1(70) COL.
SELECTION-SCREEN : END OF BLOCK TEST.
PARAMETERS : FIRST LIKE RLGRAP-FILENAME OBLIGATORY.
PARAMETERS : SECOND LIKE RLGRAP-FILENAME OBLIGATORY.
*********************************************************************************************************************
* If u want to select value from column 6th of BIG excelsheet, u need to keep 6th column of SMALL excelsheet as blank..
* So put selection parameter CL = 6.
*********************************************************************************************************************
INITIALIZATION.
NEW = 'COMPARE EXCEL SHEETS '.
COL = 'Column1- MaterialNo Column2- Descn are fixed (Max 10columns)' .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR FIRST.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
IMPORTING
FILE_NAME = FIRST.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR SECOND.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
IMPORTING
FILE_NAME = SECOND.
START-OF-SELECTION.
CALL FUNCTION 'GUI_DELETE_FILE'
EXPORTING
FILE_NAME = 'C:\Documents and Settings\admin\Desktop\TEST.XLS'
EXCEPTIONS
FAILED = 1
OTHERS = 2.
FILE1 = FIRST.
FILE2 = SECOND.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = FILE1
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 10
I_END_ROW = 60000
TABLES
INTERN = EXCELBIG.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = FILE2
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 10
I_END_ROW = 60000
TABLES
INTERN = EXCELSMALL.
LOOP AT EXCELSMALL.
CASE EXCELSMALL-COL.
WHEN 1.
MOVE EXCELSMALL-VALUE TO ITABS-1.
WHEN 2.
MOVE EXCELSMALL-VALUE TO ITABS-2.
WHEN 3.
MOVE EXCELSMALL-VALUE TO ITABS-3.
WHEN 4.
MOVE EXCELSMALL-VALUE TO ITABS-4.
WHEN 5.
MOVE EXCELSMALL-VALUE TO ITABS-5.
WHEN 6.
MOVE EXCELSMALL-VALUE TO ITABS-6.
WHEN 7.
MOVE EXCELSMALL-VALUE TO ITABS-7.
WHEN 8.
MOVE EXCELSMALL-VALUE TO ITABS-8.
WHEN 9.
MOVE EXCELSMALL-VALUE TO ITABS-9.
WHEN 10.
MOVE EXCELSMALL-VALUE TO ITABS-10.
WHEN OTHERS.
ENDCASE.
AT END OF ROW.
APPEND ITABS.
CLEAR ITABS.
ENDAT.
ENDLOOP.
SORT ITABS BY 1.
LOOP AT EXCELBIG.
CASE EXCELBIG-COL.
WHEN 1.
MOVE EXCELBIG-VALUE TO ITABB-1.
WHEN 2.
MOVE EXCELBIG-VALUE TO ITABB-2.
WHEN 3.
MOVE EXCELBIG-VALUE TO ITABB-3.
WHEN 4.
MOVE EXCELBIG-VALUE TO ITABB-4.
WHEN 5.
MOVE EXCELBIG-VALUE TO ITABB-5.
WHEN 6.
MOVE EXCELBIG-VALUE TO ITABB-6.
WHEN 7.
MOVE EXCELBIG-VALUE TO ITABB-7.
WHEN 8.
MOVE EXCELBIG-VALUE TO ITABB-8.
WHEN 9.
MOVE EXCELBIG-VALUE TO ITABB-9.
WHEN 10.
MOVE EXCELBIG-VALUE TO ITABB-10.
WHEN OTHERS.
ENDCASE.
AT END OF ROW.
APPEND ITABB.
CLEAR ITABB.
ENDAT.
ENDLOOP.
SORT ITABB BY 1.
LOOP AT ITABB.
IF EXCEL1 = 'X'.
READ TABLE ITABS WITH KEY 1 = ITABB-1
BINARY SEARCH.
IF SY-SUBRC = 0.
CASE CL.
WHEN 1.
MOVE ITABS-1 TO ITABB-1 .
WHEN 2.
MOVE ITABS-2 TO ITABB-2 .
WHEN 3.
MOVE ITABS-3 TO ITABB-3.
WHEN 4.
MOVE ITABS-4 TO ITABB-4 .
WHEN 5.
MOVE ITABS-5 TO ITABB-5 .
WHEN 6.
MOVE ITABS-6 TO ITABB-6 .
WHEN 7.
MOVE ITABS-7 TO ITABB-7 .
WHEN 8.
MOVE ITABS-8 TO ITABB-8 .
WHEN 9.
MOVE ITABS-9 TO ITABB-9 .
WHEN 10.
MOVE ITABS-10 TO ITABB-10 .
WHEN OTHERS.
ENDCASE.
ELSE.
ITABB-5 = ITABB-5.
ENDIF.
MODIFY ITABB.
CLEAR ITABB.
ENDIF.
ENDLOOP.
IF EXCEL2 = 'X'.
EXIT.
ENDIF.
DATA: X TYPE I, Y TYPE I, L TYPE I.
DEFINE WRITE_FRAME.
X = SY-COLNO. Y = SY-LINNO.
* SKIP TO LINE Y.
WRITE: '|' NO-GAP, &1 NO-GAP, '|' NO-GAP.
L = SY-COLNO - X.
Y = Y - 1. SKIP TO LINE Y.
ULINE AT X(L).
Y = Y + 2. SKIP TO LINE Y.
ULINE AT X(L).
Y = Y - 1. X = SY-COLNO. SKIP TO LINE Y. "POSITION X.
END-OF-DEFINITION.
WRITE_FRAME ' EXCEL FILE is generated on Desktop as KD.xls'.
SKIP 2.
********************************************
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
I_FILENAME = 'C:\Documents and Settings\admin\Desktop\TEST.XLS'
TABLES
I_TAB_SAP_DATA = ITABB.
********************************************
LOOP AT ITABB.
WRITE : / ITABB-1, ITABB-2, ITABB-3, ITABB-4, ITABB-5, ITABB-6, ITABB-7, ITABB-8, ITABB-9, ITABB-10.
ENDLOOP.
No comments:
Post a Comment