Application Development and Automation 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: 
Read only

Error while OPEN DATASET

Former Member
0 Likes
5,631

Hi all,

I am getting a text file from presentation server and uploading it to application server like /tmp/TEXTFILE .

Then I am scheduling a job in the same program .In the job I'll be retrieving the data from the file in app server like

OPEN DATASET w_infile FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE msg.

But m getting the error in msg as "No such file or directory".And my job is getting failed.

I tried to open the file through AL11,It is opening.Also while I try to debug the failed job the file is opening properly and my changes are carried out succesfully.

Can smbody help???

16 REPLIES 16
Read only

Former Member
0 Likes
3,412

Hi

Are u sure to transfer the correct path in w_infile?

U should consider the statament to open the file is case sensitive

Max

Read only

0 Likes
3,412

Hi Max,

the mystery is ..it is working smtimes n smtimes it is giving this error...the filename is correct only...

Read only

0 Likes
3,412

Hi

What do you mean?

Is it happens in background only?

How many Servers SAP are in your system?

Max

Read only

0 Likes
3,412

ya..but in bkgrnd it was working fine till last day...the problem began from today morning only

Read only

0 Likes
3,412

Hi

If it's all OK, u should ask if something is changed on Server to your basis

Max

Read only

Former Member
0 Likes
3,412

Hi,

You need to give extension of the file.

eg: /tmp/TEXTFILE.txt

Regards

Milan

Read only

Former Member
0 Likes
3,412

Hi,

I think your Path string is wrong

Insterd of '/' use ' \'

Also use Extension of the file

thanks & Regards,

Shreemohan

Read only

Former Member
0 Likes
3,412

Hi,

Take the help of your basis team for the correct physical path or logical path

Regards

Ramchander Rao.K

Read only

Former Member
0 Likes
3,412

Hi,

Please validate the path before uploading/downloading using following Code.

     OPEN DATASET G_FILE_NAME3
      FOR OUTPUT
      IN TEXT MODE.
    MOVE SY-SUBRC TO L_SUBRC.
  ENDCATCH.
  IF L_SUBRC  <> 0
  OR SY-SUBRC <> 0.
    DELETE DATASET G_FILE_NAME3.
    G_FILE_NAME3E = G_FILE_NAME3.
    G_FILE_NAME3 = ''.
  ENDIF.

Also remember to use ' / ' in the filepath .(forwardslash).

Regards,

Vimal.

Read only

Former Member
0 Likes
3,412

hi,

There is also a Function Module can be used, named 'OCS_GET_FILE_INFO'.

DATA: gdt_ocs_file TYPE TABLE OF ocs_file.

PARAMETERS p_file TYPE dxfile-filename.

AT SELECTION-SCREEN.

CALL FUNCTION 'OCS_GET_FILE_INFO'

EXPORTING

dir_name = p_file

file_name = '*'

TABLES

dir_list = gdt_ocs_fileImporting parameter 'file_name' is set as '*' means all the file in the specfied directory will be get and stored in the internal table 'gdt_ocs_file'. If the input file is included in the internal table, this file exists.

thanks 7 regards,

shreemohan

Read only

Former Member
0 Likes
3,412

Hi,

Try using the sample code below:




  DATA: l_file TYPE tpfht-pffile                                  .
  DATA:g_data(1000) TYPE c                                        ,
       g_delim TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
  CLEAR l_file                                                    .

  l_file = p_file               "In P_file the path entered on the selection screen in captured                                   .

  CALL FUNCTION 'PFL_CHECK_OS_FILE_EXISTENCE'     "this function module will check the                                                                                
"existence of the file on application server
    EXPORTING
      fully_qualified_filename = l_file
    IMPORTING
      file_exists              = l_true.

  IF l_true = space   .
    MESSAGE e001(zmsg).
  ENDIF               .

*& File upload from application server
  OPEN DATASET l_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
  IF sy-subrc = 0                                              .
    DO.
      READ DATASET l_file INTO g_data                          .
      IF sy-subrc = 0                                          .

        SPLIT g_data AT g_delim INTO
        wa_upload-doc_type
*       wa_upload-neg_posting
        wa_upload-comp_code    wa_upload-currency
        wa_upload-doc_date     wa_upload-pstng_date
        wa_upload-ref_doc_no   wa_upload-accnt
        wa_upload-amt_doccur   wa_upload-indicator
        wa_upload-header_txt   wa_upload-pmnttrms
        wa_upload-payment_meth wa_upload-gl_account
        wa_upload-tax_code     wa_upload-taxjurcode
        wa_upload-kostl        wa_upload-prctr
        wa_upload-alloc_nmbr
*       wa_upload-wbs_element
       wa_upload-item_text                                   .
        .
        IF wa_upload-doc_date IS NOT INITIAL.
          APPEND wa_upload TO it_upload                      .
          CLEAR wa_upload                                    .
        ENDIF                                                .
      ELSE                                                   .
        EXIT                                                 .
      ENDIF                                                  .
    ENDDO                                                    .
    CLOSE   DATASET l_file.
  ELSE.
    MESSAGE e004(zmsg)                                       ." error message if no file is uploaded
  ENDIF                                                      .

*& Check for data exist or not
  IF it_upload[] IS INITIAL.
    MESSAGE e002(zmsg)     .
  ENDIF                    .

Hope this helps

Regards

Mansi

Read only

Former Member
0 Likes
3,411

Hi

Please do one thing,go to basis & ask them to add your program & provide the authorization for read,write & delete.

Read only

Former Member
0 Likes
3,411

Hi,

While using OPEN DATASET statement, take care while giving file path. Because it is case sensitive. If you give it in small case like 'aaa.txt' and if it is stored as 'Aaa.txt' then also it givens error.

Read only

Former Member
0 Likes
3,411

This message was moderated.

Read only

Former Member
0 Likes
3,411

This message was moderated.

Read only

0 Likes
3,411

hey your P_FILE is of type string so when its creating the open dataset filepath the entire string is getting converted into CAPS. AL11 directory path is case sensitive so even though you are entering the correct filepath ald code looks correct it cannot find the directory in app server. Just change the type of P_FILE to FILEINTERN and your code will work. Hope its now clear. Thanks