06-04-2009 12:16 PM
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.
06-04-2009 12:26 PM
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.
06-04-2009 12:18 PM
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.
06-04-2009 12:19 PM
Hi,
Just check the sy-subrc and see in the exceptions for the reason.
regards
Natasha Garg
06-04-2009 12:25 PM
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.
06-04-2009 12:26 PM
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.
06-04-2009 12:27 PM
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.
06-04-2009 12:28 PM
06-04-2009 12:29 PM
check how you are passing the file to the aslm function module , file extension may be wrong
06-04-2009 12:31 PM
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
06-04-2009 1:04 PM
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
06-04-2009 1:09 PM
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.