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: 

How to download a file into file server?and how to check the file?

Former Member
0 Kudos

hi everyone,

How to download a file into file server?and how to check the file?

i want to download a file into server and i have to check that perticular file whether it is popening and writing and closing ? can u help me in this, and if possible if anyone have any sample porogramme plz send me?

Tks in advance .

Phanikumar..D

4 REPLIES 4

Former Member
0 Kudos

Hi,

During background processing SAP can only write to storage locations defined to the SAP environment. To accomplish something similar to what you describe we defined a network share (I believe it’s called an NFS mount) to SAP so we could write text data to a location accessible from our PC’s.

We then use an automated WebMethods application to archive the data and also copy it to other locations as needed. This works very well for us.

I am not familiar with the specifics as I am more a user of this functionality than a definer. You will likely have to work with your BASIS team to get this set up.

In background, the SAP server running the job has no connection to your PC, it even does nor know from which PC the job has been scheduled or started. As you know you may log on from anywhere.

So if you still want to do as asked:

- Your PC has acces to a network drive which can be accessed from SAP server. This is easy for basis people if SAP runs on WINDOWS server

- server needs file write access for the drive and path; PC at least read access

- background job’s program mus use ABAP commands OPEN DATASET and TRANSFER to write the output data. Possibly one of the function modules ARCHIVEFILE_… is useful for this.

Downloading files to SAP(Application Server):

  • Download internal table to Application server file(Unix)

DATA: e_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.

open dataset e_file for output in text mode.

lOOP AT it_datatab......

transfer it_datatab to e_file.

ENDLOOP.

close dataset e_file.

Uploading files from SAP(Application Server):

  • Retrieve Data file from Application server(Upload from Unix)

DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.

OPEN DATASET i_file FOR INPUT IN TEXT MODE.

IF sy-subrc NE 0.

MESSAGE e999(za) WITH 'Error opening file' i_file.

ENDIF.

DO.

  • Reads each line of file individually

READ DATASET i_file INTO wa_datatab.

  • Perform processing here

  • .....

ENDDO.

Thanks And if useful

please give points .

Former Member
0 Kudos

Hi,

You can use 'file' transaction code for check the file.

Coming to downlad a file into file server transaction code: CG3Y . To upload transaction code is CG3Z.

thanks & regards

venkat

If it is useful please reward points.

Former Member
0 Kudos

Use the following statement,click F1 to get their detail information

for read

open database for input .

read database.

close database.

for write

open database for output.

transfer database.

close database.

T-code:AL11 to check the file

table PATH can check the relationship of logic path and physical path

Former Member
0 Kudos

Hi,

Try this sample code,

TABLES: ZVIJ.

DATA : BEGIN OF WA,

NAME(6) TYPE C,

AGE(3) TYPE C,

DES(5) TYPE C,

SALARY(3) TYPE C,

INCENT(3) TYPE C,

END OF WA,

IT LIKE TABLE OF WA WITH HEADER LINE.

DATA : BEGIN OF WA1,

NAME(6) TYPE C,

AGE TYPE I,

DES(4) TYPE C,

SALARY TYPE I,

INCENT TYPE I,

END OF WA1,

IT1 LIKE TABLE OF WA1 WITH HEADER LINE.

OPEN DATASET 'SAMP' FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'C:\Documents and Settings\Desktop\Book62.XLS' --> XLS

for Excel file.

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

HEADER_LENGTH = 0

READ_BY_LINE = 'X'

DAT_MODE = ' '

CODEPAGE = ' '

IGNORE_CERR = ABAP_TRUE

REPLACEMENT = '#'

CHECK_BOM = ' '

VIRUS_SCAN_PROFILE =

NO_AUTH_CHECK = ' '

IMPORTING

FILELENGTH =

HEADER =

tables

data_tab = IT

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

IF sy-subrc 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT IT .

IT1-NAME = IT-NAME.

IT1-AGE = IT-AGE.

IT1-DES = IT-DES.

IT1-SALARY = IT-SALARY.

IT1-INCENT = IT-INCENT.

APPEND IT1.

ENDLOOP.

LOOP AT IT1.

ZVIJ-NAME = IT1-NAME.

ZVIJ-AGE = IT1-AGE.

ZVIJ-DES = IT1-DES.

ZVIJ-SALARY = IT1-SALARY.

ZVIJ-INCENT = IT1-INCENT.

INSERT ZVIJ.

ENDLOOP.

Thanks.

Regards.