Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Data Handling on Application Server

Former Member
0 Likes
414

Hi,

Some one please give me a detailed document of handling the data on application server.

Thanx in advance,

Ram

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
392

OPEN DATASET dset FOR access IN mode [position]

[ os_addition]

[error_handling].

This statement opens the file specified in dset for the access specified in access in a storage mode specified in mode. For dset, a character-type data object is expected, which contains the platform-specific name of the file.

Use additions position, os_addition and error_handling to determine the position at which to open the file, to specify platform-specific additions and to influence error handling.

In Unicode programs, the access and storage modes access and mode must be specified explicitly. If the additions are missing in non-Unicode programs, the file is opened implicitly as a binary file for read access.

In Unicode programs, the file must not yet be open in the current program; otherwise a treatable exception occurs. In non-Unicode programs, the file may already be open. The statement OPEN DATASET then does not reopen the file but moves the read or write position depending on the access mode. In this case, you should not change the access or storage mode.

TRANSFER

TRANSFER dobj TO dset [LENGTH len]

[NO END OF LINE].

Extras:

1. ... LENGTH len

2. ... NO END OF LINE

Effect

This statement passes the content of data object dobj to the file specified in dset. For dobj, you can specify data objects with elementary data types and flat structures. In Unicode programs, dobj must be character-type if the file was opened as a text file (this restriction does not apply to legacy text files).

dset is expected to be a character-type data object that contains the platform-specific name of the file. The content is written to the file from the current file pointer. After the transfer, the file pointer is positioned after the data that was added. You can use addition LENGTH to restrict the number of characters or bytes transferred

In a Unicode program, the file for writing, appending, or changing must be open. Otherwise, a treatable exception occurs.

If the file is closed in a non-Unicode program, the file is implicitely opened using the statement OPEN DATASET dset FOR OUTPUT IN BINARY MODE as a binary file for writing. If the system accesses an invalid file, a treatable exception is raised.

The access type defined in statement OPEN DATASET has the following effect on the transfer:

A file opened for reading using FOR INPUT cannot be written in Unicode programs. In non-Unicode programs, TRANSFER writes in a file opened for reading using FOR INPUT in exactly the same way as a file opened for changing using FOR UPDATE.

In a file opened for writing using FOR OUTPUT, the system writes to the file from the current file pointer. If the file pointer is positioned after the current start of the file, the file is pre-filled with hexadecimal 0 from the start of the file to the file pointer.

In a file opened for appending using FOR APPENDING, the system writes to the file from the current file pointer, which is always at the end of the file.

In a file opened for changing using FOR UPDATE, the system writes to the file from the current file pointer. If the file pointer is positioned after the end of the file, the file is pre-filled with hexadecimal 0 between the end of the file and the file pointer position.

READ DATASET

READ DATASET dset INTO dobj [MAXIMUM LENGTH mlen]

[[ACTUAL] LENGTH alen].

Extras:

1. ... MAXIMUM LENGTH mlen

2. ... [ACTUAL] LENGTH alen

This statement exports data from the file specified in dset into the data object dobj. For dobj, variables with elementary data types and flat structures can be specified. In Unicode programs, dobj must be character-type if the file was opened as a text file.

For dset, a character-type data object is expected - that is, an object that contains the platform-specific name of the file. The content is read from the file starting from the current file pointer. After the data transfer, the file pointer is positioned after the section that was read. Using the MAXIMUM LENGTH addition, the number of characters or bytes to be read from the file can be limited. Using ACTUAL LENGTH, the number of characters or bytes actually used can be determined.

In a Unicode program, the file must be opened with an arbitrary access type; otherwise, an exception that cannot be handled will be triggered.

If the file has not yet been opened in a non-Unicode program, it will be implicitly opened as a binary file for read access using the statement

OPEN DATASET dset FOR INPUT IN BINARY MODE.

. If a non-existing file is accessed, an exception that can be handled can be triggered.

System Fields

sy-subrc Meaning

0 Data was read without reaching end of file.

4 Data was read and the end of the file was reached or there was an attempt to read after the end of the file.

Influence of Access Type

Files can be read independently of the access type. Whether data can be read or not depends solely on the position of the file pointer. If the latter is at the end of the file or after the file, no data can be read and sy-subrc will be set to 4.

Influence of the Storage Type

The import function will take place irrespective of the storage type in which the file was opened with the statement OPEN DATASET.

If the file was opened as a text file or as a legacy text file, the data is normally read from the current position of the file pointer to the next end-of-line marking, and the file pointer is positioned after the end-of-line marking. If the data object dobj is too short for the number of read characters, the superfluous characters and bytes are cut off. If it is longer, it will be filled with blanks to the right.

If the file was opened as a binary file or as a legacy-binary file, as much data is read that fits into the data object dobj. If the data object dobj is longer than the number of exported characters, it is filled with hexadecimal 0 on the right.

If the specified storage type makes conversion necessary, this is executed before the assignment to the data object dobj. Afterwards, the read data is placed, byte by byte, into the data object.

CLOSE DATASET

CLOSE DATASET dset.

This statement closes the file specified in dset. dset must be character-type data object that contains the platform-specific name of the file. If the file is already closed or does not exist, the statement is ignored and the return value sy-subrc is set to 0.

If the operating system buffers data before it is written to a file and there is still data in the buffer, this data is written to the file before closing.

An opened file that was not explicitly closed using CLOSE DATASET is automatically closed when the program is exited.

System fields

If a file was opened without the FILTER addition, sy-subrc always contains the value 0.

If a file was opened using the FILTER addition, sy-subrc contains the return value of the filter program, which is returned by the operating system. This value is generally 0 if the statement was executed successfully.

DELETE DATASET

DELETE DATASET dset.

Effect

This statement deletes the file specified in dset. dset is expected to be a character-type data object that contains the platform-specific name of the file. The file can be opened or closed.

2 REPLIES 2
Read only

Bema
Active Participant
0 Likes
392
Read only

Former Member
0 Likes
393

OPEN DATASET dset FOR access IN mode [position]

[ os_addition]

[error_handling].

This statement opens the file specified in dset for the access specified in access in a storage mode specified in mode. For dset, a character-type data object is expected, which contains the platform-specific name of the file.

Use additions position, os_addition and error_handling to determine the position at which to open the file, to specify platform-specific additions and to influence error handling.

In Unicode programs, the access and storage modes access and mode must be specified explicitly. If the additions are missing in non-Unicode programs, the file is opened implicitly as a binary file for read access.

In Unicode programs, the file must not yet be open in the current program; otherwise a treatable exception occurs. In non-Unicode programs, the file may already be open. The statement OPEN DATASET then does not reopen the file but moves the read or write position depending on the access mode. In this case, you should not change the access or storage mode.

TRANSFER

TRANSFER dobj TO dset [LENGTH len]

[NO END OF LINE].

Extras:

1. ... LENGTH len

2. ... NO END OF LINE

Effect

This statement passes the content of data object dobj to the file specified in dset. For dobj, you can specify data objects with elementary data types and flat structures. In Unicode programs, dobj must be character-type if the file was opened as a text file (this restriction does not apply to legacy text files).

dset is expected to be a character-type data object that contains the platform-specific name of the file. The content is written to the file from the current file pointer. After the transfer, the file pointer is positioned after the data that was added. You can use addition LENGTH to restrict the number of characters or bytes transferred

In a Unicode program, the file for writing, appending, or changing must be open. Otherwise, a treatable exception occurs.

If the file is closed in a non-Unicode program, the file is implicitely opened using the statement OPEN DATASET dset FOR OUTPUT IN BINARY MODE as a binary file for writing. If the system accesses an invalid file, a treatable exception is raised.

The access type defined in statement OPEN DATASET has the following effect on the transfer:

A file opened for reading using FOR INPUT cannot be written in Unicode programs. In non-Unicode programs, TRANSFER writes in a file opened for reading using FOR INPUT in exactly the same way as a file opened for changing using FOR UPDATE.

In a file opened for writing using FOR OUTPUT, the system writes to the file from the current file pointer. If the file pointer is positioned after the current start of the file, the file is pre-filled with hexadecimal 0 from the start of the file to the file pointer.

In a file opened for appending using FOR APPENDING, the system writes to the file from the current file pointer, which is always at the end of the file.

In a file opened for changing using FOR UPDATE, the system writes to the file from the current file pointer. If the file pointer is positioned after the end of the file, the file is pre-filled with hexadecimal 0 between the end of the file and the file pointer position.

READ DATASET

READ DATASET dset INTO dobj [MAXIMUM LENGTH mlen]

[[ACTUAL] LENGTH alen].

Extras:

1. ... MAXIMUM LENGTH mlen

2. ... [ACTUAL] LENGTH alen

This statement exports data from the file specified in dset into the data object dobj. For dobj, variables with elementary data types and flat structures can be specified. In Unicode programs, dobj must be character-type if the file was opened as a text file.

For dset, a character-type data object is expected - that is, an object that contains the platform-specific name of the file. The content is read from the file starting from the current file pointer. After the data transfer, the file pointer is positioned after the section that was read. Using the MAXIMUM LENGTH addition, the number of characters or bytes to be read from the file can be limited. Using ACTUAL LENGTH, the number of characters or bytes actually used can be determined.

In a Unicode program, the file must be opened with an arbitrary access type; otherwise, an exception that cannot be handled will be triggered.

If the file has not yet been opened in a non-Unicode program, it will be implicitly opened as a binary file for read access using the statement

OPEN DATASET dset FOR INPUT IN BINARY MODE.

. If a non-existing file is accessed, an exception that can be handled can be triggered.

System Fields

sy-subrc Meaning

0 Data was read without reaching end of file.

4 Data was read and the end of the file was reached or there was an attempt to read after the end of the file.

Influence of Access Type

Files can be read independently of the access type. Whether data can be read or not depends solely on the position of the file pointer. If the latter is at the end of the file or after the file, no data can be read and sy-subrc will be set to 4.

Influence of the Storage Type

The import function will take place irrespective of the storage type in which the file was opened with the statement OPEN DATASET.

If the file was opened as a text file or as a legacy text file, the data is normally read from the current position of the file pointer to the next end-of-line marking, and the file pointer is positioned after the end-of-line marking. If the data object dobj is too short for the number of read characters, the superfluous characters and bytes are cut off. If it is longer, it will be filled with blanks to the right.

If the file was opened as a binary file or as a legacy-binary file, as much data is read that fits into the data object dobj. If the data object dobj is longer than the number of exported characters, it is filled with hexadecimal 0 on the right.

If the specified storage type makes conversion necessary, this is executed before the assignment to the data object dobj. Afterwards, the read data is placed, byte by byte, into the data object.

CLOSE DATASET

CLOSE DATASET dset.

This statement closes the file specified in dset. dset must be character-type data object that contains the platform-specific name of the file. If the file is already closed or does not exist, the statement is ignored and the return value sy-subrc is set to 0.

If the operating system buffers data before it is written to a file and there is still data in the buffer, this data is written to the file before closing.

An opened file that was not explicitly closed using CLOSE DATASET is automatically closed when the program is exited.

System fields

If a file was opened without the FILTER addition, sy-subrc always contains the value 0.

If a file was opened using the FILTER addition, sy-subrc contains the return value of the filter program, which is returned by the operating system. This value is generally 0 if the statement was executed successfully.

DELETE DATASET

DELETE DATASET dset.

Effect

This statement deletes the file specified in dset. dset is expected to be a character-type data object that contains the platform-specific name of the file. The file can be opened or closed.