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: 

Downloading a text file from application server

Former Member
0 Kudos

Hi Freinds,

I am genarating a text file in our application server (Folder /usr/sap/dbi/) I need to download this text file in my destop pc or some other windows server.

What do I have to do? What is the procedure, Pls help.

If someone have sample code, pls send.

We are running SAP ECC5.0 on an iSeries (AS/400) Database DB2/400.

Regards

Thanura

1 ACCEPTED SOLUTION

Former Member
0 Kudos

use CG3Y transaction for that...if you want to get it done thru coding, then use

OPEN DATASET

12 REPLIES 12

Former Member
0 Kudos

use CG3Y transaction for that...if you want to get it done thru coding, then use

OPEN DATASET

0 Kudos

HI,

Is this CG3Y will work as a background process.

I need to shedule to download the text file as hourly basis.

Regards

Thanura

Former Member
0 Kudos

Hi,

no need to write any code.

Go to transaction code CG3Y.

Put file name in App server and file name in Presentation server.

Execute.

Fill will be generated in Presentation Server.

Reward points if jelpful.

Srikanta Gope.

srikanta.gope@tcs.com

Former Member
0 Kudos

hi.

i think you should Use

1. OPEN DATASET WITH THE FILE NAME.

2. CLOSE DATASET dset.

this statement search for the particular file on the application server

syntax: - OPEN DATASET dset FOR access IN mode [position]

[ os_addition]

[error_handling].

<b>Example:</b>

DATA: file TYPE string VALUE `test.dat`,

result TYPE string.

OPEN DATASET file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

TRANSFER `1234567890` TO file.

CLOSE DATASET file.

OPEN DATASET file FOR UPDATE IN TEXT MODE ENCODING DEFAULT

AT POSITION 2.

TRANSFER `ABCD` TO file.

CLOSE DATASET file.

OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

WHILE sy-subrc = 0.

READ DATASET file INTO result.

WRITE / result.

ENDWHILE.

CLOSE DATASET file.

Reward points if answer is helpful.

thanks

Divya

former_member188685
Active Contributor
0 Kudos

Hi,

You first get the data from application server to internal table and then download the internal table to a file which is Frontend file.

use open dataset , read dataset , close dataset to get the data to internal table

then use the GUI_DOWNLOAD to down load the data as a file. specify the file path to GUI_DOWNLOAD Function module.

Regards

Vijay

Former Member
0 Kudos

hi,

CG3Y is the tcode to transfer a file from Application server to presentation server directly

Rgds

ReshmA

former_member235056
Active Contributor
0 Kudos

Hi,

checkout these links:

<a href="http://www.scmexpertonline.com/downloads/SCM_LSMW_StepsOnWeb.doc">http://www.scmexpertonline.com/downloads/SCM_LSMW_StepsOnWeb.doc</a>

<a href="http://www.ficoexpertonline.com/downloads/0703.doc">http://www.ficoexpertonline.com/downloads/0703.doc</a>

Pls reward points.

regards,

Ameet

Former Member
0 Kudos

If u want to download just one file.. then use

TCODE CG3Y for app server to pres server

TCODE CG3Z for pres server to app server

but If u have to do this job in a report then u can use FM

HR_CA_DOWNLOAD_TO_APPSERVER for Pres Serer to App Server..

from App Server to Pres Server..

First u can read file from App server into an internal table then using GUI_DOWNLOAD copy it to the Presentation Server.

Regards

Prax

0 Kudos

Hi freinds,

Thank you very much for the fast replys. But I am still wondering how to do this as a sheduled background process.

Some of the solution are not supporting for background processing.

lps help.

REgards

Thanura

0 Kudos

Hi,

thants right, download to a workstation doens't work in background.

Regards, Dieter

0 Kudos

You cannot do this in background since background jobs run on the Application Server and dont have access to anything on the Presentation Server

Former Member
0 Kudos

Hi,

try this:

REPORT ZGRO_TEST.

*

DATA: DATEI_A(30) TYPE C VALUE '/tmp/matnr.txt'.

DATA: DATEI_PC TYPE STRING VALUE 'C:\MATNR.TXT'.

*

DATA: ITAB TYPE TABLE OF MARA WITH HEADER LINE.

*

START-OF-SELECTION.

*

PERFORM DATEI_EINLESEN.

PERFORM DATEI_DOWNLOAD.

*

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

FORM DATEI_EINLESEN.

*

*

OPEN DATASET DATEI_A FOR INPUT IN TEXT MODE.

IF SY-SUBRC NE 0. STOP. ENDIF.

*

DO.

*

READ DATASET DATEI_A INTO ITAB.

*

IF SY-SUBRC <> 0. EXIT. ENDIF.

*

APPEND ITAB.

*

ENDDO.

*

CLOSE DATASET DATEI_A.

*

IF SY-SUBRC NE 0. STOP. ENDIF.

*

ENDFORM. "DATEI_EINLESEN

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

FORM DATEI_DOWNLOAD.

  • Datei downloaden

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD

EXPORTING

FILENAME = DATEI_PC

FILETYPE = 'ASC'

CHANGING

DATA_TAB = ITAB[]

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

NOT_SUPPORTED_BY_GUI = 22

ERROR_NO_GUI = 23

OTHERS = 24.

*

IF SY-SUBRC NE 0. STOP. ENDIF.

*

ENDFORM. "DATEI_DOWNLOAD

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

Regards, Dieter