Skip to Content
author's profile photo Former Member
Former Member

OPENDATASET not working

Hi everybody,

I'm using sentence OPENDATASET for creating a file in C:\ en user machine, the file is not created even when sy-subrc is equal to 0, can anyone help me if this is problem with security or profiles or something like that?????

Thanks in advance

Julio Cesar

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 02:39 PM

    Thanks for your answer guys, I've used GUI_DOWNLOAD before, the problem is that I need to run the program as a background job and I don't know if this function will work, can you tell me what is the best option for use in background jobs to create files in the presentation layer????

    Thanks

    Julio Cesar

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      My sugegstion is o hard code the the file location .

      I have the code in my previous post . just use the download FM and

      write the file location where you want to downkload the file to

      v_file1

      HOPE THIS SOLVES YPUR PROBLEM

      THANKS

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 02:29 PM

    hi Julio,

    When you are trying to download data on to presentation server use <b>GUI_DOWNLOAD</b> FM rather than using Open dataset statement ..

    Check out this sample code

    * This method of file download with check uses the latest techniques 
    * and achieves a very neat solution
      DATA: ld_filename TYPE string,
            ld_path TYPE string,
            ld_fullpath TYPE string,
            ld_result TYPE i.
    
    * Display save dialog window
      CALL METHOD cl_gui_frontend_services=>file_save_dialog
        EXPORTING
    *      window_title      = ' '
          DEFAULT_EXTENSION = 'XLS'
          default_file_name = 'accountsdata'
          INITIAL_DIRECTORY = 'c:temp'
        CHANGING
          filename          = ld_filename
          path              = ld_path
          fullpath          = ld_fullpath
          user_action       = ld_result.
    
    * Check user did not cancel request
      CHECK ld_result EQ '0'.
    
      CALL FUNCTION 'GUI_DOWNLOAD'
       EXPORTING
            filename         = ld_fullpath
            filetype         = 'ASC'
    *       APPEND           = 'X'
            write_field_separator = 'X'
    *       CONFIRM_OVERWRITE = 'X'
       TABLES
            data_tab         = it_datatab[]     "need to declare and populate
       EXCEPTIONS
            file_open_error  = 1
            file_write_error = 2
            OTHERS           = 3.
    

    also Check

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

    Regards,

    Santosh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 02:31 PM

    Hello,

    Do like this.

    If u are creating the file in Applicaton Server

    <b>OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE.

    loop at itab.

    transfer itab to p_file.

    endloop.

    CLOSE DATASET P_FILE.</b>

    If u are creating the file in Presentation Server

    Use <b>GUI_DOWNLOAD</b> FM

    If useful reward.

    Vasanth

    Message was edited by:

    Vasanth M

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 02:32 PM

    Hi,

    The open dataset statement is used for creating or reading the files on the application server. This will not create the file on the user machine.

    Try using the function module GUI_DOWNLOAD to create the file on the user machine specifing the file name.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    • BIN_FILESIZE =

    FILENAME = 'C:\TEST.TXT'

    FILETYPE = 'ASC'

    • APPEND = ' '

    WRITE_FIELD_SEPARATOR = 'X'

    • HEADER = '00'

    • TRUNC_TRAILING_BLANKS = ' '

    • WRITE_LF = 'X'

    • COL_SELECT = ' '

    • COL_SELECT_MASK = ' '

    • DAT_MODE = ' '

    • CONFIRM_OVERWRITE = ' '

    • NO_AUTH_CHECK = ' '

    • CODEPAGE = ' '

    • IGNORE_CERR = ABAP_TRUE

    • REPLACEMENT = '#'

    • WRITE_BOM = ' '

    • TRUNC_TRAILING_BLANKS_EOL = 'X'

    • IMPORTING

    • FILELENGTH =

    TABLES

    DATA_TAB = IT_DATA

    • FIELDNAMES =

    EXCEPTIONS

    FILE_WRITE_ERROR = 1

    NO_BATCH = 2

    GUI_REFUSE_FILETRANSFER = 3

    INVALID_TYPE = 4

    NO_AUTHORITY = 5

    UNKNOWN_ERROR = 6

    HEADER_NOT_ALLOWED = 7

    SEPARATOR_NOT_ALLOWED = 8

    FILESIZE_NOT_ALLOWED = 9

    HEADER_TOO_LONG = 10

    DP_ERROR_CREATE = 11

    DP_ERROR_SEND = 12

    DP_ERROR_WRITE = 13

    UNKNOWN_DP_ERROR = 14

    ACCESS_DENIED = 15

    DP_OUT_OF_MEMORY = 16

    DISK_FULL = 17

    DP_TIMEOUT = 18

    FILE_NOT_FOUND = 19

    DATAPROVIDER_EXCEPTION = 20

    CONTROL_FLUSH_ERROR = 21

    OTHERS = 22

    .

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    Where IT_DATA is the internal table containing the data that is to be downloaded to the user system.

    Regards,

    Ravi.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 02:38 PM

    Hi,

    The following code will askyou for the location for the file to download.

    open dataset , close dataset, read dataset are to place a file in application server not for the presentation server.

    data :v_file1 type string.

    parameters : d_file like rlgrap-filename.

    at selection-screen on value-request for d_file.

    CALL FUNCTION 'F4_FILENAME'

    EXPORTING

    PROGRAM_NAME = h_repid

    • DYNPRO_NUMBER = SYST-DYNNR

    • FIELD_NAME = ' '

    IMPORTING

    FILE_NAME = d_file

    .

    concatenate d_file '.txt' into d_file.

    v_file1 = d_file.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    • BIN_FILESIZE =

    FILENAME = V_FILE1

    FILETYPE = 'ASC'

    • APPEND = ' '

    WRITE_FIELD_SEPARATOR = 'X'

    • HEADER = '00'

    TRUNC_TRAILING_BLANKS = 'X'

    • WRITE_LF = 'X'

    • COL_SELECT = ' '

    • COL_SELECT_MASK = ' '

    *IMPORTING

    • FILELENGTH =

    TABLES

    DATA_TAB = itab[]

    EXCEPTIONS

    FILE_WRITE_ERROR = 1

    NO_BATCH = 2

    GUI_REFUSE_FILETRANSFER = 3

    INVALID_TYPE = 4

    NO_AUTHORITY = 5

    UNKNOWN_ERROR = 6

    HEADER_NOT_ALLOWED = 7

    SEPARATOR_NOT_ALLOWED = 8

    FILESIZE_NOT_ALLOWED = 9

    HEADER_TOO_LONG = 10

    DP_ERROR_CREATE = 11

    DP_ERROR_SEND = 12

    DP_ERROR_WRITE = 13

    UNKNOWN_DP_ERROR = 14

    ACCESS_DENIED = 15

    DP_OUT_OF_MEMORY = 16

    DISK_FULL = 17

    DP_TIMEOUT = 18

    FILE_NOT_FOUND = 19

    DATAPROVIDER_EXCEPTION = 20

    CONTROL_FLUSH_ERROR = 21

    OTHERS = 22

    .

    IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    else.

    write : / 'NOTE : ERROR FILE IS DOWNLOADED TO SPECIFIED LOCATION'.

    ENDIF.

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 02:39 PM

    Hi,

    For presentation server file download or upload --> user GUI_UPLOAD,GUI_DOWNLOAD function modules

    For Applicaiton server file download or upload --> user OPEN DATASET,TRANSFER,READ DATASET,CLOSE DATASET Statements

    If you want download from applicaiton server to presentation server(without programming) user CG3Y,CG3Z transaction codes.

    Regards,

    Bhupal Reddy

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 02:40 PM

    Hi,

    When using OPEN DATASET u cannot use C:\

    you have to use /usr/sap/trans.... or whatever directory u want

    for more info on directories check transaction AL11

    REward and close if helpful

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 02:40 PM

    Hi Julio,

    <b> OPEN DATASET <APPLICATION SERVER PATH> FOR OUTPUT IN <i>TEXT MODE</i>.

    IF SY-SUBRC = 0.

    LOOP AT <INTERNAL TABLE>.

    TRANSFER <INTERNAL TABLE> TO <APPLICATION SERVER PATH>.

    ENDLOOP.

    CLOSE DATASET <APPLICATION SERVER PATH>.</b>

    Thanks

    Vikranth khimavath

    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.