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

Err with scheduling an abap program using open dataset

Former Member
0 Likes
2,241

issue: have an abap program which uses "open dataset ... for input ..." to read the file.

- with manual ly running it, receive the following message "dataset_not_open".

- with scheduling it, receive same message

attempting to run an abap program as part of a process chain (ie scheduling a background job) in BI.

the abap performs the following fxns:

1) read a file on the server

2) removes delimiter, renames it

3) rewrites the file onto the server

initially used ws_upload for reading and ws_download for writing the file.

- both fxns worked fine if it is run manually --> but failed as a background (part of process chain)

- note 7925 states can't use ws_upload, download for background jobs

-so switched to "open dataset"

Any suggestions as to why the "open dataset" does not work is greatly appreciated it.

B.A.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,089

If you used WS_UPLOAD and WS_DOWNLOAD and they worked in foreground, then the files are on the presentation server. Correct?

If so, OPEN and CLOSE DATASET will not work. They can only be used on the application server.

Rob

15 REPLIES 15
Read only

Former Member
0 Likes
2,089

Hi. Please write your code for opening file.

I recomend you to use transaction AL11. You can check whether you can see you file on the server.

The most popular error in my work is not having permission for this file or folder.

If in AL11 you can see and open your file then problem in your code. Otherwise, you should ask your basis team to change permissions on that file for OS user, which is assigned to SAP.

Read only

Former Member
0 Likes
2,089

Hi BA,

From your question I am not clear whether you got the system message or the custom message you created for OPEN DATASET. But my way of trapping error is to always have the addition MESSAGE msg in my OPEN DATASET. That should give you more detailed error message. Then you can figure out what the issue is. Most of the time the issues are due to permission.

You can use the following sample code

DATA err_mess TYPE string.

OPEN DATASET 'Somefile` FOR INPUT IN BINARY MODE MESSAGE err_mess.

IF sy-subrc <> 0.

  MESSAGE err_mess TYPE 'I'.

ENDIF.

Good luck.

Thanks,

KasthuriRangan Srinivasan

Read only

Former Member
0 Likes
2,089

Thanks, Konstantin.

However, all permissions have been checked and I do have full permission. So, does "BWREMOTE" which takes over when running the process chain (ie background job) in BI

Read only

Former Member
0 Likes
2,089

WS_UPLOAD/DOWNLOAD were replaced with GUI_UPLOAD/DOWNLOAD. However, these are for foreground desktop targets. If your file is on the apps server, and you do open dataset, check your return code....8 = could not open file. You either don't have permissions or you're not pointing to the actual file or alias for the file. Program should not proceed until a check of that return code gives a zero!

Read only

Former Member
0 Likes
2,089

Thank you for all responses. here is more info about the err message:

sy-subrc = 8

'invalid argument'

I looked up the invalid argument in note 99155 --> due to "The destination file is no longer available during repeated file access. " So, the following steps were taken:

- file was regenerated and

- file was placed on the server to be read

have the following code:

OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE encoding default

MESSAGE D_MSG_TEXT.

also have tried the following:

OPEN DATASET d1 for input in text mode encoding default.

open dataset d1 for output in text mode encoding NON-UNICODE..

open dataset d1 for output in text mode encoding utf-8.

none had worked. system --> status shows no unicode.

THanks again for any suggestions.

Read only

0 Likes
2,089

I can only advice to log in on application server as user, which is used by SAP, and try open/write to file.

It's the quickest method I see.

Read only

0 Likes
2,089

Hi BA,

What was the error you got in the variable D_MSG_TEXT. That should tell you the correct problem.

Thanks.

Read only

0 Likes
2,089

Another common mistake dealing with Aplication server files is the case sensitivity.. make sure the path that you are passing for open dataset exactly matched the case that you see in AL11.. check the .DAT or .dat or .TXT or .txt

Read only

Former Member
0 Likes
2,090

If you used WS_UPLOAD and WS_DOWNLOAD and they worked in foreground, then the files are on the presentation server. Correct?

If so, OPEN and CLOSE DATASET will not work. They can only be used on the application server.

Rob

Read only

0 Likes
2,089

Thank you all for your answers.

Rob,

I am trying to run the files on the background. Our Basis is indicating that the presentation and application serve are both on the same server.

Thanks again.

B.A.

Read only

0 Likes
2,089

HI,

How are you passing the file name to the program? "C:" or "
servername\"?

Arash

Read only

0 Likes
2,089

Thanks for your response. Yes, it is hard coded as

Data: FILENAME(128) value '
XXX\XX\file.csv'.

Not using "parameter".

Read only

0 Likes
2,089

Behnaz,

Just to clarify - the presentation server is the PC you, as a user, is logged on to and the application server is where SAP is running. These are two very different things.

Rob is right, if the upload / dowload worked previously using 'WS_*' then the file is residing on your local machine and not the server.

Can you double check this?

Cheers,

Neil.

Read only

0 Likes
2,089

hi,

Did you check in the Application server that what ever the dataset you have created was that created in application sever.. you can track this information using Tcode AL11... just check it...

Regards,

Kiran

Read only

0 Likes
2,089

Thank you Neil and Kiran. You both are right. It used to be in AL11. No longer. The server was partitioned and the file is created in the new partition. eventhough the file is in the same server but is in a different partition

Thank you all for your time, expertise.

B.A.