‎2008 Jun 03 4:24 AM
Hi, Experts
I upload excel(.XLS) to a internal table whose type is
BIN.
How to convert this internal table data to another
internal table whose fields type is like sap?
Thanks you very much!
‎2008 Jun 03 4:32 AM
Hi Ken....
data: ta_excel type standard table of alsmex_tabline initial
size 0,
wa_excel type alsmex_tabline.
----
Selection screen *
----
selection-screen begin of block session_process with frame title text-001.
parameter: pa_file type rlgrap-filename obligatory. "File Name
selection-screen end of block session_process.
----
At Selection screen *
----
at selection-screen on value-request for pa_file.
call function 'F4_FILENAME'
exporting
field_name = 'PA_FILE'
importing
file_name = pa_file.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = pa_file
i_begin_col = 1 " this important frm which col
i_begin_row = 1 "you have data
i_end_col = 255
i_end_row = 65000
tables
intern = ta_excel
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc <> 0.
MESSAGE E000 WITH TEXT-E01 PA_FILE.
endif.
Sorting table by Rows and Columns.
sort ta_excel by row col.
Get ROW 1.
read table ta_excel into wa_excel index 1.
Match First Row to Current Row
tp_currentrow = wa_excel-row.
loop at ta_excel into wa_excel.
Reset Values for Next Row
if wa_excel-row ne tp_currentrow.
append wa_mm01 to ta_mm01.
clear wa_mm01.
tp_currentrow = wa_excel-row.
endif.
case wa_excel-col.
when'0001'.
wa_mm01-matnr = wa_excel-value.
when'0002'.
wa_mm01-mbrsh = wa_excel-value.
when'0003'.
wa_mm01-mtart = wa_excel-value.
when'0004'.
wa_mm01-werks = wa_excel-value.
when'0005'.
wa_mm01-lgnum = wa_excel-value.
when'0006'.
wa_mm01-lgtyp = wa_excel-value.
when'0007'.
wa_mm01-ltkza = wa_excel-value.
when'0008'.
wa_mm01-ltkze = wa_excel-value.
when'0009'.
wa_mm01-lgpla = wa_excel-value.
endcase.
endloop.
append wa_mm01 to ta_mm01.
Regards,
Sg
‎2008 Jun 03 5:47 AM
Suneel Kumar,
Thanks you for your help!
But I can not use the function 'ALSM_EXCEL_TO_INTERNAL_TABLE', because the excel is a attachment of activity in CRM.
‎2008 Jun 03 6:01 AM