08-18-2009 10:15 AM
Dear All,
I want to upload data existing in Excel sheet into SAP. Is there any possibility with the following requirements?
1) Excel file contains serial numbers with different values.Like power(230Wp),Voc,Isc,Vmp and Imp.
2) We need to upload the same data into SAP with validations.
3) Validations are like no serial number should be repeated.
4) And depending on the Power value, the serial number should be assigned to different batches.Eg:The batches are as follows:
201 - 210
210 - 220
220 - 230
and if the Pmax of the serial number is 205.It should be assigned to batch 201 - 210 .
5) At present we are using MB31 to post the serial numbers which are existing in the flat file.
Thanks and Regards,
Varun Siddharth
08-18-2009 10:21 AM
Hi Varun,
brwose SDN-Forum there are tons of hints regarding excel-upload to sap.
Regards
REA
08-18-2009 10:28 AM
08-18-2009 10:40 AM
08-18-2009 10:45 AM
Hi,
Refer to the following code:
DATA: lv_filetype(10) TYPE c,
lv_gui_sep TYPE c,
lv_file_name TYPE string.
lv_filetype = 'ASC'.
lv_gui_sep = 'X'.
lv_file_name = pa_dfile.
FM call to upload file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_file_name
filetype = lv_filetype
has_field_separator = lv_gui_sep
TABLES
data_tab = gi_zhralcon_file
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
The excel file must be a tab delimited file.
Hope it helps.
Regards,
Rajesh Kumar
08-18-2009 11:13 AM
Hi,
Use GUI_UPLOAD or TEXT_CONVERT_XLS_TO_SAP to convert the excel into internal table.
Perform all the required validations in the internal table like deleting duplicate records etc.
Now use update statement to upload the internal table values into the ZTABLE.
Regards,
Vik
08-18-2009 11:26 AM
Try
FM: ALSM_EXCEL_TO_INTERNAL_TABLE using
for example
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = FILEname
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 10
I_END_ROW = 10
TABLES
INTERN = IT_TAB
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
in this u can also change the start row,column and end row.column at run time.
08-18-2009 12:54 PM
HI,
To upload excel data into internal table you can try using,
DATA: it_raw TYPE truxs_t_text_data.
*&---------------------------------------------------------------------*
*&Function module called to upload xls data into an internal table
*&---------------------------------------------------------------------*
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_line_header = 'X'
i_tab_raw_data = it_raw
i_filename = p_file "file path browsed
TABLES
i_tab_converted_data = it_upload[] "int table populated
EXCEPTIONS
conversion_failed = 1 "browsed file's data
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.
Hope it helps
Regards
Mansi