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: 

DATASET program in Windows OS

former_member355937
Participant
0 Kudos

Hello,

Below is the source of my Dataset program.

It doesn't create a file specfied in the code which is supposed to.

I just got this code in the ABAP documentation samples but the document stated that it works only under UNIX systems. I need to do this under Windows environment. Is this possible?

<<<<<<

REPORT DATASET_DEMO.

DATA FNAME(60) VALUE 'C:\TEMP\myfile.TXT'.

TYPES: BEGIN OF LINE,

COL1 TYPE I,

COL2 TYPE I,

END OF LINE.

TYPES ITAB TYPE LINE OCCURS 10.

DATA: LIN TYPE LINE,

TAB TYPE ITAB.

DO 5 TIMES.

LIN-COL1 = SY-INDEX.

LIN-COL2 = SY-INDEX ** 2.

APPEND LIN TO TAB.

ENDDO.

OPEN DATASET FNAME FOR OUTPUT.

LOOP AT TAB INTO LIN.

TRANSFER LIN TO FNAME.

ENDLOOP.

CLOSE DATASET FNAME.

>>>>>>

Need your help on this one.

Thanks,

Jeff

5 REPLIES 5

ChristianFi
Active Participant
0 Kudos

Jeffrey,

are you trying to store files on the client? Then you should use Function Module GUI_DOWNLOAD.

Open dataset does work on application server with OS WINDOWS.

Christian

Former Member
0 Kudos

Hi,

This program will work with Windows OS also. But the first thing you have to see is whether the folder C:\temp is visible to SAP.

You just make a change to your code instead of

DATA FNAME(60) VALUE 'C:\TEMP\myfile.TXT'.

use

DATA FNAME(60) VALUE 'myfile.TXT'.

This will write to the folder specified in DIR_HOME.

If you want to write specifically to a folder in application server, get with your basis team and get the list of folders visible to SAP and use the corresponding folders. Instead you can use the logical path also.

Thanks,

Vishnu Aravind A.V.

0 Kudos

No way! you can use open datset to write to presentation server. for that purpose you need to use gui_download function.

Here is a note from ABAP key word documentation for open dataset.

<i>The system must be able to reach the file from the current application server. You cannot edit files from the current presentation server. If you need to do this, use the function modules GUI_DOWNLOAD and GUI_UPLOAD.</i>

Regards

Raja

Former Member
0 Kudos

Hi,

1) If you want to download file to an Application server

Try this out,

data fname value <file>.

open dataset fname for output.

text1 ='Sample Data'.

transfer text1 to fname.

close dataset fname.

The Above Statements will put the data into the file specified by <file>.

In case you are performing repeated write operation in the same file use,

open dataset fname for appending.

This will append data to the existing file.

2) If you want to download data to your system,

Then try the following code,

call function 'WS_DOWNLOAD'

exporting

codepage = ' '

filename = 'D:\DATA.TXT'

filetype = 'ASC'

tables

data_tab = itab.

or you can try the same with GUI_DOWNLOAD as

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'D:\sample.txt'

FILETYPE = 'ASC'

tables

data_tab = itab.

I think this will solve the problem,

Thanks and Regards,

Kathir.

former_member355937
Participant
0 Kudos

Hi Guys,

Thanks a lot for the info.

Anyway, the reason why I used DATASET instead of fm GUI_DOWNLOAD is I need to to upload data into a text file with different sections and structures. The file has a header (comma delimited), detail (TAB delimited) and a footer (also comma delimited).

Actually, I did some work around on this. What I did was I created an internal table having one column with a TAB/Comma delimited data and I used fm WS_DOWNLOAD.

I am just asking if there is another way to do it aside from what I did.

Regards,

Jeff