Skip to Content
0
Former Member
Sep 11, 2007 at 12:10 PM

What is opening, reading etc dataset

23 Views

Hi all,

What does the following code do?

I do not know why to open a dataset etc.

Thanks in advance.

Deniz.

*-- Open dataset for reading 

DATA: 
  dsn(20) VALUE '/usr/test.dat', 
  rec(80). 

OPEN DATASET dsn FOR INPUT IN TEXT MODE. 
IF sy-subrc = 0. 
  DO. 
    READ DATASET dsn INTO rec. 
    IF sy-subrc <> 0. 
      EXIT. 
    ELSE. 
      WRITE / rec. 
    ENDIF. 
  ENDDO. 
ENDIF. 
CLOSE DATASET dsn. 

*-- Open dataset for writing 

DATA rec(80). 

OPEN DATASET dsn FOR OUTPUT IN TEXT MODE. 
  TRANSFER rec TO '/usr/test.dat'. 
CLOSE DATASET dsn.