Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Table is Not storing all data's

Former Member
0 Kudos

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

5 REPLIES 5

praveenboss
Participant
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi Praveen,

Can you please help me if you can solve my problem..

0 Kudos

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.

former_member195402
Active Contributor
0 Kudos

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

0 Kudos

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.