Application Development 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: 

upload a file from unix environment

Former Member
0 Kudos

hi

does anybody know which fm to use to upload a file from unix environment?

anjali

1 ACCEPTED SOLUTION

Former Member
0 Kudos

We have to use OPEN Dataset Statement for the same.

Eg:

  open dataset p_file for input in text mode.
  if sy-subrc ne 0.
* Report error
  else.
    do.
      read dataset p_file into wa_itab.
      if sy-subrc ne 0.
         exit.
      else.
         append wa_itab to itab.
      endif.
    enddo.
    close dataset p_file.
  endif.

Note that filenaming convention will be case sensitive in UNIX environment.

Kind Regards

Eswar

5 REPLIES 5

Former Member
0 Kudos

Hi,

To read a file into abap program from UNix you need to use Datasets.

For viewing the file from Application server you can use transaction AL11 and for downloading the file to your PC you can use transaction CG3Y.

Hope this helps.

former_member181962
Active Contributor
0 Kudos

No need for an FM in this case:

use open dataset/read dataset/close dataset commands

sample code:

DATA: line TYPE string,

file(20) TYPE C value '/usr/test.dat'.

OPEN DATASET file IN TEXT MODE ENCODING DEFAULT FOR INPUT.

DO.

READ DATASET file INTO line.

IF sy-subrc <> 0.

EXIT.

ENDIF.

WRITE: / line.

ENDDO.

close dataset file.

Former Member
0 Kudos

We have to use OPEN Dataset Statement for the same.

Eg:

  open dataset p_file for input in text mode.
  if sy-subrc ne 0.
* Report error
  else.
    do.
      read dataset p_file into wa_itab.
      if sy-subrc ne 0.
         exit.
      else.
         append wa_itab to itab.
      endif.
    enddo.
    close dataset p_file.
  endif.

Note that filenaming convention will be case sensitive in UNIX environment.

Kind Regards

Eswar

0 Kudos

thanks very much!

anversha_s
Active Contributor
0 Kudos

hi sia,

try this.

parameters: p_file like rlgrap-filename obligatory

default '/usr/sap/upload.xls'.

types: begin of t_data,

vbeln like vbap-vbeln,

posnr like vbap-posnr,

matnr like vbap-matnr,

werks like vbap-werks,

megne like vbap-zmeng,

end of t_data.

data: it_data type standard table of t_data,

wa_data type t_data.

open dataset p_file for output in text mode encoding default.

if sy-subrc ne 0.

write:/ 'Unable to open file:', p_file.

else.

do.

read dataset p_file into wa_data.

if sy-subrc ne 0.

exit.

else.

append wa_data to it_data.

endif.

enddo.

close dataset p_file.

endif.

rgds

anver