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

DATASET_NOT_OPEN

Former Member
0 Likes
3,879

Hi,

We want to upload a text file placed in the application server to Ztable through background job. We searched for the code snippet, got and used that in our program. Previously, we used gui_upload. That did not work. So we switched to open and read dataset.

When we run the program using SE38, it works fine but when we configure the job and run, it gets cancelled and generates dump with the message: Dataset_not_open. As it can be run successfully using 38, there should not be any permission issue with the file. We also can view the file from AL11.

Could you help me point out where it has gone wrong?

Please find below the code snippet.

**************upload data from NIS****************************
*  CONCATENATE h_path '/nis_data1/Attd.txt' INTO file.
   file = '/usr/sap/ARP/DVEBMGS00/data/trf/nis/Attd.txt'.

   DATA : var(50).
   CLEAR : l_index, var.
*--Read the data from application server file.
   OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

   DO.
     READ DATASET file INTO l_line.
     IF sy-subrc <> 0.
       EXIT.
     ELSE.
       l_index = l_index + 1.
       it_input_nis-input_string = l_line.
**********************************************************
       IF l_index > 1.

         SPLIT it_input_nis AT ',' INTO  it_input_xls_bok_nis-sr_no
                                           it_input_xls_bok_nis-date
                                           it_input_xls_bok_nis-time
                                           it_input_xls_bok_nis-empcode
                                           it_input_xls_bok_nis-name
                                           it_input_xls_bok_nis-card_no
                                           var.

         REPLACE ALL OCCURRENCES OF '-' IN it_input_xls_bok_nis-date WITH '.'.
         TRANSLATE it_input_xls_bok_nis-date TO UPPER CASE.

         REPLACE ALL OCCURRENCES OF ':' IN it_input_xls_bok_nis-time WITH '.'.
         it_input_xls_bok_nis-time = it_input_xls_bok_nis-time(5).

         APPEND it_input_xls_bok_nis.
         CLEAR it_input_xls_bok_nis.
       ENDIF.
     ENDIF.
   ENDDO.
   CLOSE DATASET file.
*************************************************************

<added code tags>

Regards

Palash

Message was edited by: Suhas Saha

Hi,

We want to upload a text file placed in the application server to Ztable through background job. We searched for the code snippet, got and used that in our program. Previously, we used gui_upload. That did not work. So we switched to open and read dataset.

When we run the program using SE38, it works fine but when we configure the job and run, it gets cancelled and generates dump with the message: Dataset_not_open. As it can be run successfully using 38, there should not be any permission issue with the file. We also can view the file from AL11.

Could you help me point out where it has gone wrong?

Please find below the code snippet.

**************upload data from NIS****************************
*  CONCATENATE h_path '/nis_data1/Attd.txt' INTO file.
   file = '/usr/sap/ARP/DVEBMGS00/data/trf/nis/Attd.txt'.

   DATA : var(50).
   CLEAR : l_index, var.
*--Read the data from application server file.
   OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

   DO.
     READ DATASET file INTO l_line.
     IF sy-subrc <> 0.
       EXIT.
     ELSE.
       l_index = l_index + 1.
       it_input_nis-input_string = l_line.
**********************************************************
       IF l_index > 1.

         SPLIT it_input_nis AT ',' INTO  it_input_xls_bok_nis-sr_no
                                           it_input_xls_bok_nis-date
                                           it_input_xls_bok_nis-time
                                           it_input_xls_bok_nis-empcode
                                           it_input_xls_bok_nis-name
                                           it_input_xls_bok_nis-card_no
                                           var.

         REPLACE ALL OCCURRENCES OF '-' IN it_input_xls_bok_nis-date WITH '.'.
         TRANSLATE it_input_xls_bok_nis-date TO UPPER CASE.

         REPLACE ALL OCCURRENCES OF ':' IN it_input_xls_bok_nis-time WITH '.'.
         it_input_xls_bok_nis-time = it_input_xls_bok_nis-time(5).

         APPEND it_input_xls_bok_nis.
         CLEAR it_input_xls_bok_nis.
       ENDIF.
     ENDIF.
   ENDDO.
   CLOSE DATASET file.
*************************************************************

<added code tags>

Regards

Palash

Message was edited by: Suhas Saha

8 REPLIES 8
Read only

Former Member
0 Likes
3,026

check if the command OPEN DATASET  was successful.

Read only

0 Likes
3,026

Weird situation... Can you please paste the dump data ?

Read only

0 Likes
3,026

Hi,

We usually get DATASET_NOT_OPEN dump when we are trying to READ or TRANSFER from/to a file which is not present in application server.

So it's better try usin a sy-subrc check soon after OPEN DATASET statement.

Read only

Former Member
0 Likes
3,026

file names at server level are case sensitive, so be sure that is correct  And, always, always, check the value of sy-subrc on dataset operations before proceeding.  If zero proceed to input the file and CLOSE the dataset at the end of the input....

Check your definition of the file name ( I usually type as localfile or type textnnn).  if you are using a variant, be sure that you have each character in the filename precisely correct, including the case, whether upper or lower.

What userid is executing the background job?  Check with your basis guys to be sure that the user has the necessary capability in the folders that you are accessing....and finally, be sure that the file is indeed where you think it is.

Read only

venkateswaran_k
Active Contributor
0 Likes
3,026

Hi

I had a similar situation while fetching an xml file from the shared location.  It worked fine in my laptop throug SE38, however on background job it was cancelled.  So I made followng changes and it started working fine.  I mention my changes here.. You may also try it.

1. Very important one - make sure the Application server can access your shared file folder

2. Open in BINARY Mode

        l_filename = p_filnam   "'\\XXXXXX\FILESERVER\SAP\MR\MR-842.xml'.

       OPEN DATASET l_filename FOR INPUT in BINARY MODE .

       DO.

        READ DATASET l_filename INTO l_xml_line.

         IF sy-subrc EQ 0.

           APPEND l_xml_line TO l_xml_table.

         ELSE.

           EXIT.

         ENDIF.

       ENDDO.

Please post back with your results

Regards,

Venkat

Read only

0 Likes
3,026

Hi Venkat

I have tried all this possible ways (which are suggested above by our sap gurus) to open dataset and read it in a file which is also working fine when I execute the program through SE38. So there is no abap problem I think. I have the full authorization in directory where the raw file is situated. When i schedule the program as a background job then one time it successfully completed the task but after that it is getting a dump 'dataset_not_open'.

I have prepared the job by SM36..where i gave jobname as 'ZJOB' then Job class as 'C'      Status is Schedule. Then press enter , a pop open. I gave program name and laguage as 'EN' then save and check.  After clicking on start condition, I have scheduled immediately.

Regards

Swati

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
3,026

Did you check for SAP notes for this issue ?

Read only

0 Likes
3,026

Did you mean 854044?

That is what I got in SDN. We are on ECC6 pack basis level 701. That is not applicable for us as told by our basis guy