2006 Aug 14 5:30 PM
Hi all ,
I want to read a filename from server .can any one reply me how to write unix read statement?
Thanks
2006 Aug 14 5:43 PM
hi,
check the below link for it
http://www.sapgenie.com/abap/unixfile.htm
u can check one more file also
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3cc0358411d1829f0000e829fbfe/content.htm
Regards,
Naveen
hi,
check the below link for it
http://www.sapgenie.com/abap/unixfile.htm
u can check one more file also
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3cc0358411d1829f0000e829fbfe/content.htm
Regards,
Naveen
2006 Aug 14 5:36 PM
data: YourFile(50).
data: TheStr(200).
YourFile = '/somedir/filename.txt'.
open dataset YourFile for input in text mode encoding default.
do.
read dataset YourFile into TheStr.
if sy-subrc <> 0.
exit.
endif.
do some business logic here
enddo.
close dataset YourFile.
2006 Aug 14 5:41 PM
Jhon ,
I dont want to open my file .I just want to read the server whether that file exisit or not .I just want read the server for a file name.
Thanks
2006 Aug 14 5:56 PM
2006 Aug 14 6:01 PM
If the file exists, sy-subrc will be 0 (zero) upon returning from the FM call.
And don't forget points for helpful answers.
2006 Aug 14 6:45 PM
To prove it to yourself, find a file in a certain path on your UNIX and run the FM against it. SY-SUBRC will be ZERO.
Then delete (or move) the file and run again. SY-SUBRC will NOT be zero now.
2006 Aug 14 5:43 PM
hi,
check the below link for it
http://www.sapgenie.com/abap/unixfile.htm
u can check one more file also
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3cc0358411d1829f0000e829fbfe/content.htm
Regards,
Naveen
2006 Aug 14 5:47 PM
Naveen,
I dont want to upload data from unix file . i just want to check the directory for file existitance.
Thanks
2006 Aug 14 5:49 PM
Re: Unix read statement
Posted: Aug 14, 2006 11:36 AM Reply E-mail this post
data: YourFile(50).
data: TheStr(200).
YourFile = '/somedir/filename.txt'.
open dataset YourFile for input in text mode encoding default.
IF SY-SUBRC <> 0.
File does not exist
ENDIF.
2006 Aug 14 6:22 PM
Priya,
Has your issue been resolved?
If so, please reward points accordingly and close the thread.
If not, please provide more details of the issue.
Thanks in advance.
2006 Aug 14 6:34 PM
2006 Aug 14 6:43 PM
Priya,
It will handle frontend or your backend filesystem.
You must place an "X" into FRONTEND to search your client PC. You must leave FRONTEND as a blank to search your system's core filesystem.
Note the code of the Func Mod:
IF FRONTEND = 'X'.
handle frontend
s_filename = filename.
call method cl_gui_frontend_services=>file_exist
exporting
file = s_filename
receiving
result = result
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
WRONG_PARAMETER = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5
.
if sy-subrc <> 0 or result <> 'X'.
raise not_found.
endif.
ELSE.
handle backend <<< Priya - here it looks to core filesystem
A_FILENAME = FILENAME.
CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
EXPORTING
PROGRAM = 'ZDATASET'
ACTIVITY = SABC_ACT_READ
FILENAME = A_FILENAME
EXCEPTIONS
NO_AUTHORITY = 1
ACTIVITY_UNKNOWN = 2.
CHECK SY-SUBRC = 0.
OPEN DATASET FILENAME FOR INPUT IN BINARY MODE.
IF SY-SUBRC = 0.
CLOSE DATASET FILENAME.
ENDIF.
ENDIF.
IF SY-SUBRC <> 0.
RAISE NOT_FOUND.
ENDIF.
ENDFUNCTION.
And note that it actually performs a simple OPEN DATASET as I cited above to verify IF the file exists.
2006 Aug 14 7:21 PM
In most of the function modules SAP uses OPEN DATASET to check for file existance. That's the prefered method.
If ur app server is unix, you can try this:
data: v_cmd type rlgrap-filename,
v_fnam type rlgrap-filename.
data: begin of t_cmd occurs 0,
line(200),
end of t_cmd.
v_fnam = <full file name with path>
concatenate ls v_fnam into v_cmd separated by space.
call 'SYSTEM' id 'COMMAND' field v_cmd
id 'TAB' field t_cmd-sys.
if not t_cmd[] is initial.
write:/ v_fnam 'Exist'.
endif.
Regards
Sridhar
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |