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

.dat file creation on Application server

Former Member
0 Likes
1,918

Hi All,

I need to create one file with extension ".dat" on Application server. I hv no clue how should I proceed with this.

I just know We can use OPEN DATASET to create, read & write into files on Application server.

How could we deal about extension of these files?

Thanks in advance.

Prasad

2 REPLIES 2
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
898

Here is an example of copying a file on the backend.

Notice the extensions.




report zrich_0001.

Parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt',
            d2 type localfile default '/usr/sap/TST/SYS/Data2.dat'.

data: begin of itab occurs 0,
      rec(20) type c,
      end of itab.
data: wa(20) type c.


start-of-selection.

  open dataset d1 for input in text mode.
  if sy-subrc = 0.
    do.
      read dataset d1 into wa.
      if sy-subrc <> 0.
        exit.
      endif.
      itab-rec = wa.
      append itab.
    enddo.
  endif.
  close dataset d1.

  open dataset d2 for output in text mode.
  loop at itab.
    transfer itab to d2.
  endloop.
  close dataset d2.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
898

Hi Prasad,

Filename (including extension) doesn't really matter for these statements, you can choose whatever extension you want. Example given above is a good starter. Please pay attention to the "mode" used for opening dataset/file. Choose the one that meets your requirement. I feel you should use "binary" mode.

Cheers,

Sanjeev