Posted By

qrist0ph on 10/27/10


Tagged

abap


Versions (?)

ABAP Read from file


 / Published in: Other
 

  1. REPORT z_ziv01_korr_ihk_gp .
  2. TYPE-POOLS: abap.
  3.  
  4. TYPES: BEGIN OF ty_input,
  5. partner TYPE bu_partner,
  6. ihk TYPE zbpe_ihk,
  7. END OF ty_input.
  8.  
  9. DATA: lv_partner TYPE bu_partner,
  10. lv_datei_in TYPE string,
  11. ls_line_csv TYPE string,
  12. lv_eof TYPE boole-boole,
  13. lv_tmp TYPE string,
  14. ls_line_in TYPE ty_input,
  15. lv_ihk TYPE zbpe_ihk.
  16.  
  17.  
  18. CONCATENATE '/SAPFTP/' sy-sysid '/Datei' INTO lv_datei_in.
  19.  
  20.  
  21. *** Öffnen der Eingabe Datei
  22. OPEN DATASET lv_datei_in FOR INPUT IN TEXT MODE ENCODING DEFAULT.
  23. IF sy-subrc NE 0.
  24. CLEAR lv_tmp.
  25. CONCATENATE 'Fehler beim Öffnen der Datei: ' lv_datei_in INTO lv_tmp SEPARATED BY space.
  26. MESSAGE lv_tmp TYPE 'E'.
  27. ENDIF.
  28.  
  29.  
  30. *** Durchlaufen der Eingabe Datei
  31. lv_eof = abap_false.
  32. WHILE lv_eof EQ abap_false.
  33. READ DATASET lv_datei_in INTO ls_line_csv.
  34. IF sy-subrc EQ 4. "4=EOF
  35. lv_eof = abap_true.
  36. ELSE.
  37. SPLIT ls_line_csv AT ';' INTO ls_line_in-partner ls_line_in-ihk.
  38. ENDIF.
  39.  
  40. ENDWHILE.

Report this snippet  

You need to login to post a comment.