08-02-2007 3:11 PM
Im trying to use this function module to get the rows into internal table for upload into database, for some reason not all the 14403 records are not being loaded into the internal table.Only 10000 records are being loaded into the table. Below is my code can you guys help me out, its a little urgent.
p_table is reference to table whose structure is like.
Internal Table for uploading from Excel spreadsheet
DATA: BEGIN OF jtable OCCURS 0,
field_001(25) TYPE c, "Ship To
field_002(25) TYPE c, "Material
field_003(25) TYPE c, "Area
field_004(25) TYPE c, "Sales Org
field_005(25) TYPE c, "Comp Code
field_006(25) TYPE c, "Plant
field_007(25) TYPE c, "Version
field_008(25) TYPE c, "Currency
field_009(25) TYPE c, "UOM
field_010(25) TYPE c, "Fiscal Year
field_011(25) TYPE c, "Jan Qty
field_012(25) TYPE c, "Feb Qty
field_013(25) TYPE c, "Mar Qty
field_014(25) TYPE c, "Apr Qty
field_015(25) TYPE c, "May Qty
field_016(25) TYPE c, "Jun Qty
field_017(25) TYPE c, "Jul Qty
field_018(25) TYPE c, "Aug Qty
field_019(25) TYPE c, "Sep Qty
field_020(25) TYPE c, "Oct Qty
field_021(25) TYPE c, "Nov Qty
field_022(25) TYPE c, "Dec Qty
field_023(25) TYPE c, "Jan Rev
field_024(25) TYPE c, "Feb Rev
field_025(25) TYPE c, "Mar Rev
field_026(25) TYPE c, "Apr Rev
field_027(25) TYPE c, "May Rev
field_028(25) TYPE c, "Jun Rev
field_029(25) TYPE c, "Jul Rev
field_030(25) TYPE c, "Aug Rev
field_031(25) TYPE c, "Sep Rev
field_032(25) TYPE c, "Oct Rev
field_033(25) TYPE c, "Nov Rev
field_034(25) TYPE c, "Dec Rev
msg_011(50) TYPE c,
END OF jtable.
FORM c200-upload_file TABLES p_table
USING p_file.
Data Declarations.......................................
DATA : l_intern TYPE kcde_cells OCCURS 0 WITH HEADER LINE.
DATA : l_index TYPE i.
DATA : l_start_col TYPE i VALUE '1',
l_start_row TYPE i VALUE '1',
l_end_col TYPE i VALUE '256',
l_end_row TYPE i VALUE '65536'.
Field Symbols...........................................
FIELD-SYMBOLS : <fs>.
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_file
i_begin_col = l_start_col
i_begin_row = l_start_row
i_end_col = l_end_col
i_end_row = l_end_row
TABLES
intern = l_intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
.
IF sy-subrc <> 0.
MESSAGE E002(ZA). " File Error
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE : / 'File Error'.
EXIT.
ENDIF.
IF l_intern[] IS INITIAL.
MESSAGE E003(ZA). " No Data Uploaded
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE : / 'No Data Uploaded'.
EXIT.
ELSE.
SORT l_intern BY row col.
LOOP AT l_intern.
MOVE l_intern-col TO l_index.
ASSIGN COMPONENT l_index OF STRUCTURE p_table TO <fs>.
MOVE l_intern-value TO <fs>.
AT END OF row.
APPEND p_table.
CLEAR p_table.
ENDAT.
ENDLOOP.
ENDIF.
end form.
*One more thing the excel file contains 34 columns and 14403 rows.
08-06-2007 7:32 PM
Actuall there was some problem in the field symbols, i could'nt figure out though. My internal table to which the field symbol refers has one column more, so there was a problem when assigning the fields to the row of internal table so i had to use another if condition to put the fields in the internal table appropriately and i also removed the sort statement because for some reason it would fill my internal table with empty columns.
10-23-2012 3:32 PM
The reason of restriction 10000 records is type NUMC 4 for field ROW in DD-structure KCDE_CELLS.
You can make a modification of KCDE_CELLS and set type NUMC 5 (or more length) for the fields ROW and COL.
To solve the problem I've performed approximately the following steps (in SRM system):
- created function group ZKCDE;
in top-include define constant:
CONSTANTS: c_esc VALUE '"'.
- copied DD-structure KCDE_CELLS to ZKCDE_CELLS;
set type NUMC 5 for fields:
ROW
COL
i.e. I've increased the limit to 100000 records
- copied (and adapt) type group KCDE to ZKCDE
don't forget to use DD-structure zkcde_cells:
TYPES: BEGIN OF zkcde_intern_struc.
INCLUDE STRUCTURE zkcde_cells.
TYPES: END OF zkcde_intern_struc.
...
TYPES: zkcde_intern TYPE zkcde_intern_struc OCCURS 0.
- copied FM KCD_EXCEL_OLE_TO_INT_CONVERT to Z_KCD_EXCEL_OLE_TO_INT_CONVERT
correct type of table parameter INTERN to type ZKCDE_INTERN
- copied the following subroutines:
separated_to_intern_convert
line_to_cell_separat
line_to_cell_esc_sep
(I copied to FM Z_KCD_EXCEL_OLE_TO_INT_CONVERT)
- in my case I did in FM the following correction:
* <field> = c_hex_tab.
<field> = 9. " TAB