reza
reza

Reputation: 11

how to create a file in application server with abap programing

I have a file in my D: drive of my computer and I want to copy this file to an SAP application server so that I am able to see my file with transaction AL11. I know that I can create a file with AL11 but I want do this in ABAP.

Of course in my search I find this code but I cannot solve my problem with it.

data: unixcom like   rlgrap-filename. 
data: begin of tabl occurs 500,

    line(400),

  end of tabl.

dir = 

unixcom = 'mkdir mydir'. "command to create dir

"to execute the unix command
call 'SYSTEM' id 'COMMAND' field unixcom
              id 'TAB'     field tabl[].

Upvotes: 0

Views: 42954

Answers (3)

Alexander Boos
Alexander Boos

Reputation: 37

To upload the file to the application server, there are three steps to be followed. To open the file use the below statement:

Step1: OPEN DATASET file name FOR INPUT IN TEXT MODE ENCODING DEFAULT.

To write into the application server use.

Step2: TRANSFER name TO file name.

Dont forget to close the file once it is transferred.

Step3: CLOSE DATASET file name.

Plese mark with correct answer, if it helps! :)

Upvotes: 1

reza
reza

Reputation: 11

I used CG3Z transaction and with this transaction I was able to copy a file in the application server directory.

Upvotes: 0

maillard
maillard

Reputation: 680

If you want to do this using ABAP you could create a small report that uses the function module GUI_UPLOAD to get the file from your local disk into an internal table and then write it to the application server with something like this:

lv_filename = '\\path\to\al11\directory\file.txt'.

OPEN DATASET lv_filename  FOR OUTPUT IN TEXT MODE ENCODING UTF-8.

LOOP AT lt_contents INTO lv_line.
  TRANSFER lv_line TO lv_filename.
ENDLOOP.

CLOSE DATASET lv_filename.

Upvotes: 0

Related Questions