‎2006 Sep 04 3:37 PM
Guys,
I am using the below code to upload from Excel to internal table.
performaence is very bad please help on this.
CONSTANTS:wl_dat(3) TYPE c VALUE 'DAT'.
DATA: wf_infile LIKE rlgrap-filename,
wf_filetype LIKE rlgrap-filetype,
wf_filelen TYPE i,
wf_begcol TYPE i,
wf_begrow TYPE i,
wf_endcol TYPE i,
wf_endrow TYPE i,
wf_currentrow TYPE i.
wf_infile = p_pcfile.
wf_filetype = wl_dat.
wf_begcol = 1.
wf_begrow = 1.
wf_endcol = 14.
wf_endrow = 9999.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = wf_infile
i_begin_col = wf_begcol
i_begin_row = wf_begrow
i_end_col = wf_endcol
i_end_row = wf_endrow
TABLES
intern = int_file
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE e004 WITH text-014. "Problem uploading Excel Spreadsheet
ENDIF.
*Sort table by rows and colums
SORT int_file BY row col.
Get first row retrieved
READ TABLE int_file INDEX 1.
Set first row retrieved to current row
wf_currentrow = int_file-row.
LOOP AT int_file.
Reset values for next row
IF int_file-row NE wf_currentrow.
APPEND int_input.
CLEAR int_input.
wf_currentrow = int_file-row.
ENDIF.
CASE int_file-col.
WHEN '0001'. "Year
int_input-year = int_file-value.
WHEN '0002'. "Period
int_input-period = int_file-value.
WHEN '0003'. "amount
int_input-amount = int_file-value.
WHEN '0004'. "Company Code
int_input-coco = int_file-value.
WHEN '0005'. "Profit center
int_input-prtcen = int_file-value.
WHEN '0006'. "Country Code
int_input-ctryco = int_file-value.
WHEN '0007'. "Payer Customer
int_input-paycust = int_file-value.
WHEN '0008'. "Ending Balance
int_input-endbal = int_file-value.
WHEN '0009'. "Monthly Revenue Total
int_input-monrev = int_file-value.
ENDCASE.
ENDLOOP.
APPEND int_input.
CLEAR int_input.
regards,
vijay
‎2006 Sep 04 3:43 PM
hi,
by default that FM will take max time :
for better result do like this::
if not int_file[] is initial.
SORT int_file BY row col.
Get first row retrieved
READ TABLE int_file INDEX 1.
Set first row retrieved to current row
wf_currentrow = int_file-row.
LOOP AT int_file.
Reset values for next row
IF int_file-row NE wf_currentrow.
APPEND int_input.
CLEAR int_input.
wf_currentrow = int_file-row.
ENDIF.
CASE int_file-col.
WHEN '0001'. "Year
int_input-year = int_file-value.
WHEN '0002'. "Period
int_input-period = int_file-value.
WHEN '0003'. "amount
int_input-amount = int_file-value.
WHEN '0004'. "Company Code
int_input-coco = int_file-value.
WHEN '0005'. "Profit center
int_input-prtcen = int_file-value.
WHEN '0006'. "Country Code
int_input-ctryco = int_file-value.
WHEN '0007'. "Payer Customer
int_input-paycust = int_file-value.
WHEN '0008'. "Ending Balance
int_input-endbal = int_file-value.
WHEN '0009'. "Monthly Revenue Total
int_input-monrev = int_file-value.
ENDCASE.
<b>at end of row.</b>
APPEND int_input.
CLEAR int_input.
endat.
ENDLOOP.
endif.
endloop.
Regards
Ashok P
‎2006 Sep 04 4:03 PM
‎2006 Sep 04 5:11 PM
Hi,
Try using GUI_UPLOAD in your program.
I found nothing to optimise in your remaining code.
Thanks,
GSK