Application Development and Automation 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: 
Read only

getting dump in uplading excel sheet

Former Member
0 Likes
1,354

PARAMETERS : P_FILE LIKE RLGRAP-FILENAME DEFAULT 'C:\SALES_EXCEL'.

DATA : ITAB LIKE STANDARD TABLE OF ALSMEX_TABLINE .

DATA : ITAB1 LIKE ITAB.

*data : itab1 type itab.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = P_FILE

I_BEGIN_COL = 1

I_BEGIN_ROW = 1

I_END_COL = 256

I_END_ROW = 256

TABLES

INTERN = ITAB

  • EXCEPTIONS

  • INCONSISTENT_PARAMETERS = 1

  • UPLOAD_OLE = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

this code is geeting me dump can any one help.............

PARAMETERS : P_FILE LIKE RLGRAP-FILENAME DEFAULT 'C:\SALES_EXCEL'.

DATA : ITAB LIKE STANDARD TABLE OF ALSMEX_TABLINE .

DATA : ITAB1 LIKE ITAB.

*data : itab1 type itab.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = P_FILE

I_BEGIN_COL = 1

I_BEGIN_ROW = 1

I_END_COL = 256

I_END_ROW = 256

TABLES

INTERN = ITAB

  • EXCEPTIONS

  • INCONSISTENT_PARAMETERS = 1

  • UPLOAD_OLE = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

this code is geeting me dump can any one help.............

4 REPLIES 4
Read only

Former Member
0 Likes
859

Hi,

Look at the below example


*&---------------------------------------------------------------------*
*& Report  UPLOAD_EXCEL                                                *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*& Upload and excel file into an internal table using the following    *
*& function module: ALSM_EXCEL_TO_INTERNAL_TABLE                       *
*&---------------------------------------------------------------------*
REPORT  UPLOAD_EXCEL no standard page heading.

*Data Declaration
*----------------
data: itab like alsmex_tabline occurs 0 with header line.
* Has the following format:
*             Row number   | Colum Number   |   Value
*             ---------------------------------------
*      i.e.     1                 1             Name1
*               2                 1             Joe

TYPES: Begin of t_record,
    name1 like itab-value,
    name2 like itab-value,
    age   like itab-value,
    End of t_record.
DATA: it_record type standard table of t_record initial size 0,
      wa_record type t_record.
DATA: gd_currentrow type i.

*Selection Screen Declaration
*----------------------------
PARAMETER p_infile like rlgrap-filename.


************************************************************************
*START OF SELECTION
 call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
       exporting
            filename                = p_infile
            i_begin_col             = '1'
            i_begin_row             = '2'  "Do not require headings
            i_end_col               = '14'
            i_end_row               = '31'
       tables
            intern                  = itab
       exceptions
            inconsistent_parameters = 1
            upload_ole              = 2
            others                  = 3.
  if sy-subrc <> 0.
    message e010(zz) with text-001. "Problem uploading Excel Spreadsheet
  endif.

* Sort table by rows and colums
  sort itab by row col.

* Get first row retrieved
  read table itab index 1.

* Set first row retrieved to current row
  gd_currentrow = itab-row.

  loop at itab.
*   Reset values for next row
    if itab-row ne gd_currentrow.
      append wa_record to it_record.
      clear wa_record.
      gd_currentrow = itab-row.
    endif.

    case itab-col.
      when '0001'.                              "First name
        wa_record-name1 = itab-value.
      when '0002'.                              "Surname
        wa_record-name2 = itab-value.
      when '0003'.                              "Age
        wa_record-age   = itab-value.
    endcase.
  endloop.
  append wa_record to it_record.
*!! Excel data is now contained within the internal table IT_RECORD

* Display report data for illustration purposes
  loop at it_record into wa_record.
    write:/     sy-vline,
           (10) wa_record-name1, sy-vline,
           (10) wa_record-name2, sy-vline,
           (10) wa_record-age, sy-vline.
  endloop.

Regards

Sudheer

Read only

Former Member
0 Likes
859

Hi!

Try using exact filename with extension: 'C:SALES_EXCEL.xls'.

Check out, that the file is not used in your MS excel.

Regards

Tamá

Read only

Former Member
0 Likes
859

Hi,

This code is not giving me a dump.

Check "'C:\SALES_EXCEL' or C:\SALES_EXCEL.xls'

Regards

Arun

Read only

Former Member
0 Likes
859

Check with your file extension ?

file name would be file.xls .. and also do not open xl file while using program.

Do not comment Function module exception,if you want to know exact problem,then uncomment Exception,it gives sy-subrc value..

Chk this link for a sample program:

For excel file Upload check this link...

http://www.sapdevelopment.co.uk/file/file_upexcel.htm

Thanks

Seshu