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

OPEN dataset statement

Hi folks,

I have a file stored on the network shared drive. Can I read the file using open dataset statement. This file is not stored on the application server.

I have read that the open dataset statement works for only with the files stored in the application server.

thanks

sankar

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 05:37 AM

    Hi

    Go thru this code, it will help you,.

    See the use of open dataset statement here.

    Pls reward if help.

    Refer this:

    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm

    ABAP code for uploading a TAB delimited file into an internal table. See code below for structures.

    &----


    *& Report ZUPLOADTAB * &----


    *& Example of Uploading tab delimited file *

    &----


    REPORT zuploadtab .

    PARAMETERS: p_infile LIKE rlgrap-filename

    OBLIGATORY DEFAULT '/usr/sap/'..

    DATA: ld_file LIKE rlgrap-filename.

    *Internal tabe to store upload data

    TYPES: BEGIN OF t_record,

    name1 like pa0002-VORNA,

    name2 like pa0002-name2,

    age type i,

    END OF t_record.

    DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,

    wa_record TYPE t_record.

    *Text version of data table

    TYPES: begin of t_uploadtxt,

    name1(10) type c,

    name2(15) type c,

    age(5) type c,

    end of t_uploadtxt.

    DATA: wa_uploadtxt TYPE t_uploadtxt.

    *String value to data in initially.

    DATA: wa_string(255) type c.

    constants: con_tab TYPE x VALUE '09'.

    *If you have Unicode check active in program attributes then you will

    *need to declare constants as follows:

    *class cl_abap_char_utilities definition load.

    *constants:

    • con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.

    ************************************************************************

    *START-OF-SELECTION

    START-OF-SELECTION.

    ld_file = p_infile.

    OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

    IF sy-subrc NE 0.

    ELSE.

    DO.

    CLEAR: wa_string, wa_uploadtxt.

    READ DATASET ld_file INTO wa_string.

    IF sy-subrc NE 0.

    EXIT.

    ELSE.

    SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1

    wa_uploadtxt-name2

    wa_uploadtxt-age.

    MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.

    APPEND wa_upload TO it_record.

    ENDIF.

    ENDDO.

    CLOSE DATASET ld_file.

    ENDIF.

    ************************************************************************

    *END-OF-SELECTION

    END-OF-SELECTION.

    *!! Text data is now contained within the internal table IT_RECORD

    • Display report data for illustration purposes

    loop at it_record into wa_record.

    write:/ sy-vline,

    (10) wa_record-name1, sy-vline,

    (10) wa_record-name2, sy-vline,

    (10) wa_record-age, sy-vline.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 05:37 AM

    Hi,

    you have to use GUI_UPLOAD function module to read thet file in your program.

    OPEN DATASET works only for Application server.

    Regards,

    Pankaj

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 05:39 AM

    hi,

    then use gui_upload fm to upload to application server then use open dataset

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 05:41 AM

    hi,

    To open a file on the application server, use the OPEN statement as follows:

    Syntax

    OPEN DATASET <dsn> [Additions].

    This statement opens the file <dsn>. If you do not specify any additions for the mode, the file is opened in binary mode for reading. SY-SUBRC returns 0 if the system opens the file. Otherwise, SY-SUBRC is set to 8.

    You enter the filename <dsn> either as a literal or as a field containing the actual name of the file. If you do not specify a path, the system opens the file in the directory in which the R/3 System is running on the application server. To open a file, the user under which the R/3 System is running must have the requisite authorizations at operating system level.

    To read from presentation server use any of the FM

    1.ws_upload.

    2.gui_upload.

    3.upload.

    Hope this is helpful, Do reward.

    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.