‎2008 Aug 04 3:31 PM
Hi,
I need to convert the excel file data into internal table. The format of internal table is
TYPES : BEGIN OF type_header_record,
record_type(1),
document_date(8),
posting_date(8),
company_code(4),
header_text(100),
currency_key(5),
exchange_rate(10),
document_type(2),
reference_document_number(50),
tax(1),
END OF type_header_record.
I don' t want IT format in col, row, descrpiton format.
Plz help
‎2008 Aug 04 3:33 PM
‎2008 Aug 04 3:33 PM
hiii
use following code for getting data into internal table
*Upload data from Excel sheet to internal table.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_pfile
i_begin_col = 1
i_begin_row = 2
i_end_col = 13
i_end_row = 8
TABLES
intern = it_excel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*Populate data to internal tables and structures
SORT it_excel BY row col.
LOOP AT it_excel INTO ls_excel.
CASE ls_excel-col.
WHEN 1.
ls_data-rec_no = ls_excel-value.
IF ls_data-rec_no NE w_docno.
WRITE:
'You Have Entered wrong Document Number'.
ELSE.
WRITE:
'Document Number Same'.
ENDIF. " IF ls_data-rec_no NE w_docno.
WHEN 2.
ls_data-doc_type = ls_excel-value.
WHEN 3.
ls_data-doc_part = ls_excel-value.
WHEN 4.
ls_data-doc_ver = ls_excel-value.
WHEN 5.
ls_data-application = ls_excel-value.
WHEN 6.
ls_data-data_car = ls_excel-value.
WHEN 7.
ls_data-file_path = ls_excel-value.
WHEN 8.
ls_data-matnr = ls_excel-value.
ENDCASE. " CASE ls_excel-col.regards
twinkal
‎2008 Aug 04 3:35 PM
Save your File as Tabdelimited file and then use the GUI_UPLOAD with fieldseparator = 'X' , this will load the data to internal table.
‎2008 Aug 04 3:35 PM
data: T_TEMP like standard table of ALSMEX_TABLINE,
P_FILE type RLGRAP-FILENAME value 'D:\test.xls'.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
FILENAME = P_FILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 6
I_END_ROW = 100
tables
INTERN = T_TEMP
exceptions
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
others = 3.