PARAMETERS: P_FILE TYPE STRING OBLIGATORY.
DATA: CONN TYPE OLE2_OBJECT,
RSDB TYPE OLE2_OBJECT,
SQL TYPE C LENGTH 1024.
CREATE OBJECT CONN 'ADODB.Connection'.
CREATE OBJECT RSDB 'ADODB.Recordset'.
* MDB Connetion infomations
CONCATENATE 'Provider=Microsoft.Jet.OLEDB.4.0;' 'Data Source=' P_FILE ';' INTO SQL.
CALL METHOD OF CONN 'Open' EXPORTING #1 = SQL.
* Query Statement ...
CONCATENATE 'SELECT * FROM' LV_TABNAME INTO SQL SEPARATED BY SPACE.
* Run Query
CALL METHOD OF RSDB 'OPEN'
EXPORTING #1 = SQL
#2 = CONN
#3 = '1'.
DO.
CALL METHOD OF RSDB 'getstring' = SQL
EXPORTING #1 = '2' "Do not modify!
#2 = 1 "Do not modify!
#3 = '|' "Do not modify!
#4 = '|'. "Do not modify!
IF SY-SUBRC EQ 0.
REFRESH IT_TEMP.
SPLIT SQL AT '|' INTO TABLE IT_TEMP.
LOOP AT IT_TEMP INTO WA_TEMP.
CASE SY-TABIX.
WHEN 1.
CASE WA_TEMP-VALUE(1).
WHEN '1'.
IT_TAB-CARD = 'A'.
WHEN '2'.
IT_TAB-CARD = 'B'.
ENDCASE.
WHEN 2.
CONCATENATE '1' WA_TEMP-VALUE(2) '0' INTO IT_TAB-OFF_NO.
WHEN 3.
DATA: LV_YEAR(4) TYPE C.
LV_YEAR = WA_TEMP-VALUE(3) + 1911.
CONCATENATE LV_YEAR WA_TEMP-VALUE+3(4) INTO IT_TAB-TRDATE.
* IT_TAB-TRDATE = WA_TEMP-VALUE(40).
WHEN 4.
IT_TAB-SEQ_NO = WA_TEMP-VALUE(40).
WHEN 5.
IT_TAB-AMT1 = WA_TEMP-VALUE.
WHEN 6.
IT_TAB-AMT2 = WA_TEMP-VALUE.
WHEN 7.
IT_TAB-AMT3 = WA_TEMP-VALUE.
WHEN 8.
IT_TAB-MSG = WA_TEMP-VALUE(40).
ENDCASE.
ENDLOOP.
APPEND IT_TAB.
CLEAR IT_TAB.
ELSE.
EXIT.
ENDIF.
ENDDO.
沒有留言:
張貼留言