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
952

hi to all

plz help me this issue,

OPEN DATASET 'ZREF1.TXT' FOR APPENDING IN TEXT MODE ENCODING DEFAULT

instead of 'ZREF1.TXT' i want to give a file path in al11 C:\interface\payext\ZREF1.TXT

. how can i give this

thanks in advance

kiran kumar

Message was edited by:

kiran kumar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
809

initially take a variable and assign the file path to the variable...

now use OPEN DATASET <variable> FOR APPENDING IN TEXT MODE ENCODING DEFAULT

This will work...

6 REPLIES 6
Read only

Former Member
0 Likes
810

initially take a variable and assign the file path to the variable...

now use OPEN DATASET <variable> FOR APPENDING IN TEXT MODE ENCODING DEFAULT

This will work...

Read only

0 Likes
809

hi ramesh ,

can u give one example.

thanks and regards

kiran kumar

Read only

0 Likes
809

You can find the example here

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ccd358411d1829f0000e829fbfe/content.htm

Regards,

Ravi

Note Please mark all the helpful answers

Read only

Former Member
0 Likes
809

file_name = '/usr/sap/xx/filename'.

Now use the OPEN DATASET filename for appending in text movde encoding default.

Regards,

Ravi

Read only

0 Likes
809

I think u want to download the file to your local system.

Open dataset command is usedto create files on applicaiton server..

to download that file to your locval system use ws_download function module.

create the file giving the normal name as 'xyz.txt'

then

OPEN DATASET 'xyz.txt' FOR INPUT IN TEXT MODE.

READ DATASET 'xyz.txt' INTO ITAB_FILE.

then call ws_download as

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

FILENAME = 'local file name'

FILETYPE = 'ASC'

MODE = 'O'

TABLES

DATA_TAB = ITAB_FILE

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_WRITE_ERROR = 2

INVALID_FILESIZE = 3

INVALID_TABLE_WIDTH = 4

INVALID_TYPE = 5

NO_BATCH = 6

UNKNOWN_ERROR = 7

OTHERS = 8.

hope this helps

Read only

graghavendra_sharma
Contributor
0 Likes
809

Hi Kiran,

I hope in AL11, file path will not start with 'C:\'. Try to find out the logical file name for the file path. else you can directly use the file name along with the path in OPEN DATASET.

CONSTANTS: c_lname LIKE filepath-pathintern VALUE 'Z_LOGICAL_FPATH'.

DATA: l_fname TYPE pathextern.

DATA: l_error.

CLEAR: l_fname, l_error.

*Get the application server file name along with the path

CALL FUNCTION 'FILE_GET_NAME'

EXPORTING

logical_filename = c_lname

IMPORTING

file_name = l_fname

EXCEPTIONS

file_not_found = 1

OTHERS = 2.

OPEN DATASET l_fname FOR APPENDING IN TEXT MODE ENCODING DEFAULT