Skip to Content

DATASET program in Windows OS

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Dec 28, 2004 at 07:34 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 28, 2004 at 07:58 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

  • author's profile photo Former Member
    Former Member
    Posted on Dec 28, 2004 at 12:33 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 28, 2004 at 03:37 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.