08-03-2006 5:00 PM
Hi all,
what does this stement mean
open dataset io_file for input in text mode.
open dataset io_file for output in text mode message msg.
can i see the data while debugging when the control triggers these statements
Thanks in advance
08-03-2006 5:04 PM
hi,
you cant see the data in debugging mode.
the Purpose of Open data set is:
OPEN DATASET <file name> FOR {OUTPUT/INPUT/APPENDING}
IN {TEXT/BINARY} MODE
This statement returns SY_SUBRC as 0 for successful opening of file or 8, if unsuccessful.
OUTPUT: Opens the file for writing. If the dataset already exists, this will place the cursor at the start of the dataset, the old contents get deleted at the end of the program or when the CLOSE DATASET is encountered.
INPUT: Opens a file for READ and places the cursor at the beginning of the file.
FOR APPENDING: Opens the file for writing and places the cursor at the end of file. If the file does not exist, it is generated.
BINARY MODE: The READ or TRANSFER will be character wise. Each time n characters are READ or transferred. The next READ or TRANSFER will start from the next character position and not on the next line.
IN TEXT MODE: The READ or TRANSFER will start at the beginning of a new line each time. If for READ, the destination is shorter than the source, it gets truncated. If destination is longer, then it is padded with spaces.
Defaults: If nothing is mentioned, then defaults are FOR INPUT and in BINARY MODE.
08-03-2006 5:06 PM
hi,
<b>open dataset io_file for input in text mode.</b>
this opens the dataset i.e, file stred in the application server and keeps the cursor at the beginning of the file and is ready to read the file line by line.....
<b>open dataset io_file for output in text mode message msg</b>.
this opens the dataset and is ready for writing on to that by placing the cursor at the start of the file....
Regards,
Santosh
08-03-2006 5:05 PM
These statements are used for opening files on the application server for writing to and reading from. You can write to a file on the app server by using the TRANSFER statement and you can read from the file using the READ DATASET statement. You can then close the file using the statement CLOSE DATASET.
Regards,
Rich Heilman
08-03-2006 5:05 PM
Hi Suchitra..
open dataset io_file for input in text mode....opens the application file in read mode and the data is read line by line
open dataset io_file for output in text mode message msg.
If an error occurs opening the file, the corresponding message of the operating system is stored in the field msg.
Regards,
VIdya
08-03-2006 5:13 PM
<b>open dataset io_file for input in text mode.</b>
this will open a file in input(read) mode.
<b>open dataset io_file for output in text mode message msg.</b>
this will open a file in write mode,
the addition MESSAGE MSG will be used to know if for any reason the file opening in write mode is failed,the error will be passed to MSG field.
you can check the MSG field after the OPEN DATASET statement.
regards
srikanth
08-03-2006 5:32 PM
Hi suchitra,
OPEN DATASET <dsn> FOR .... IN TEXT MODE.
If you read from or write to a file that is open in text mode, the data is transferred line by line. The system assumes that the file has a line structure.
In each TRANSFER statement, the system transfers all bytes (apart from spaces at the end) into the file, and places an end of line marker at the end. For information about the TRANSFER statement, refer to Writing Data to Files.
In each READ DATASET statement, the system reads all of the data up to the next end of line marker. For information about the READ DATASET statement, refer to Reading Data from Files. If the target field is too small, the line is truncated. If it is longer than the line in the file, it is filled with trailing spaces.
You should always use text mode if you want to write strings to files or where you know that an existing file has a line construction. You can, for example, use text mode to read files that you have created using any editor on your application server
Opening a File for Write Access
To open a file for writing, use the FOR OUTPUT addition to the OPEN DATASET statement.
Syntax
OPEN DATASET <dsn> FOR OUTPUT.
If the file does not already exist, it is created automatically. If it does already exist, but is closed, its contents are overwritten. If the file exists and is already open (for read or write access, or for appending), the position is reset to the beginning of the file. If the system can open the file <dsn> successfully, SY-SUBRC is set to 0. If not, it is set to 8.
DATA: MESS(60),
FNAME(10) VALUE '/tmp'.
OPEN DATASET FNAME FOR OUTPUT MESSAGE MESS.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC:', SY-SUBRC,
/ 'System Message:', MESS.
ENDIF.
regards,
keerthi.
08-03-2006 5:58 PM
Hi guys,
Now i have an idea.I tried to locate the file in application server using al11,i could not locate the file.Is this the right tcode because it shows the error files .I downloaded by giving the file location in sxdb t code ,i could download the data to presentation server.
I want to locate the file in application server could you guys tell me the t-code.
can i see the data during debugging.
open dataset io_file for input in text mode.
open dataset io_file for output in text mode message msg.
can i see the anything for this statements during debugging.
when i click io_file i see the location of file
msg i don't see any thing
pls do let me know
08-03-2006 6:03 PM
yes, AL11 is the transaction code to view files on application server.
but this system may have many no of folders.
so while using OPEN DATASET you should give the full ( absolute path).
what you are giving for OPEN DATASET, you should go to that folder in AL11, to see the file.
you can NOT See the data just for OPEN DATASET.
if you open the DATASET IN input MODE,
then while USING READ DATASET <FILENAME> INTO <VARIABLE> .
Here only you can see the read contents from the file.
regards
srikanth
08-03-2006 6:03 PM
hi suchitra,
U can see the files on appl. server in AL11 only..
search ur file in the the directory that u have specified..
08-03-2006 8:58 PM
hi guys,
IAM READING DATA FROM
DATA:
input like RFPDO-RFBIFILE default
'/user/dev/zxx/abc.abc.amb'.
open dataset input for input in text mode.
data: output like rfpdo-rfbifile value
'/user/dev/zxxx/abc.abc.amb'.
open dataset output for output in text mode message msg.
if sy-subrc ne 0.
message e999(00) with msg 'Cannnot open file' output.
endif.
I AM GETTING AN ERROR IN MSG AS
"No such file or directory"
LET ME KNOW IF I AM WRONG ANYWHERE
08-03-2006 9:01 PM
08-03-2006 9:05 PM
The message says it all. Since you are opening it for writing(output), it should not complain about file not existing.
Also, OUTPUT and INPUT are reserved words, so do not use those names for your files.
08-03-2006 9:21 PM
Hi rich and srinivas,
Rich its user, because
open dataset in for input in text mode.
if sy-subrc ne 0.
message e999(00) with 'Cannnot open file' input.
endif.
here sy-subrc is o
open dataset out for output in text mode message msg.
if sy-subrc ne 0.
message e398(00) with msg 'Cannnot open file' out.
endif.
here sy-subrc is not zero.
error no such file or directory.
I have a question do i need to create a directory before using in program or it creates automatcally.
DO LET ME KNOW
08-03-2006 9:26 PM
Directories are <b>not</b> created by OPEN DATASET statement. Only files are created.
08-03-2006 9:28 PM
08-03-2006 9:29 PM
08-03-2006 9:32 PM