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

To create a file on Application Server

Former Member
0 Likes
1,363

How can i create a File on Application Server ?

Please send code for that .

e-mail-- [email protected]

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,206

Hi Krishna Kuamr,

there is a slight change in Pawan's Code to write to an Application Server.

OPEN DATASET <filename> FOR <b>OUTPUT</b> IN TEXT MODE.

LOOP...

TRANSFER <itab> to <filename>

ENDLOOP.

CLOSE DATASET <filename>.

How can i create a File on Application Server ?

Please send code for that .

e-mail-- [email protected]

10 REPLIES 10
Read only

Former Member
0 Likes
1,206

Hi krishna,

1. we will have to use

the commands

OPEN DATASET, TRANSFER, CLOSE DATASET

2. Just see F1 help on it.

3. Also note that the filename

to open

is case sensitive in case of UNIX/AIX

application servers.

regards,

amit m.

Read only

0 Likes
1,206

<b>CG3Z</b> - Upload a empty file to a application server from presentation server.it create a file in application server.

Read only

Former Member
0 Likes
1,206

hi,

we use OPEN DATASET and CLOSE DATASET commands for creating a file on application server.

u can see them in AL11.

OPEN DATASET <filename> FOR INPUT IN TEXT MODE.

LOOP...

TRANSFER <itab> to <filename>

ENDLOOP.

CLOSE DATASET <filename>.

reward if found useful...

Read only

Former Member
0 Likes
1,206

Hi,

Go thro' the link, this might help,

http://www.sapdevelopment.co.uk/file/file_downloadsap.htm

Rgds,

Read only

Former Member
0 Likes
1,207

Hi Krishna Kuamr,

there is a slight change in Pawan's Code to write to an Application Server.

OPEN DATASET <filename> FOR <b>OUTPUT</b> IN TEXT MODE.

LOOP...

TRANSFER <itab> to <filename>

ENDLOOP.

CLOSE DATASET <filename>.

Read only

Former Member
0 Likes
1,206

Hi Krishna,

Check your mail now.

Regards,

Vinay

Read only

Former Member
0 Likes
1,206

Use OPEN DATASET Stmt.

parameters: p_file like rlgrap-filename obligatory

default '/usr/sap/upload.xls'.

types: begin of t_data,

vbeln like vbap-vbeln,

posnr like vbap-posnr,

matnr like vbap-matnr,

werks like vbap-werks,

megne like vbap-zmeng,

end of t_data.

data: it_data type standard table of t_data,

wa_data type t_data.

open dataset p_file for output in text mode encoding default.

if sy-subrc ne 0.

write:/ 'Unable to open file:', p_file.

else.

do.

read dataset p_file into wa_data.

if sy-subrc ne 0.

exit.

else.

append wa_data to it_data.

endif.

enddo.

close dataset p_file.

endif.

Read only

Former Member
0 Likes
1,206

Hi,

in first reply i have posted code for reading file from application server.

this code will create file on applicaton server.

in this code i have added "length" statement which is use to catete record when you have no data for the last field. for example you have data in you itab like..

ABC 123 XYX

WER 453 SDF

ASS 577

QWE 321 232

in this situation when you dont have record for the third row, file will be created with blank record.

  • open file on application server.

open dataset <file name> for output in text mode.

  • transfer the record first.

transfer itab to <filename> length len.

  • close the file at Application Server.

close dataset <filename>.

Read only

Former Member
0 Likes
1,206

Use code:

DATA:

dsn(40) VALUE

'\usr\sap\TDV\DVEBMGS00\data\stat.dat',

rec(80).

First use opendataset.

read datset and last close dataset.

OPEN DATASET dsn.

IF sy-subrc = 0.

DO.

READ DATASET dsn INTO rec.

IF sy-subrc <> 0.

EXIT.

ELSE.

WRITE / rec.

ENDIF.

ENDDO.

ENDIF.

CLOSE DATASET dsn.

Read only

Former Member
0 Likes
1,206

Sorry.

Use transfer insted of read staments

Thanks