07-01-2015 11:36 AM
Hi Gurus,
I have created a Z table and i have to upload 13000 records in this z table and for this i have written the below code but i am not able to ulpoad all the data's it uploaded only 8755 records could you please assist me as below are the code.
REPORT zupload_prg.
tables: zupld.
TYPES: BEGIN OF t_datatab ,
mandt TYPE zupld-mandt,
zzstd_dsc TYPE zupld-zzstd_dsc,
spras TYPE zupld-spras,
END OF t_datatab.
DATA: it_datatab TYPE STANDARD TABLE OF t_datatab INITIAL SIZE 0,
wa_datatab TYPE t_datatab.
DATA : gd_scol TYPE i VALUE '1',
gd_srow TYPE i VALUE '1',
gd_ecol TYPE i VALUE '256',
gd_erow TYPE i VALUE '15000'.
DATA: it_tab TYPE filetable,
gd_subrc TYPE i.
*Selection screen definition
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_file LIKE rlgrap-filename
DEFAULT 'c:\test.xls' OBLIGATORY. " File Name
SELECTION-SCREEN END OF BLOCK b1.
***********************************************************************
* AT SELECTION-SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
REFRESH: it_tab.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select File'
default_filename = '*.xls'
multiselection = ' '
CHANGING
file_table = it_tab
rc = gd_subrc.
LOOP AT it_tab INTO p_file.
* so_fpath-sign = 'I'.
* so_fpath-option = 'EQ'.
* append so_fpath.
ENDLOOP.
***********************************************************************
* START-OF-SELECTION.
START-OF-SELECTION.
PERFORM upload_excel_file TABLES it_datatab
USING p_file
gd_scol
gd_srow
gd_ecol
gd_erow.
***********************************************************************
END-OF-SELECTION.
IF it_datatab IS NOT INITIAL.
Modify zupld FROM TABLE it_datatab.
IF sy-subrc = 0.
WRITE : 'Data Uplaoded Sucessfully'.
ENDIF.
ENDIF.
END-OF-SELECTION.
*&--------------------------------------------------------------------*
*& Form UPLOAD_EXCEL_FILE
*&--------------------------------------------------------------------*
* upload excel spreadsheet into internal table
*---------------------------------------------------------------------*
* -->P_TABLE Table to return excel data into
* -->P_FILE file name and path
* -->P_SCOL start column
* -->P_SROW start row
* -->P_ECOL end column
* -->P_EROW end row
*---------------------------------------------------------------------*
FORM upload_excel_file TABLES p_table
USING p_file
p_scol
p_srow
p_ecol
p_erow.
DATA : lt_intern TYPE kcde_cells OCCURS 0 WITH HEADER LINE.
DATA : ld_index TYPE i.
FIELD-SYMBOLS : <fs>.
* Note: Alternative function module - 'ALSM_EXCEL_TO_INTERNAL_TABLE'
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_file
i_begin_col = p_scol
i_begin_row = p_srow
i_end_col = p_ecol
i_end_row = p_erow
TABLES
intern = lt_intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
WRITE:/ 'Error Uploading file'.
EXIT.
ENDIF.
IF lt_intern[] IS INITIAL.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE:/ 'No Data Uploaded'.
EXIT.
ELSE.
SORT lt_intern BY row col.
LOOP AT lt_intern.
MOVE lt_intern-col TO ld_index.
ASSIGN COMPONENT ld_index OF STRUCTURE p_table TO <fs>.
MOVE lt_intern-value TO <fs>.
AT END OF row.
APPEND p_table.
ENDAT.
ENDLOOP.
ENDIF.
ENDFORM. "UPLOAD_EXCEL_FILE
08-27-2015 12:11 PM
09-11-2015 6:59 AM
Hi Praveen,
Can you please help me if you can solve my problem..
09-24-2015 12:30 PM
Hi,
can you please just use ' ALSM_EXCEL_TO_INTERNAL_TABLE' instead?
It is a better alternative .
or, you can also put a break point on the line CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'.
and check what the table lt_intern contains at that point ? does it contain all 13000 records ?
Please check and let us know.
09-24-2015 12:41 PM
Hi Brijesh,
maybe your internal table from excel file contains duplicate entries for your Z-table.
Sort your internal table, delete adjacent duplicates comparing all z-table key fields and check, how many entries will remain.
Regards
Klaus
09-24-2015 12:53 PM
Just to add, it may happen that the client contains some other value in excel sheet.
Like I want to update data in client 100, but in excel for some of the entries I am putting 150 instead of 100.