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

OPEN DATASET

Former Member
0 Likes
2,759

Hi, friends..

I'm trying to save in App. Server same records, using the sintax below:

... to create the file in App. I use :

OPEN DATASET file_ws FOR OUTPUT IN TEXT MODE ENCODING DEFAULT

... and to input the data into the file a use:

v_size = '280'.

loop at t_file_11 .

...

...

TRANSFER t_file_11 TO file LENGTH v_size.

...

...

endloop.

But when I access the folder in App Server, the file doesn't exist.

and when I execute the program in Foreground using GUI_DOWNLOAD, the file is created normally.

Edited by: Flavio Ferreira on Nov 28, 2008 7:19 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,676

hi flavio,

to work with application server ,while creating a new file you must declare the file using the datatype rlgrap-filename like

parameters: pa_file type rlgrap_filename.

initialization: pa_file = '/usr/sap/tmp'.

(you can add your file name with this)

open dataset pa_file for output in text mode encoding default.

rest same as u have done

try this

thanks

geeta

7 REPLIES 7
Read only

Former Member
0 Likes
1,676

OPEN DATASET FILE _WS FOR OUTPUT IN TEXT MODE

MESSAGE D_MSG_TEXT.(this will allow you to trace the error)

IF SY-SUBRC NE 0.

WRITE: 'File cannot be opened. Reason:', D_MSG_TEXT.

EXIT.

ENDIF

loop at t_file_11 .

...

...

TRANSFER t_file_11 TO FILE_WS LENGTH v_size.

...

...

endloop.

CLOSE DATASET FILE_WS.

Regards

Neha

Edited by: Neha Shukla on Nov 29, 2008 12:03 AM

Edited by: Neha Shukla on Nov 29, 2008 12:06 AM

Read only

Former Member
0 Likes
1,676

Hi Flavio,

We use the following:


DATA: dsn(40).
CONCATENATE '\\' SY-HOST '\usr\datafile.dat' INTO dsn.
DATA: wa_itab like line of itab.

OPEN DATASET dsn FOR APPENDING IN TEXT MODE ENCODING DEFAULT.
  IF SY-SUBRC = 0.
    LOOP AT ITAB INTO wa_itab.
      TRANSFER wa_itab TO dsn.
    ENDLOOP.
  ENDIF.
CLOSE DATASET dsn.

And we don't have any issues. The one problem we had when first setting this up was with write access to the directory. Check with your BASIS and/or network guys to make sure that the correct users are assigned privileges to write to the application server.

Hope this helps.

SL

Read only

Former Member
0 Likes
1,676

data : fpath(100),

sorg(10),

div(11),

reg(5).

data : html type table of w3html with header line.

parameter : ip_add(15) type c default '192.168.0.2',

share(15) type c default 'TEMP\ZTEST'.

concatenate '
' ip_add '\' share '\' sorg '-' div '.HTM' into fpath.

open dataset fpath for output in text mode encoding non-unicode.

if sy-subrc = 0.

loop at html.

transfer html to fpath.

endloop.

endif.

close dataset fpath.

message i001(ze) with 'File has generated on Foreground Process !!'.

endif.

Read only

Former Member
0 Likes
1,676

HI,

Try this Code....

OPEN DATASET filename FOR OUTPUT IN TEXT MODE

IGNORING CONVERSION ERRORS ENCODING UTF-8 MESSAGE msg.

Loop at itab.

transfer content to filename.

endloop.

close dataset filename.

Please check the file in AL11 according the path specified by you or check the file in DIR_TEMP directory...

Refer to this Link...

Edited by: avinash kodarapu on Nov 30, 2008 6:14 PM

Read only

0 Likes
1,676

Hi.

I think you are a little confused where the file system is:

GUI_DOWNLOAD uses the presentation server file system i.e. windows C:\ etc.

OPEN DATASET uses the application server file system.

You can use the first only when running online, the later only for backgroung processing.

Ariel Fisher

Read only

Former Member
0 Likes
1,676

if you want to save the file in application server

just move from presentation server

using CG3z

while the presentation server file path

and give target file path

give ASC type

and to confirm the path of the application server

just go to AL11 get the directory name

hope it will work

if at all you want to download from SAP database

use GUI_download and then move this file to application server

you can use your method too

you can follow this method also

Read only

Former Member
0 Likes
1,677

hi flavio,

to work with application server ,while creating a new file you must declare the file using the datatype rlgrap-filename like

parameters: pa_file type rlgrap_filename.

initialization: pa_file = '/usr/sap/tmp'.

(you can add your file name with this)

open dataset pa_file for output in text mode encoding default.

rest same as u have done

try this

thanks

geeta