Application Development and Automation 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: 
Read only

copy a file

Former Member
0 Likes
3,559

please help me for the following questions:

a. what command i should use to know if a file is present in the application server (/usr/sap/trans)?

b. what command i used use to copy a file?

invbal.csv -> invbal1.csv

thanks.

donna

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,237

Hi,

See this link.

Svetlin

5 REPLIES 5
Read only

Former Member
0 Likes
3,237

to find about file existence....

read dataset (check for sy-subrc = 0 for success)

to copy file...

read the file in an internal table (open dataset d1 for input)

open another file for output (open dataset d2 for output)

transfer contents of itab into d2.

close both files. (close dataset)

rgds,

PJ

Read only

Former Member
0 Likes
3,238

Hi,

See this link.

Svetlin

Read only

0 Likes
3,237

Hi,

You can define you own external command via SM69 and execute it via SXPG_COMMAND_EXECUTE

Eddy

Read only

Former Member
0 Likes
3,237

hi,

DATA:

dsn(20) VALUE '/usr/sap/trans/invbal.csv',

dsncopy(20) VALUE '/usr/sap/trans/invbal1.csv',

rec(80).

OPEN DATASET dsn.

if sy-subrc <> 0.

file not exits

exit

endif

DO.

READ DATASET dsn INTO rec.

IF sy-subrc <> 0.

EXIT.

ELSE.

WRITE / rec.

ENDIF.

ENDDO.

ENDIF.

CLOSE DATASET dsn.

OPEN DATASET dsncopy.

TRANSFER rec TO dir.

close dataset

cheers,

sasi

Read only

aaruljothi
Participant
0 Likes
3,237

1. If you want ot check the existence of the file manually just go to AL11 transaction and navigate through the path that you have specified and find the file.

2. To copy a file open the file using open dataset transfer it to an internal table and then write it in another file.