SAP MDG · REPLICATION INBOUND

How does the MDG mass key mapping upload routine read Excel files and build row content in SAP ABAP?

The upload routine reads the selected Excel file into an internal table, converts the cells into delimiter-separated lines, preserves empty columns by inserting delimiters, replaces embedded delimiters in cell values with a dot, and appends each completed row to the upload content table.

The upload routine reads the selected Excel file into an internal table, converts the cells into delimiter-separated lines, preserves empty columns by inserting delimiters, replaces embedded delimiters in cell values with a dot, and appends each completed row to the upload content table.

The upload routine `FORM upload_execl` in `ZCREATE_KEY_MAPPING_UPLOAD.abap` converts an Excel file into line-based content for mass key-mapping upload. It reads the file into `lt_temp_excel_file`, reconstructs missing columns by inserting delimiters, sanitizes delimiter characters found in cell values, and appends one assembled string per Excel row to `et_filecontent`.

Process flow

  1. Select upload mode in the report.
  2. Provide the Excel file path and the row limit.
  3. Read the Excel file into a cell table via `excel_to_internal_table`.
  4. Loop through the cell table row by row.
  5. Insert delimiters for skipped columns so empty cells stay visible.
  6. Replace delimiter characters inside cell values with `.`.
  7. Append each completed row to the upload content table.

Referenced tables

ObjectPurpose
fm_tablineTemporary internal table line type used to hold Excel cell data after file conversion.

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

1*----------------------------------------------------------------------* 2***INCLUDE CREATE_KEY_MAPPING_UPLOAD . 3*----------------------------------------------------------------------* 4*&---------------------------------------------------------------------* 5*& Form UPLOAD_EXECL 6*&---------------------------------------------------------------------* 7* text 8*----------------------------------------------------------------------* 9* -->P_I_FILE_NAME text 10*----------------------------------------------------------------------* 11FORM upload_execl TABLES et_filecontent 12 USING i_file_name 13 i_lines. " Note 2514101 14 15 DATA: 16 ld_max_rows TYPE i, 17 lt_temp_excel_file TYPE TABLE OF fm_tabline, 18 ls_result TYPE string, 19 ld_delimiter(1) TYPE c, 20 ld_prev_col TYPE kcd_ex_col_n, 21 ld_initial_col TYPE kcd_ex_col_n, 22 i_delimiter TYPE c VALUE ','. 23 24 DATA: i_begin_col TYPE i, 25 i_begin_row TYPE i, 26 i_end_col TYPE i, 27 i_end_row TYPE i. 28 CONSTANTS: con_max_testrun TYPE i VALUE 1000. 29* CONSTANTS: con_max_xls_row TYPE i VALUE 5000. " Note 2514101 30 31 FIELD-SYMBOLS: <lfs_excel> TYPE fm_tabline. 32 33** Set max.Number rows to read: in Dialog-Test max.1000, otherwise 5000 34 35 ld_max_rows = i_lines. " Note 2514101 36 37 i_begin_col = '1'. 38 i_begin_row = '1'. 39 i_end_col = '200'. 40 i_end_row = ld_max_rows. 41 42 PERFORM excel_to_internal_table TABLES lt_temp_excel_file 43 USING i_file_name 44 i_begin_col 45 i_begin_row 46 i_end_col 47 i_end_row. 48 49* IF NOT i_maxcols IS INITIAL. 50** Delete all unimportant informations: 51* DELETE lt_temp_excel_file WHERE col GT 6. 52* ENDIF. 53* 54 ld_delimiter = i_delimiter. 55* 56* convert to line seperated by delimiter. 57* Set previouse column to zero 58 ld_prev_col = 0. 59 LOOP AT lt_temp_excel_file ASSIGNING <lfs_excel>. 60 61* determine the number of delimiters for 62* each inital column. If one column had got an initial value 63* 2 delimiters are added. 64 ld_initial_col = <lfs_excel>-col - ld_prev_col. 65 DO ld_initial_col TIMES. 66 CONCATENATE ls_result ld_delimiter INTO ls_result 67 IN CHARACTER MODE. 68 ENDDO. 69 ld_prev_col = <lfs_excel>-col. 70 71 AT NEW row. 72 CLEAR ls_result. 73 ENDAT. 74 75* avoid fields containing delimiter -> replace by '.' 76 IF <lfs_excel>-value CA ld_delimiter. 77 REPLACE ALL OCCURRENCES OF ld_delimiter 78 IN <lfs_excel>-value WITH '.' IN CHARACTER MODE. 79 ENDIF. 80 81 CONCATENATE ls_result <lfs_excel>-value INTO ls_result 82 IN CHARACTER MODE. 83 CONDENSE ls_result. 84 85 AT END OF row. 86 et_filecontent = ls_result. 87 APPEND et_filecontent. 88 CLEAR et_filecontent. 89* Set previouse column to zero 90 ld_prev_col = 0. 91 ENDAT. 92* end of note 770391 93 ENDLOOP. 94 95ENDFORM. " UPLOAD_EXECL

The remaining configuration, implementation details, and testing guidance continue from this answer more…

Related questions and keywords

Alternative questions

  • How is Excel upload processed in the MDG mass key mapping report?
  • What does the UPLOAD_EXECL form do in the key mapping upload include?
  • How are blank Excel columns and delimiter characters handled during key-mapping upload?

Possible questions

  • How does the MDG mass key mapping upload routine read Excel files and build row content in SAP ABAP?
  • How is Excel upload processed in the MDG mass key mapping report?
  • What does the UPLOAD_EXECL form do in the key mapping upload include?
  • How are blank Excel columns and delimiter characters handled during key-mapping upload?
  • How do I implement a similar Excel-to-internal-table upload routine in ABAP?

Keywords

MDGABAPmass key mappinguploadExcelFM_TABLINEexcel_to_internal_tableapplication logdelimiterrow limit