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

FILENAME

Hi

am using the simple program below.But am getting the output as FILE NOT READ.I hav a file with the same name in the 'C' drive.Please help.

REPORT ZBDC_3A.

DATA : FNAME(30) VALUE 'C:\ZFCHR1.TXT'.

DATA : STR(255).

OPEN DATASET FNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF SY-SUBRC = 0.

DO.

READ DATASET FNAME INTO STR.

IF SY-SUBRC = 0.

WRITE : / STR.

ELSE.

EXIT.

ENDIF.

ENDDO.

ELSE.

WRITE : 'FILE NOT FOUND TO READ'.

ENDIF.

CLOSE DATASET FNAME.

With Regards

Vijay

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 01, 2008 at 06:39 AM

    Are you trying to read a file from your PC?

    Files stored on your PC are presentation server files and should be read using the FM WS_UPLOAD or GUI_UPLOAD.

    Unix files or Application server files are read using OPEN DATASET statement. These files can be seen in transaction AL11.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 01, 2008 at 06:44 AM

    Hi,

    Use this FM GUI_DOWNLOAD.

    Declare an interna table same as your File in the program.

    Sample code is given below:-

    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                      = filepath
    *   FILETYPE                      = 'ASC'
        has_field_separator           = 'X'
    
       TABLES
                           data_tab   = i_tab
    
    
     EXCEPTIONS
       file_open_error               = 1
       file_read_error               = 2
       no_batch                      = 3
       gui_refuse_filetransfer       = 4
       invalid_type                  = 5
       no_authority                  = 6
       unknown_error                 = 7
       bad_data_format               = 8
       header_not_allowed            = 9
       separator_not_allowed         = 10
       header_too_long               = 11
       unknown_dp_error              = 12
       access_denied                 = 13
       dp_out_of_memory              = 14
       disk_full                     = 15
       dp_timeout                    = 16
       OTHERS                        = 17
              .
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    

    Regards

    Sandipan

    Edited by: Sandipan Ghosh on Apr 1, 2008 12:15 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 01, 2008 at 07:01 AM

    Hi,

    Use Upload or download FM instead of Open dataset.

    Hope this will help u

    Regards,

    Vijay K

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 01, 2008 at 07:27 AM

    Hi Vijay,

    As the previous guys mentioned, we can use OPEN DATASET for the files on the Application server only.

    But instead of changing the entire code, u can put the same file in the application server & use the same code.....

    Use the transaction CG3Z for uploading the files in presentation server to Application server.

    But specify a filepath (in which u want to upload the file in AL11 transaction) in the same transaction CG3Z.Then in that path, the file will be stored. Then u assign that filepath to FNAME in ur program. This will surely works.

    Try this & let me know in case of any issues.

    Dont forget to reward points if helpful.

    Pavan.

    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.