Загрузка Excel документа во внутреннею таблицу

  1. REPORT UPLOAD_EXCEL no standard page heading.
  2.  
  3.  
  4. data: itab like alsmex_tabline occurs 0 with header line.
  5.  
  6. TYPES: Begin of t_record,
  7. name1 like itab-value,
  8. name2 like itab-value,
  9. age like itab-value,
  10. End of t_record.
  11. DATA: it_record type standard table of t_record initial size 0,
  12. wa_record type t_record.
  13. DATA: gd_currentrow type i.
  14.  
  15. *Selection Screen Declaration
  16. *----------------------------
  17. PARAMETER p_infile like rlgrap-filename.
  18.  
  19.  
  20. ************************************************************************
  21. *START OF SELECTION
  22. call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  23. exporting
  24. filename = p_infile
  25. i_begin_col = '1'
  26. i_begin_row = '2' "Do not require headings
  27. i_end_col = '14'
  28. i_end_row = '31'
  29. intern = itab
  30. exceptions
  31. inconsistent_parameters = 1
  32. upload_ole = 2
  33. others = 3.
  34. if sy-subrc <> 0.
  35. message e010(zz) with text-001. "Problem uploading Excel Spreadsheet
  36.  
  37.  
  38. sort itab by row col.
  39.  
  40.  
  41. read table itab index 1.
  42.  
  43.  
  44. gd_currentrow = itab-row.
  45.  
  46. loop at itab.
  47.  
  48. if itab-row ne gd_currentrow.
  49. append wa_record to it_record.
  50. clear wa_record.
  51. gd_currentrow = itab-row.
  52.  
  53. case itab-col.
  54. when '0001'. "First name
  55. wa_record-name1 = itab-value.
  56. when '0002'. "Surname
  57. wa_record-name2 = itab-value.
  58. when '0003'. "Age
  59. wa_record-age = itab-value.
  60. append wa_record to it_record.
  61.  
  62. loop at it_record into wa_record.
  63. write:/ sy-vline,
  64. (10) wa_record-name1, sy-vline,
  65. (10) wa_record-name2, sy-vline,
  66. (10) wa_record-age, sy-vline.

Комментарии