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

OPEN DATASET Problem

Former Member
0 Likes
912

Hi Friends,

I have issue in the OPEN DATASET Statement.

From this statement how to handle the exceptions. Pls give me a sample coding.

f_filename = '/usr/sap/DBI/INVD.txt'.

OPEN DATASET f_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

How to check the errors and handle the error in a background process.

Pls help

Regards

Thanura

9 REPLIES 9
Read only

Former Member
0 Likes
807
DATA mess TYPE string. 

OPEN DATASET `` FOR INPUT IN BINARY MODE MESSAGE mess. 

IF sy-subrc = 8. 
  MESSAGE mess TYPE 'I'. 
ENDIF.
Read only

0 Likes
807

Hi,

This statement fails always in the production system only. In our development server it always run perfectly.

Is there any specific reason why this fails only in production system.?

When it's fails what do I have to do to make it happen. It means I have to overwrite the text file always. If it fails how to make it happen.?

Regards

Thanura

Read only

Former Member
0 Likes
807

Hi,

You can check out the results through sy-subrc. it may take values 0,4,8 etc..

for complete details do F1 on OPEN DATASET you can see different values & reasons for the same.

Regards,

Raghavendra

Read only

Former Member
0 Likes
807
DATA mess TYPE string. 

OPEN DATASET `` FOR INPUT IN BINARY MODE MESSAGE mess IGNORING CONVERSION ERRORS. 

IF sy-subrc = 8. 
  MESSAGE mess TYPE 'I'. 
ENDIF.
Read only

0 Likes
807

Hi,

Why this binary mode.

Can't we use TEXT mode.

Pls clarify

REgards

Thanura.

Read only

0 Likes
807

Hi,

Handling error is not enough for me.

The text file I am try to create have to create always. When it fails What do I have to do to recreate it.

Regards

Thanura

Read only

Former Member
0 Likes
807

Hi,

Whenever you open the file in OUTPUT mode, if the file already exists, then SAP will overwrite it & if it doesnt exists, then SAP will create a new one.

You dont have to worry @ it.

The only problem for an error could be if you dont have authorization to access the folder. In that case you need to use some other path for which you have authorization.

Best regards,

Prashant

Read only

0 Likes
807

Hi,

Thanks and u are correct. If the text file is there it overwrites and if it is not it creates.

But my issue is when I run at first time it creates the test file and when I run it second it give me the message 'No such file or directory'.

What do I have to do for this.?

Best regards

Thanura

Read only

Former Member
0 Likes
807

op[[