2010 Mar 23 8:53 AM
HI All ,
I have file which i can read from GUI_UPLOAD but we need to read it
on OPEN DATASET for that i use the following code but i get in mess
No such file or directory
What i miss here since when i try to open it from start->run it's work and
also in GUI_UPLAOD but not in open data set
OPEN DATASET lv_path_file FOR INPUT IGNORING CONVERSION ERRORS
IN TEXT MODE ENCODING DEFAULT MESSAGE mess .
Regards
Alex
2010 Mar 23 9:04 AM
HI,
There is a basic difference between GUI upload and OPEN Dataset.
GUI uploads uploads file from presentation server into SAP. But Open dataset uploads from application server.
U seem to be trying to use open dataset for a file on ur desktop.
hope it helps,
Raj
2010 Mar 23 9:02 AM
Hello,
FOR INPUT is to read a already existing file in the application server. You will have to use FOR OUTPUT if you are creating the file
OPEN DATASET lv_path_file FOR OUTPUT IGNORING CONVERSION ERRORS
IN TEXT MODE ENCODING DEFAULT MESSAGE mess .
Vikranth
2010 Mar 23 9:22 AM
HI Vikranth ReddY ,
the file is already exist so any idea ?
Regards
Alex
2010 Mar 23 9:25 AM
Hello Alex,
I thought you were trying to create a file after using GUI_UPLOAD.
If the file already exists, make sure you are passing the correct file path from AL11 also check if you are able to view the file through AL11. Also what is the value of SY_SUBRC after the open dataset?
Vikranth
2010 Mar 23 9:40 AM
HI Vikranth ,
I Create file in transction FILE and i use 'FILE_GET_NAME' FM
to read the file from the location but now the problem is that the read
dataset i getting subrc 4 and the file contain data so what can be the reason
in this case ?
OPEN DATASET lv_path_file FOR INPUT IGNORING CONVERSION ERRORS
IN text MODE ENCODING DEFAULT MESSAGE mess .
DO.
READ DATASET lv_path_file INTO ls_file.
IF sy-subrc = 0.
APPEND ls_file TO lt_file .
ELSE.
EXIT.
ENDIF.
ENDDO.Thanks
Alex
2010 Mar 23 11:01 AM
Check whether the FM is returing logical file name or physical file name.
For OPEN DATASET, you need to specify the complete path.
2010 Mar 23 12:13 PM
Hi Alex,
What does the FM- FILE_GET_NAME return ?
Cross check before running the program using the file-name returned in earlier step by going to transaction AL11 (logical file paths for application server) and see if a file actually exists.
Plus the statement - OPEN DATASET <file> , needs not only the file directory path, but the complete file name,
i.e. say eg;- directory is TMP, in that a file by name "test.txt".
then ur filename value for OPEN DATASET should be "/tmp/test.txt".
Please try again this time.
Regards
Dedeepya C
2010 Mar 23 4:34 PM
HI dedeepya ,
it return the file path ( the full file path)
Regards
Alex
2010 Mar 23 9:04 AM
HI,
There is a basic difference between GUI upload and OPEN Dataset.
GUI uploads uploads file from presentation server into SAP. But Open dataset uploads from application server.
U seem to be trying to use open dataset for a file on ur desktop.
hope it helps,
Raj
2010 Mar 23 9:24 AM
HI Rajat ,
i drop it to server ,
when the file was on the desktop i use gui upload and it work fine .
Regards
Alex
Edited by: Alex Dean on Mar 23, 2010 10:25 AM
2010 Mar 23 9:41 AM
Did you check authority (SU53 or SE16 on table SPTH) - Are you able to see the data from AL11, not only the file name in the list ?
SY-SUBRC = 4 is an EOF condition, check the linefeed default value in parameter abap/NTfmode (or add a [linefeed |http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET_LINEFEED.htm]option to the OPEN DATASET)
Regards,
Raymond
2010 Mar 23 4:25 PM
HI Raymond
I am not see the file in AL11 ,
now i get sy-subrc = 0 after open data set but
the problem is that when i do read it's not opening (sy-subrc = 4 like below ) .any idea want could be the reason ?
READ DATASET lv_path_file INTO ls_file.
IF sy-subrc = 0.Regards
Alex
2010 Mar 23 4:59 PM
>
> I am not see the file in AL11 ,
> now i get sy-subrc = 0 after open data set but
> the problem is that when i do read it's not opening (sy-subrc = 4 like below ) .any idea want could be the reason ?
>
>
READ DATASET lv_path_file INTO ls_file. > IF sy-subrc = 0.
If you cannot see the file in the app server directory how do you expect to READ it
2010 Mar 23 5:52 PM
HI Suhas ,
the file is in server and i create entry in TR . file
when I do open data set i get subrc = 0,
i guess if it dont find the file the i get subrc 8 .
bu the read is not work well do you have any idea ?
p.s.
do you say that if the file is not exist in AL11 i cant read it so i need to create entry there
and dont use TR.FILE
Regards
Alex
2010 Mar 23 6:20 PM
What you are doing in FILE is basically creating logical filename & filepath. When you do so you donot create a physical file with its contents in the app server.
SY-SUBRC = 4 for READ DATASET implies that End Of File is reached & there are no contents in the file left to be read.
[http://help.sap.com/abapdocu_70/en/ABAPREAD_DATASET.htm|http://help.sap.com/abapdocu_70/en/ABAPREAD_DATASET.htm]
I think you have uploaded an empty file in the app server.
BR,
Suhas
PS: Try uploading the file to the app server using CG3Z trxn or CACS_FILE_COPY trxn & check if the READ DATASET stmt is failing.
Edited by: Suhas Saha on Mar 23, 2010 11:51 PM
2010 Mar 24 7:25 AM
If you don't see the file via AL11, you wont be able to read data with OPEN/READ DATASET. You must be able to see the filename in AL11 with an 'X' indicating that you are allowed to use it, and you must be able to display data when double-clicking on it.
On which OS do you operate, is there a text in the mess field after OPEN DATASET ?
Regards,
Raymond
2010 Mar 24 8:17 AM
Hi Raymond ,
What i want actually is that the user will define the file path VIA transaction file
and read it from my program
are you sure that this is not possible ? since when i do that i gui upload its works
but with open data set i don't get any data after the read data set as i mentioned in
my previos post .
Thanks
Alex
lc_lo_fname TYPE fileintern VALUE 'MY_FILE_NAME',
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
logical_filename = lc_lo_fname
operating_system = sy-opsys
* PARAMETER_1 = '01'
IMPORTING
emergency_flag = lv_flag
file_format = lv_format
file_name = lv_file_name
EXCEPTIONS
file_not_found = 1.
** Reading the contents of the physical file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_file_name
IMPORTING
filelength = lv_file_length
TABLES
data_tab = lt_file_tab
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.
2010 Mar 24 8:22 AM
How have you defined your logical file 'MY_FILE_NAME' ?
I think you have given a presentation server file (file is present on your PC hard disk) because of which GUI_UPLOAD is working.
BR,
Suhas
2010 Mar 24 9:08 AM
HI ,
I give the file path define term for my file under logical file path than double click
on assignments of Physical path ,
in put my system and the Physical path like
vms025\shared\<FILENAME>
and in the physical file i put the file like user.csv
data format ASC
application area BC
ETC
How can i drop the file in AL11 ?
Regards
ALex
Edited by: Alex Dean on Mar 24, 2010 10:35 AM
2010 Mar 24 9:37 AM
If the file is defined on application server use OPEN DATASET, on operation system use GUI_UPLOAD. You may add a radiobuttion on selection-screen (PC/Appl) and use this flag in
- FILE_GET_NAME (filling OPERATING_SYSTEM parameter from the selected option)
- Main program read data form with a IF/OPEN DATASET/ELSE/GUI_UPLOAD/ENDIF
Regards,
Raymond
2010 Mar 24 9:50 AM
HI Raymond ,
You say in your previos post that the file need to be in application in order to use it
i.e. AL11 if not i cant use it in open data set ,so how i can put the file fin AL11 ?
Regards
Alex
2010 Mar 24 9:55 AM
2010 Mar 23 9:07 AM
2010 Mar 23 9:38 AM
HI Raymond ,
I Create file in transaction file and i use 'FILE_GET_NAME' FM
to read the file from the location but now the problem is that the read
dataset I getting subrc 4 and the file contain data so what can be the reason
in this case ?
OPEN DATASET lv_path_file FOR INPUT IGNORING CONVERSION ERRORS
IN text MODE ENCODING DEFAULT MESSAGE mess .
DO.
READ DATASET lv_path_file INTO ls_file.
IF sy-subrc = 0.
APPEND ls_file TO lt_file .
ELSE.
EXIT.
ENDIF.
ENDDO.Thanks
Alex
2010 Mar 23 5:19 PM
Hi,
Did you check autohorizations? For server application SAP uses other than your username.
Best regards,
Maria João Rocha
2010 Mar 23 5:54 PM
HI ,
I dont think that this relate to authorisation since it's not fail in open data set ,
i get subrc = 0 .
Regards
Alex
2010 Mar 24 4:01 AM
How is your ls_file declared, try changing it into a variable of type string or use a field symbol and try.
2010 Mar 24 6:03 AM
If u UPLOAD FILE Then u can not use OPEN DATASET lv_path_file FOR INPUT but u can use
OPEN DATASET iv_path FOR OUTPUT insted of input u use output
Example :-
htab = cl_abap_char_utilities=>horizontal_tab.
OPEN DATASET filepath FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
2010 Mar 24 8:24 AM
Hey Alex,
If you want user to enter the file path ( on application server ), please use FM /SAPDMC/LSM_F4_SERVER_FILE instead of FILE_GET_NAME.
If you are not able to see your folder or file with this FM, please check for authorization with your BASIS team.
Hope it helps,
Raj