05-22-2007 11:39 AM
Hi,
I have an excel file which has to be uploaded to the internal table.
But this FM needs importing parameter as below:
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = i_file
I_BEGIN_COL = C1
I_BEGIN_ROW = R1
I_END_COL = Cn
I_END_ROW = <b>??</b>
TABLES
INTERN = itab
.
I have the filename, I have the internal table. But for other parameters, begin_col, begin_row and end_col, I can pass no problem.
But, I don't know how many records will be there in the excel file unless it is uploaded to my internal table itab.
And it is mandatory to give <b>i_end_row</b>, which I dont know.
Please suggest me how do I upload the contents of to itab.
Thanks in adcance,
Ishaq.
05-22-2007 11:44 AM
DATA:iexcel TYPE TABLE OF alsmex_tabline WITH HEADER LINE.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = path1
i_begin_col = 1
i_begin_row = 1
i_end_col = 4
i_end_row = 60000
TABLES
intern = iexcel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0 .
WRITE :/15 'FILE NOT UPLOADED. INVALID FILE NAME OR PATH.' COLOR 6 .
EXIT.
ENDIF.
LOOP AT iexcel.
IF iexcel-col = '0001'.
itab-etsrk = iexcel-value.
ENDIF.
IF iexcel-col = '0002'.
itab-evbgd = iexcel-value.
ENDIF.
IF iexcel-col = '0003'.
itab-evend = iexcel-value.
ENDIF.
IF iexcel-col = '0004'.
itab-tlsrk = iexcel-value.
ENDIF.
AT END OF row.
APPEND itab.
ENDAT.
CLEAR iexcel.
ENDLOOP.
REFRESH iexcel.
05-22-2007 11:42 AM
Plz try to upload the data using the GUI_UPLOAD. I think ure pblem will be solved.
05-22-2007 11:44 AM
DATA:iexcel TYPE TABLE OF alsmex_tabline WITH HEADER LINE.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = path1
i_begin_col = 1
i_begin_row = 1
i_end_col = 4
i_end_row = 60000
TABLES
intern = iexcel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0 .
WRITE :/15 'FILE NOT UPLOADED. INVALID FILE NAME OR PATH.' COLOR 6 .
EXIT.
ENDIF.
LOOP AT iexcel.
IF iexcel-col = '0001'.
itab-etsrk = iexcel-value.
ENDIF.
IF iexcel-col = '0002'.
itab-evbgd = iexcel-value.
ENDIF.
IF iexcel-col = '0003'.
itab-evend = iexcel-value.
ENDIF.
IF iexcel-col = '0004'.
itab-tlsrk = iexcel-value.
ENDIF.
AT END OF row.
APPEND itab.
ENDAT.
CLEAR iexcel.
ENDLOOP.
REFRESH iexcel.
05-22-2007 11:45 AM
Hi,
i have used this FM , where i have given 200 for "End Column" & 5000 for en rowen
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '200'
i_end_row = '5000'.
U can give anything not a problem..
Reward Points if it is Useful.
Thanks,
Manjunath MS
intern = xcel
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
05-22-2007 11:47 AM
Hi..
Its nothing but the number of records u need to move from excel to ur internal table.For example if u have 20 fields and 50 records in ur excel sheet,
i_begin_col is the first field of the 20 fields u want to import into internal table.
i_begin_row is the first record of 50 records from where u wan to import the data.
similarly for i_end_col and i_end_row are the records upto where u want to select the data.
Regards,
kamal
05-22-2007 11:53 AM
Hi Ali,
You can try this FM
data: W_FILE_XLS LIKE IBIPPARMS-PATH, "to store file path
W_FILE_TXT TYPE STRING,
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR = 'X'
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = W_DATA
I_FILENAME = W_FILE_XLS
TABLES
I_TAB_CONVERTED_DATA = T_T510_1.
05-22-2007 12:00 PM
Give a large no. like '99999'. you can also use FM
TEXT_CONVERT_XLS_TO_SAP