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

sequential file handling

Former Member
0 Likes
1,301

hi experts, iam new to this ....

can anybody send me some examples of file handling inthis...

i need some example code to upload a file to application server and to download a file from application server.

and how to see that files in application server.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
919

ABAP/4 provides below statements for handling files:

OPEN DATASET

CLOSE DATASET

DELETE DATASET

READ DATASET

TRANSFER

OPEN DATASET

Opens the specified file. If you do not use any additions, the file is opened for reading in binary mode. It returns SY-SUBRC = 0 if the file is opened successfully. Otherwise SY-SUBRC = 8.

Syntax

OPEN DATASET <dsn> [Additions].

Additions:

1. FOR INPUT ( Default )

2. FOR OUTPUT

3. FOR APPENDING

4. IN BINARY MODE

5. IN TEXT MODE

6. AT POSITION p

7. TYPE ctrl

8. MESSAGE mess

9. FILTER f

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm

CLOSE DATASET

Closes the specified file.

Syntax

CLOSE DATASET <dsn>.

DELETE DATASET

Deletes the file specified file. If it deletes the file successfully it returns SY-SUBRC = 0. Otherwise returns SY-SUBRC = 4. The possible reasons for failing are:

The file does not exist.

The file is a directory.

The file is a program that is currently running.

READ DATASET

Used to read a record from a file.

Syntax

READ DATASET dsn INTO f.

Addition : LENGTH len.

The actual length of the data objet read is placed in the field len after the read access. len must be defined as a variable. A syntax error will occur if you define it as a constant. The following example displays 9.

TRANSFER statement

Used to write a record into a file.

Syntax

TRANSFER f TO dsn.

Transfers the data object f to a sequential file whose name is specified in dsn. dsn can be a field or a literal. You must already have opened the file. . If the specified file is not already open, TRANSFER attempts to open the file FOR OUTPUT IN BINARY MODE. If this is not possible, a runtime error occurs.f can be a field, a string, or a structure.

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

4 REPLIES 4
Read only

Former Member
0 Likes
920

ABAP/4 provides below statements for handling files:

OPEN DATASET

CLOSE DATASET

DELETE DATASET

READ DATASET

TRANSFER

OPEN DATASET

Opens the specified file. If you do not use any additions, the file is opened for reading in binary mode. It returns SY-SUBRC = 0 if the file is opened successfully. Otherwise SY-SUBRC = 8.

Syntax

OPEN DATASET <dsn> [Additions].

Additions:

1. FOR INPUT ( Default )

2. FOR OUTPUT

3. FOR APPENDING

4. IN BINARY MODE

5. IN TEXT MODE

6. AT POSITION p

7. TYPE ctrl

8. MESSAGE mess

9. FILTER f

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm

CLOSE DATASET

Closes the specified file.

Syntax

CLOSE DATASET <dsn>.

DELETE DATASET

Deletes the file specified file. If it deletes the file successfully it returns SY-SUBRC = 0. Otherwise returns SY-SUBRC = 4. The possible reasons for failing are:

The file does not exist.

The file is a directory.

The file is a program that is currently running.

READ DATASET

Used to read a record from a file.

Syntax

READ DATASET dsn INTO f.

Addition : LENGTH len.

The actual length of the data objet read is placed in the field len after the read access. len must be defined as a variable. A syntax error will occur if you define it as a constant. The following example displays 9.

TRANSFER statement

Used to write a record into a file.

Syntax

TRANSFER f TO dsn.

Transfers the data object f to a sequential file whose name is specified in dsn. dsn can be a field or a literal. You must already have opened the file. . If the specified file is not already open, TRANSFER attempts to open the file FOR OUTPUT IN BINARY MODE. If this is not possible, a runtime error occurs.f can be a field, a string, or a structure.

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

Read only

0 Likes
919

1)

You can use t/code <b>CG3Y</b> to download a file from application server to presentation server and t/code <b>CG3Z</b> to upload a file to a application server from presentation server.

2)use transaction <b>AL11</b> to c file in application server

kishan negi

Read only

gopi_narendra
Active Contributor
0 Likes
919
  • Open Dataset

CATCH SYSTEM-EXCEPTIONS dataset_cant_open = 8.

OPEN DATASET unix_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

ENDCATCH.

  • Write to Dataset

LOOP AT it_str INTO is_str.

CATCH SYSTEM-EXCEPTIONS dataset_not_open = 0 .

TRANSFER is_str-str TO unix_file.

ENDCATCH.

ENDLOOP.

IF sy-subrc EQ 0.

MESSAGE s138(zsm) WITH 'Data Downloaded to Unix File'.

ENDIF.

  • Close Dataset

CLOSE DATASET unix_file.

TRANSFER will write to teh aplication server

READ DATASET will read from teh application server

Regards

- Gopi