Skip to Content
0
Former Member
Aug 10, 2006 at 12:42 PM

uploading data from flatfile plz correct this code

25 Views

hi all,

here i m sending code for uploading data from flatfile in to table .plz check it and modify it

REPORT ZFM_KFZ.

TABLES: ZFM_KFZ.

PARAMETERS: FILEDATA(128) default ''

lower case .

DATA: begin of rec,

filler(300),

end of rec.

DATA : begin of itab occurs 0,

kfznr like zfm_kfz-kfznr,

geraet like zfm_kfz-geraet,

kostentraeger type c,

tuvdatummmyyyy type c ,

asudatummmyyyy type c,

kmstand type c,

reifen type c,

end of itab.

  • -------------------- MAIN

OPEN DATASET FILEDATA FOR INPUT IN TEXT MODE encoding default.

IF sy-subrc ne 0. "### Error opening

WRITE: 'The Input file cannot be opened:',FILEDATA.

EXIT.

ELSEIF sy-subrc = 0.

DO.

READ DATASET FILEDATA INTO rec.

IF sy-subrc <> 0. "### EOF

EXIT.

ELSE.

split rec at ';' into

itab-KFZNR

itab-GERAET

itab-KOSTENTRAEGER

itab-TUVDATUMMMYYYY

itab-ASUDATUMMMYYYY

itab-KMSTAND

itab-REIFEN

append itab.

ENDIF.

ENDDO.

CLOSE DATASET FILEDATA.

ENDIF.

loop at itab.

  • write itab.

CLEAR ZFM_KFZ.

ZFM_KFZ-KFZNR = itab-KFZNR.

ZFM_KFZ-GERAET = itab-GERAET.

ZFM_KFZ-KOSTENTRAEGER = itab-KOSTENTRAEGER.

ZFM_KFZ-TUVDATUMMMYYYY = itab-TUVDATUMMMYYYY.

ZFM_KFZ-ASUDATUMMMYYYY = itab-ASUDATUMMMYYYY.

ZFM_KFZ-REIFEN = itab-REIFEN.

INSERT ZFM_KFZ.

if sy-subrc ne 0.

write: / 'NOT INSERTED '.

endif.

endloop.