2006 Nov 03 4:00 AM
Hi ,
I am using the following FM to upload an EXCEL file.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_file
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 3
I_END_ROW = 4
TABLES
INTERN = t_datain2
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
it works fine but, i have one more requirement, the number of lines in the excel sheet is going to decided according to the file that the user is going to upload. therefore i cannot hardcode the value i_end_row an i_col for the function module. i there any workaround for this.
Regards
Narendiran Rathinavelu.
Hi ,
I am using the following FM to upload an EXCEL file.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_file
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 3
I_END_ROW = 4
TABLES
INTERN = t_datain2
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
it works fine but, i have one more requirement, the number of lines in the excel sheet is going to decided according to the file that the user is going to upload. therefore i cannot hardcode the value i_end_row an i_col for the function module. i there any workaround for this.
Regards
Narendiran Rathinavelu.
2006 Nov 03 4:10 AM
Hi Narendiran,
U can fix the no. of rows / no. of columns to maximum value, so that it will work for any excel sheet.
- Satya Priya
2006 Nov 03 4:18 AM
hi
is there anyway of dynamically determining this file length at runtime.
Regards
Narendiran Rathinavelu
2006 Nov 03 4:19 AM
i mean the number of rows or columns
Regards
Narendiran Rathinvelu
2006 Nov 03 4:12 AM
Use this.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file
FILETYPE = 'ASC'
has_field_separator = '#'
TABLES
data_tab = t_datain2[].
2006 Nov 03 4:18 AM
hi
good
yes i think you can do this, check this example
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = FILENM
i_begin_col = 1
i_begin_row = 1
i_end_col = 100
i_end_row = 30000
tables
intern = IEXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
if sy-subrc <> 0.
WRITE: / 'EXCEL UPLOAD FAILED ', FILENM, SY-SUBRC.
ELSE.
SORT IEXCEL BY row col.
LOOP AT IEXCEL.
IF NOHEADER = 'X'
AND IEXCEL-row = 1.
CONTINUE.
ENDIF.
tind = IEXCEL-col.
CONCATENATE 'DATA_TAB-VALUE_' tind INTO zwfeld.
ASSIGN (zwfeld) TO <fs1>.
<fs1> = IEXCEL-value.
AT END OF row.
APPEND data_tab.
WRITE:/ 'data_tab ', data_tab-value_0001, data_tab-value_0002,
data_tab-value_0003, data_tab-value_0004.
CLEAR data_tab.
ENDAT.
ENDLOOP.
endif.
thanks
mrutyun^
2006 Nov 03 4:21 AM
Hi,
thanks for the response, is there anyway of obtaining the number of lines and number of rows dynamicaly in this case.
Regards
Narendiran Rathinavelu
2006 Nov 03 5:28 AM
Hi Narendiran,
After uploading the excel sheet with i_end_col and i_end_row set to max values, u can get the no.of rows and no. of columns from the table t_datain2. Like
declare one more table t_datain1 type t_datain2.
t_datain1[] = t_datain2[]
sort t_datain1 by row descending.
read table t_datain1 index 1. *Gets the no. of rows in XL
t_datain1[] = t_datain2[]
sort t_datain1 by col descending.
read table t_datain1 index 1.
*Gets the no. of columns in XL
-Satya Priya Vepakomma
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |