
Tuesday, November 22, 2011
at
1:20 AM
|
0
comments
In SAP ABAP you can read file with open dataset,
The command used to read a file on the application server is as follows.
OPEN DATASET ... FOR INPUT
Please see example code below.
REPORT YSANTO_12 .
data: lv_fname(100),
  lv_msg like sy-msgv1.
data: begin of gi_data occurs 0,
      txt(255),
  end of gi_data.
lv_fname = '/home/data/data.txt'.
open dataset lv_fname for input message lv_msg in text mode encoding default.
if sy-subrc = 0.
  do.
  read dataset lv_fname into gi_data-txt.
  if sy-subrc <> 0.
    exit.
  endif.
  append gi_data.
  clear gi_data.
  enddo.
else.
  write 'File does not exist!'.
endif.
close dataset lv_fname.
The command used to read a file on the application server is as follows.
OPEN DATASET ... FOR INPUT
Please see example code below.
REPORT YSANTO_12 .
data: lv_fname(100),
  lv_msg like sy-msgv1.
data: begin of gi_data occurs 0,
      txt(255),
  end of gi_data.
lv_fname = '/home/data/data.txt'.
open dataset lv_fname for input message lv_msg in text mode encoding default.
if sy-subrc = 0.
  do.
  read dataset lv_fname into gi_data-txt.
  if sy-subrc <> 0.
    exit.
  endif.
  append gi_data.
  clear gi_data.
  enddo.
else.
  write 'File does not exist!'.
endif.
close dataset lv_fname.
Posted by
Shanto
Labels:
ABAP