‎2009 Feb 13 2:28 PM
Hi Everyone......
I hope this might be a common problem but i searched for similar problem......i did'nt find the solution my problem is
I'm trying to download .xls(excel file data into an internal table using OPEN DATASET FOR INPUT IN TEXT MODE ENCODING DEFUALT and read dataset for reading it).But in the read dataset syntax all stange values like **$#@&&& are getting uploaded???? I dont now why......
Is it happing because i'm trying to upload .XLS file ???
My coding is as follows...........
OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
IF sy-batch IS INITIAL.
MESSAGE i001(zz) WITH 'Error opening file for upload'.
EXIT.
ELSE.
MESSAGE s001(zz) WITH 'Error opening file for upload'.
EXIT.
ENDIF.
ENDIF.
*First Uploading the data into structure
DO.
READ DATASET p_file INTO l_wa_tab. "My internal table work area
IF sy-subrc = 0.
APPEND l_wa_tab TO l_tab.
ELSE.
EXIT.
ENDIF.
ADD 1 TO count.
ENDDO.
CLOSE DATASET p_file.
Any solution for above problem.........
‎2009 Feb 13 2:39 PM
> Is it happing because i'm trying to upload .XLS file ???
>
You are trying read XLS in text mode , not possible to read xls from app server in text mode
Try to convert the xls file as csv or space tab delimited file then try
a®
‎2009 Feb 13 2:39 PM
> Is it happing because i'm trying to upload .XLS file ???
>
You are trying read XLS in text mode , not possible to read xls from app server in text mode
Try to convert the xls file as csv or space tab delimited file then try
a®
‎2009 Feb 13 5:19 PM
Hi
Thx for the quick response......Do we have any syntax which can does this in SAP like in my case getting the data from .xls file from application server.........without downloading the file from application server to presentation server..........or converting the file into .txt or CVS formatt............Because the end users are kind of lazy guys and want SAP to every thing
‎2009 Feb 13 2:42 PM
Hi,
Just try to download the data using transaction CG3Y and see if u r getting the data in excel. If not there is something wrong with file download to application server.
Manually upload excel to app server using tcode CG3Z and then run ur program.
Thanks,
Vinod.
‎2009 Feb 13 2:42 PM
Hi,
Check whether path ur providing to the open data set stmt is correct or not in debugging mode.
* File upload to internal table from UNIX Directory
IF NOT p_i1file IS INITIAL AND NOT p_path IS INITIAL.
CONCATENATE p_path p_i1file INTO v_file.
CONDENSE v_file.
OPEN DATASET v_file FOR INPUT IN TEXT MODE MESSAGE v_msg.
IF sy-subrc EQ 0.
WRITE: / 'INPUT FILE CONTAINS NO RECORD :'(010), v_file.
DO.
CLEAR tbl_input.
READ DATASET v_file INTO tbl_input.
IF sy-subrc NE 0.
EXIT.
ELSE.
APPEND tbl_input.
ENDIF.
ENDDO.
* Close Input File
CLOSE DATASET v_file.
ELSE.
WRITE:/'Error uploading file: '(008),v_file.
STOP.
ENDIF.
ENDIF.It should work.check the sy-subrc value and file value in debug mode.
Thanks
Parvathi
‎2009 Feb 13 2:44 PM
Hi Younus ,
I too have the same code except one change in IF condition ..
but it works fine.
OPEN DATASET i_filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
DO.
READ DATASET i_filename INTO gw_record_input-rec.
IF sy-subrc EQ 0.
APPEND gw_record_input TO gi_record_input.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET i_filename.
ENDIF.
ENDIF.
See if the above code works in yopur case.
And also change the above file to extension .csv
Edited by: Sumit Mittal on Feb 13, 2009 3:45 PM
‎2009 Feb 13 2:47 PM
Hi friend,
Simple use following T-codes.
Download/upload file between application server and presentation server
CG3Y - Downloads file - Download file from Application server
CG3Z - Uploads file - Upload file to Application server
Hope might be useful
Thnks....
‎2009 Feb 13 5:28 PM
have you tried using ALSM_EXCEL_TO_INTERNAL_TABLE? You don´t need to format the .xls file and as far as I know, it works in the application server
Yo uare only getting the wird characters because excel files are not just plain text.
‎2009 Jun 08 5:05 PM
‎2010 Aug 03 10:29 AM
hi Younus,
May I know how you read the excel file from application server to internal table?
Regards,
Arun.
‎2011 Sep 20 6:25 AM
Hi Youins
I am also faceing the same problem.
Please put some light on this as u say u resolved the problem.
Right now i am doing the from application server to presention server .
and then Presention Server to Internal table.
But I want do in background.
Thanks,
Nitin
‎2011 Sep 20 7:18 AM
Hi,
Do the following to read an Excel file into an internal table.
TYPE-POOLS: truxs.
DATA: v_file_name TYPE rlgrap-filename,
it_type TYPE truxs_t_text_data.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_tab_raw_data = it_type
i_filename = v_file_name
TABLES
i_tab_converted_data = itab
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
Internal table ITAB contains your uploaded data.
Regards,
Danish.