0

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[].
1
  • 1
    Use function module ARCHIVFILE_CLIENT_TO_SERVER Commented Nov 24, 2014 at 21:06

3 Answers 3

1

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! :)

Sign up to request clarification or add additional context in comments.

Comments

0

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.

2 Comments

Why write any code at all when one could run simply the function module ARCHIVFILE_CLIENT_TO_SERVER in SE37?
@Jagger That would be a better solution for this particular question, indeed. But I did not know about this function module (thanks to you, now i do :-) ). Why don't you post that as an answer? I also think that the code in this answer still is useful.
0

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

1 Comment

Note that this transaction is only available in an ERP system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.