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: 

ALSM_EXCEL_TO_INTERNAL_TABLE not working properly

Former Member
0 Kudos

Hi Gurus,

I am using ALSM_EXCEL_TO_INTERNAL_TABLE for uplaoding an excel file.Then some operations are being performed on the data.Initially it is working fine (checked in debugger) but at the end (mass testing) it is giving a dump.

Please suggest why this is happening and how to correct it.

Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

ALSM_EXCEL_TO_INTERNAL_TABLE has a constraint of number of records. Check the components ROW and COl of the structure ALSMEX_TABLINE in tables.They are NUMC 4 and both can thus have a maximum value of 9999.

If you go for mass testing it wont be successfull if the number of records are even10000.

Instead of this you can use FM TEXT_CONVERT_XLS_TO_SAP.

Regards.

10 REPLIES 10

former_member333737
Active Participant
0 Kudos

Hi,

chk dis coding,

FORM upload_items_from_excel.

  DATA: fname        LIKE rlgrap-filename,
        wintitle     TYPE string,
        lv_subrc     TYPE i,
        li_filetable TYPE STANDARD TABLE OF file_table,
        uptab        LIKE TABLE OF alsmex_tabline WITH HEADER LINE,
        quanstr      TYPE char30,
        matnum(18)   TYPE n,
        quantity     TYPE esecompavg.


* Select excel file on front end
  wintitle = text-002.
  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title            = wintitle
      initial_directory       = 'C:\'
    CHANGING
      file_table              = li_filetable
      rc                      = lv_subrc
    EXCEPTIONS
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      OTHERS                  = 4.

 
  READ TABLE li_filetable INDEX 1 INTO fname.
  CHECK fname <> space.

* upload excel file to internal table
  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      filename                = fname
      i_begin_col             = 1
      i_begin_row             = 1
      i_end_col               = 2
      i_end_row               = 500
    TABLES
      intern                  = uptab
    EXCEPTIONS
      inconsistent_parameters = 1
      upload_ole              = 2
      OTHERS                  = 3.

Regards,

Nikhil.

Former Member
0 Kudos

Hi,

Just check the sy-subrc and see in the exceptions for the reason.

regards

Natasha Garg

naveen_kumar116
Active Participant
0 Kudos

Hi,

Check the Size of your Excel file or check the EXCEL is been open or not...

Check whether the Byte allocation to the internal Table is sufficient or not....Check DUMP analysis.

Former Member
0 Kudos

Hi,

ALSM_EXCEL_TO_INTERNAL_TABLE has a constraint of number of records. Check the components ROW and COl of the structure ALSMEX_TABLINE in tables.They are NUMC 4 and both can thus have a maximum value of 9999.

If you go for mass testing it wont be successfull if the number of records are even10000.

Instead of this you can use FM TEXT_CONVERT_XLS_TO_SAP.

Regards.

Former Member
0 Kudos

parameter:p_infile like rlgrap-filename obligatory.

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 = '22'

i_end_row = '10000'

TABLES

intern = itab1

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

others = 3.

if sy-subrc <> 0.

message e010(zz) with text-001. "Problem uploading

Excel Spreadsheet

endif.

kesavadas_thekkillath
Active Contributor
0 Kudos

When reporting a error ... try to paste the dump analysis..

Former Member
0 Kudos

check how you are passing the file to the aslm function module , file extension may be wrong

Former Member
0 Kudos

Hi,

Please refer the sample code below,


*&---------------------------------------------------------------------*
*&Function module called to upload xls data into an internal table
*&---------------------------------------------------------------------*

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
 EXPORTING
i_field_seperator    = 'X'
 i_line_header        = 'X'
i_tab_raw_data       = it_raw
 i_filename           = p_file_path
  TABLES
  i_tab_converted_data = it_upload[]     "internal table having same struc as that of the flat files
 EXCEPTIONS
  conversion_failed    = 1
 OTHERS               = 2.
IF it_upload[] IS INITIAL.
   MESSAGE e002(zmsg).
  ELSE.
  ENDIF.

Hope it helps

Regards

Mansi

Former Member
0 Kudos

example


tables: RLGRAP.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE  TEXT-001.
PARAMETER : postdate TYPE vbak-erdat DEFAULT sy-datum.
PARAMETERS:    P_FILE LIKE RLGRAP-FILENAME
                DEFAULT 'C:\Documents and Settings\ztest.xls' OBLIGATORY.   " File Name
SELECTION-SCREEN END OF BLOCK B1.

At selection-screen on value-request for P_FILE.
    perform get_file_name.

FORM get_file_name.

   
        CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
* EXPORTING
*   PROGRAM_NAME        = SYST-REPID
*   DYNPRO_NUMBER       = SYST-DYNNR
*   FIELD_NAME          = ' '
*   STATIC              = ' '
*   MASK                = ' '
  CHANGING
    file_name           = P_FILE
* EXCEPTIONS
*   MASK_TOO_LONG       = 1
*   OTHERS              = 2
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


ENDFORM.                    " get_file_name

Former Member
0 Kudos

one more example


form UPLOAD_FILE  tables   p_it_tab
                  using    p_file.

FIELD-SYMBOLS : <FS>.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  EXPORTING
    filename                      = P_FILE
    i_begin_col                   = '1'
    i_begin_row                   = '2'
    i_end_col                     = '256'
    i_end_row                     = '10000'
  tables
    intern                        = L_INTERN
 EXCEPTIONS
   INCONSISTENT_PARAMETERS       = 1
   UPLOAD_OLE                    = 2
   OTHERS                        = 3
          .
IF sy-subrc NE 0.
   FORMAT COLOR COL_BACKGROUND INTENSIFIED.
   WRITE : / 'File Error'.
   EXIT.
ENDIF.

IF L_INTERN[] IS INITIAL.
   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_IT_TAB TO <FS>.
     MOVE L_INTERN-VALUE TO <FS>.
     AT END OF ROW.
       APPEND p_IT_TAB.
       CLEAR p_IT_TAB.
     ENDAT.
   ENDLOOP.
 ENDIF.

endform.