2006 Oct 12 12:12 PM
HI ,
i need to upload a excel file, I am able to get records form excel to internal table, using ws_upload FM.
But i m getting a # in between every fields.
I have used split at '#' into field1 field2... but it is not working. Can anybody help me onthis.. plz..
Kumar
HI ,
i need to upload a excel file, I am able to get records form excel to internal table, using ws_upload FM.
But i m getting a # in between every fields.
I have used split at '#' into field1 field2... but it is not working. Can anybody help me onthis.. plz..
Kumar
2006 Oct 12 12:17 PM
use GUI_UPLOAD
or
ALSM_EXCEL_TO_INTERNAL_TABLE
Funtion modules
2006 Oct 12 12:18 PM
try the below code
REPORT zupload_excel_to_itab.
TYPE-POOLS: truxs.
PARAMETERS: p_file TYPE rlgrap-filename.
TYPES: BEGIN OF t_datatab,
col1(30) TYPE c,
col2(30) TYPE c,
col3(30) TYPE c,
END OF t_datatab.
DATA: it_datatab type standard table of t_datatab,
wa_datatab type t_datatab.
DATA: it_raw TYPE truxs_t_text_data.
At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
TABLES
i_tab_converted_data = it_datatab[] "ACTUAL DATA
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.
END-OF-SELECTION.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/ wa_datatab-col1,
wa_datatab-col2,
wa_datatab-col3.
ENDLOOP.
ViveK
2006 Oct 12 12:18 PM
Hi,
Try using the function module "GUI_UPLOAD". Make sure you pass the interface parameter "HAS_FIELD_SEPARATOR" as #.
Manoj
2006 Oct 12 12:20 PM
Both upload and ws_upload does the same functionality, that is transfere data from presentation server to application server or from PC to SAP system(to an internal table).
There are very few difference between the two.
1 Upload requires a User Interaction for uploading i.e., user has to respond to the dialog boxes that appear WS_Upload does not. You just need to specify the file location in the function input parameters itself.
2 upload - u can give the file in run time wsupload - u have to give in Function module
3 upload is meant to be used by abappers. ws_upload is meant to be called by SAP. It is not a standard ABAP command.
4 ws_upload is Obsolete : No longer supported by SAP. Use <b>GUI_UPLOAD</b> instead.
2006 Oct 12 12:29 PM
Manoj,
if i use "HAS_FIELD_SEPARATOR" as #, i am able to get only first coloumn correctly. Other coloumns from the file are missing.
kumar
2006 Oct 12 12:36 PM
If i use GUI_upload,
then i m getting records like this..
"5000797#10#10.01.2006#00.00.0000#Not Found in CRM Link table for 09" . Here if i use "split lt_excel-text AT ',' into f1 f2 f3 f4 f5.", then it is not spliting.
If i use has_field_seperator = '#', then i am getting records like this, "5000797". Only first coloumn is getting properly. Others are gone.
Plz help me in this.
Kumar
2006 Oct 12 12:48 PM
Hi,
Does your Internal table passed to GUI_UPLOAD has all the columns specified in the Excel file. In other words, the number of columns in the internal table and Excel file should be the same.
Manoj
2006 Oct 12 12:39 PM
Hi Nitin,
*..............................................................
*: Description :
*: ----------- :
*: This is a simple example program to get data from an excel :
*: file and store it in an internal table. :
*: :
*:............................................................:
REPORT zupload_excel_to_itab.
TYPE-POOLS: truxs.
PARAMETERS: p_file TYPE rlgrap-filename.
TYPES: BEGIN OF t_datatab,
col1(30) TYPE c,
col2(30) TYPE c,
col3(30) TYPE c,
END OF t_datatab.
DATA: it_datatab type standard table of t_datatab,
wa_datatab type t_datatab.
DATA: it_raw TYPE truxs_t_text_data.
* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
TABLES
i_tab_converted_data = it_datatab[] "ACTUAL DATA
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.
END-OF-SELECTION.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/ wa_datatab-col1,
wa_datatab-col2,
wa_datatab-col3.
ENDLOOP.
See the below link for one more example:-
http://www.sapdevelopment.co.uk/file/file_upexcel2.htm
Regards
SUdheer
2006 Oct 12 12:41 PM
2006 Oct 12 12:43 PM
SOrry all,
i didnt mention you. I am working on CRM server. I dont have these function modules like aslm_excel_internal_table,
AND THE below example i tried, it is not working for me too..
i have got the data, but i am getting the problem in the split at '#'. it is splitting only for the first occurence and leaving the others. even i tried split for all occurences. it didnt work. my file type is ASC.
kumar
2006 Oct 12 12:45 PM
try this
replace all occurrences of '#' in v_str with '/'.
then use split at '/'
2006 Oct 23 5:41 PM
Try using the function module "GUI_UPLOAD". Make sure you pass the interface parameter HAS_FIELD_SEPARATOR = 'X'
2008 Apr 30 7:34 AM
Hi I have encountered this problem too. After trying different solutions, I guess that FM 'GUI_UPLOAD' is
not supposed to upload an excel file. So please try FM 'TEXT_CONVERT_XLS_TO_SAP' as below. It works.
*..............................................................
*: Description :
*: -
:
*: This is a simple example program to get data from an excel :
*: file and store it in an internal table. :
*: :
*: Author : www.sapdev.co.uk, based on code from Jayanta :
*: :
*: SAP Version : 4.7 :
*:............................................................:
TYPE-POOLS: truxs.
PARAMETERS: p_file TYPE rlgrap-filename. "To retrieve the upload file name
TYPES: BEGIN OF t_datatab,
col1(10) TYPE c,
col2(10) TYPE c,
col3(10) TYPE c,
END OF t_datatab.
DATA: it_datatab type standard table of t_datatab,
wa_datatab type t_datatab.
DATA: it_raw TYPE truxs_t_text_data.
At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR = 'X'
i_line_header = 'X' "To ignore the header line(the first line) if it is 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
TABLES
i_tab_converted_data = it_datatab[] "ACTUAL DATA
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.
END-OF-SELECTION.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/ wa_datatab-col1,
wa_datatab-col2,
wa_datatab-col3.
ENDLOOP.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |