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: 

Cutting And Pasting Files in Application Server

Former Member
0 Kudos

Hi All,

I want to cut one file in one folder at application server and paste that file in to another folder on to application server.

How can I do it ? Please let me know.

Thanks,

Mayank.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

<b>

data itab(200) occurs 0 with header line.

parameter pfile1 like rlgrap-filename.

parameter pfile2 like rlgrap-filename.

open dataset pfile1 for input in text mode.

do .

read dataset pfile1 into itab.

if sy-subrc ne 0.

exit.

endif.

append itab.

enddo.

close dataset pfile1.

open dataset pfile2 for output in text mode.

loop at itab.

transfer itab to pfile2.

endloop.

close dataset pfile2.

delete dataset pfile1.</b>

Cheers

8 REPLIES 8

Former Member
0 Kudos

First thing to remember here is <b>SAP is not Windows!</b> So please don't be in a "Windows frame of mind" when working in SAP!! The app server directory is not Windows Explorer

I don't think there is a standard functionility for that. We, in our company, have developed our own UNIX commands to copy/paste/delete/download files from different folders at the app server level.

Cheers,

Syd.

Former Member
0 Kudos

there are some FMs to create and delete files....u can read the existing file....create it at another location and then delete the previous one....

foll. may be helpful...

EPS_DELETE_FILE

CONVT_DELETE_FILES

or u can work with <b>open dataset for output</b> and <b>delete dataset</b> statements

rgds,

PJ

Former Member
0 Kudos

hi,

use open dataset, read dataset for reading file from application server and use transfer to write a file in different folder then delete the previous file

open dataset for input

read dataset

close dataset

open dataset for output

transfer

close dataset

delete dataset

cheers,

sasi

Former Member
0 Kudos

<b>

data itab(200) occurs 0 with header line.

parameter pfile1 like rlgrap-filename.

parameter pfile2 like rlgrap-filename.

open dataset pfile1 for input in text mode.

do .

read dataset pfile1 into itab.

if sy-subrc ne 0.

exit.

endif.

append itab.

enddo.

close dataset pfile1.

open dataset pfile2 for output in text mode.

loop at itab.

transfer itab to pfile2.

endloop.

close dataset pfile2.

delete dataset pfile1.</b>

Cheers

Former Member
0 Kudos

Hi,

You can use External OS commands ( tr.code SM69 ). Declare your own commands in SM69 for copy,paste etc.

You call them using FM 'SXPG_CALL_SYSTEM'.

call function 'SXPG_CALL_SYSTEM'

EXPORTING

commandname = 'COPY'

additional_parameters = parameter

IMPORTING

status = status

TABLES

exec_protocol = err_tab

EXCEPTIONS

no_permission = 1

command_not_found = 2

parameters_too_long = 3

security_risk = 4

wrong_check_call_interface = 5

program_start_error = 6

program_termination_error = 7

x_error = 8

parameter_expected = 9

too_many_parameters = 10

illegal_command = 11

others = 12.

Svetlin

P.S If you find an answer useful, please assign reward points.

Former Member
0 Kudos

Hi Mayank,

If I can open the Thread, here is the procedure to move file from one location to other in Application server:


TYPES:
*      Structure used to move file
       BEGIN OF GS_TABL,
        LINE(200),
       END OF GS_TABL.

DATA: GT_TABL TYPE STANDARD TABLE OF GS_TABL WITH HEADER LINE.

* Workarea
  DATA: GW_TABL TYPE GS_TABL.
* Variables
  DATA: LV_PARCOM(250).
* If the OS is SUN SOLARIS, GC_MOVE = 'mv', if WINDOWS 
* NT, GC_MOVE = 'move'
  CONCATENATE GC_MOVE
              'source file name'
              'target file name' INTO LV_PARCOM
                             SEPARATED BY SPACE.

* Call system function passing 'mv' command and 
* parameters.
  CALL 'SYSTEM' ID 'COMMAND' FIELD LV_PARCOM
                ID 'TAB'     FIELD GT_TABL-*SYS*.

  LOOP AT GT_TABL INTO GW_TABL.
    WRITE AT / LW_TABL-LINE.
  ENDLOOP.

Regards,

Phani

Former Member
0 Kudos

Hi,

Two function modules will do that:

CG3Y and CG3Z.

regards

Aveek

0 Kudos

Hi Mayank

when you read and writting into another file make sure that folder where you going to write this file is in write mode other wise you may get some problem.

you can Change mode by using CHMOD command in UNIX server.

Regards

Kali