‎2007 Jan 23 10:20 AM
i am doing a BDC where i am using a excel sheet toload the master data.i am loading the data through the function module 'TEXT_CONVERT_XLS_TO_SAP'.But its throwing an error and not loading the file saying incorrect date format.
Can someone tell me how to solve the issue??
Thanks in anticipation.
‎2007 Jan 23 10:24 AM
Hi Supriya,
One Suggestion: You can save the Excel data file into tab delimited format and use normal GUI_UPLOAD FM.
OR refer sample code.
Use FM ALSM_EXCEL_TO_INTERNAL_TABLE
TYPES:
BEGIN OF ty_upload,
field1 TYPE c length 12,
field2 TYPE c length 12,
field3 TYPE c length 12,
END OF ty_upload.
DATA it_upload TYPE STANDARD TABLE OF ty_upload WITH DEFAULT KEY.
DATA wa_upload TYPE ty_upload.
DATA itab TYPE STANDARD TABLE OF alsmex_tabline WITH DEFAULT KEY.
FIELD-SYMBOLS: <wa> type alsmex_tabline.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = filename
i_begin_col = 1
i_begin_row = 1
i_end_col = 3
i_end_row = 65535
TABLES
intern = itab.
LOOP AT itab ASSIGNING <wa>.
CASE <wa>-col.
WHEN '0001'.
wa_upload-field1 = <wa>-value.
WHEN '0002'.
wa_upload-field2 = <wa>-value.
WHEN '0003'.
wa_upload-field3 = <wa>-value.
ENDCASE.
APPEND wa_upload TO it_upload.
CLEAR wa_upload.
ENDLOOP.
**********another way*******
TYPE-POOLS truxs.
tables : ztable.
types: begin of t_tab,
col1(5) type c,
col2(5) type c,
col3(5) type c,
end of t_tab.
data : itab type standard table of t_tab,
wa type t_tab.
data it_type type truxs_t_text_data.
parameter p_file type rlgrap-filename.
data ttab type tabname.
at selection-screen on value-request for p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = p_file
.
start-of-selection.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
i_tab_raw_data = it_type
i_filename = p_file
tables
i_tab_converted_data = itab[]
EXCEPTIONS
CONVERSION_FAILED = 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.
end-of-selection.
loop at itab into wa.
ztable-col1 = wa-col1.
ztable-col2 = wa-col2.
ztable-col3 = wa-col3.
modify ztable.
endloop.
Reward points if this Helps.
Manish
‎2007 Jan 23 10:25 AM
Hi,
There may be a type mismatch between the value that you are passing to the date field. Data field has to be in this format,
'yyyy' followed by 'mm' followed by 'dd'.
You can provide the value of the field as 'yyyymmdd',
Note- Do not provide special characters in between like '.' or '/' as we usually do.
Best Regards,
Vijay
‎2007 Jan 23 10:38 AM
hi manish ,
i_end_col = 3
i_end_row = 65535
how would i know the number of records to be loaded.as in would i give a range there???