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

Problem in uploading file from Application Server

Former Member
0 Likes
788

Hi everyone,

i got a problem in uplaoding a file from application server.i am having two folder (one folder name is current and another one is processed)in application server. In current folder i am having N no of files.I want to upload all the files names into one internal table and i want to process one by one file.After processing each file the file should be moved to processed folder and the files should not exist in current folder.All these process must be done everyday.Please rectify my problem asap.

6 REPLIES 6
Read only

Former Member
0 Likes
665

hi,

You have to write few lines of code to meet your requirement

EPS_GET_DIRECTORY_LISTING gives the list of fiels in a specified direcotry.

you can process one by one.

Regards,

Sailaja.

Read only

0 Likes
665

Hi,

If i am using this FM after executing it is going to dump giving the error as NO AUTHORIZATION.

Regards,

ramesh kodavati

Read only

0 Likes
665

That means you don't have authorization. You have to use that function module to get the list of files, so get your basis people add that authority to your user profile.

Read only

Former Member
0 Likes
665

Ramesh,

Take authorization from basis guy.

Use the below code to get the list of files from require directory

&----


*& Report ZDIRFILES *

&----


REPORT ZDIRFILES .

PARAMETER: p_fdir type pfeflnamel DEFAULT '/usr/sap/tmp'.

data: begin of it_filedir occurs 10.

include structure salfldir.

data: end of it_filedir.

************************************************************************

*START-OF-SELECTION

START-OF-SELECTION.

  • Get Current Directory Listing for OUT Dir

call function 'RZL_READ_DIR_LOCAL'

exporting

name = p_fdir

tables

file_tbl = it_filedir.

Now in internal table "it_filedir" will have all your files.

For moving and deleting

report zrich_0001.

Parameters: d1 type localfile default '/usr/sap/TST/SYS/fld1/Data1.txt',

d2 type localfile default '/usr/sap/TST/SYS/fld2/Data1.txt'.

data: begin of itab occurs 0,

rec(20) type c,

end of itab.

data: wa(20) type c.

start-of-selection.

open dataset d1 for input in text mode.

if sy-subrc = 0.

do.

read dataset d1 into wa.

if sy-subrc <> 0.

exit.

endif.

itab-rec = wa.

append itab.

enddo.

endif.

close dataset d1.

open dataset d2 for output in text mode.

loop at itab.

transfer itab to d2.

endloop.

close dataset d2.

delete dataset d1.

Check below FM if required

To move the file to archive directoryuse FMs 'PFL_COPY_OS_FILE'

To Delete 'EPS_DELETE_FILE'.

Don't forgot to reward if useful

Read only

Former Member
0 Likes
665

Ramesh,

You can also use to move the file like

DATA: COMMAND(200).

DATA: BEGIN OF TABL OCCURS 0,

LINE(255),

END OF TABL.

command = 'mv /home/prd/file.in /home/prd/processed/file.out'.

CALL 'SYSTEM' ID 'COMMAND' FIELD COMMAND ID 'TAB' FIELD TABM-SYS.

Pls. reward if useful

Read only

Former Member
0 Likes
665

hi

good

go through this link

http://www.dalestech.com/Media/files/docs/file/Programming_with_file_class_100.pdf

/people/thomas.jung3/blog/2004/11/15/performing-ftp-commands-from-abap

thanks

mrutyun^