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 dump

Former Member
0 Likes
2,568

Hi,

When I try the following, everything works, no dumps:

OPEN DATASET par_file5 FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.

TRANSFER V1 TO par_file5.

CLOSE DATASET par_file5.

OPEN DATASET par_file5 FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.

READ DATASET par_file5 INTO V2.

CLOSE DATASET par_file5.

However, when I comment the 1st open dataset section and just leave the second, I get a dump with the message 'DATASET_NOT_OPEN'. Why is this happening?

Also, is it possible to read the dataset details (when it was created, by whom, etc) from some table/

Please help.

Thanks,

John

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,890

Hi John

Can we have a look at your code? (complete)

Regards

Raj

12 REPLIES 12
Read only

Former Member
0 Likes
1,890

OPEN DATASET par_file5 FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.

READ DATASET par_file5 INTO V2.

CLOSE DATASET par_file5.

OPEN DATASET par_file5 FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.

TRANSFER V1 TO par_file5.

CLOSE DATASET par_file5.

Just swap both and try.

First read the file if not exist Than create(output).

Read only

Former Member
0 Likes
1,890

Hi,

You might be getting a dump because the file is not created at all. But I don't think it should give a dump rather it should return sy-subrc 8.

In practice you write something to the file , only then you would read.

Also check this, not sure it i helps but give it a try [documentation|http://help.sap.com/erp2005_ehp_04/helpdata/EN/79/c554dcb3dc11d5993800508b6b8b11/frameset.htm]

regards,

Advait

Read only

0 Likes
1,890

Well, this 1st one creates it:

OPEN DATASET par_file5 FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.

TRANSFER V1 TO par_file5.

CLOSE DATASET par_file5.

Then if I try a separate program to read it, i get the message:

OPEN DATASET par_file5 FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.

READ DATASET par_file5 INTO V2.

CLOSE DATASET par_file5.

If you put them both in one program together, it reads it without problem.

Read only

0 Likes
1,890

Hmm, that is strange, what is the sy-subrc after

OPEN DATASET par_file5 FOR INPUT IN TEXT MODE ENCODING NON-UNICODE ?

Is the file getting created with the first statment in the other program.

Also make sure that the program that is reading the file is running after the program that is creating it.

regards,

Advait

Read only

0 Likes
1,890

Sy-subrc is 8. Am I doing anything wrong?

The file is crashing with 2nd line - READ DATASET par_file5 INTO V2.

Error Short text" File <file name> is not open.

Even if I tried extracting it later in the day, it should read the dataset. The dataset shouldn't be deleted and should be created. Does it always have to be part of one program?

Read only

0 Likes
1,890

Could be, as I said did you see if the file really exists with the name that you are passing to the second open dataset statement ? And also ensure that run the file creation program first and then the file reading program next.

No it is not necessary that it should be part of one program. As far as you pass the the same filename to the reading program as you had while creating the file.

regards,

Advait

Edited by: Advait Gode on Dec 9, 2008 12:00 AM

Read only

0 Likes
1,890

Well, it is creating the file in one program, then reading in the next. Thats definitely not the problem.

Is there a way to check if a file was created (application server)?

The problem with the same file name logic, is that there already is a standard program in our system that writes the dataset name as 'program name''date''time'. Then later, they want to extract it to a different format via a custom program. So it would be 2 different file names, but the same dataset name. For example, dataset par_file, one with a time containing 1 time and another with a name containing another time.

It works in succession, creating and debugging when both sections are in one program - with different filenames since the seconds are different.

Read only

Former Member
0 Likes
1,891

Hi John

Can we have a look at your code? (complete)

Regards

Raj

Read only

0 Likes
1,890

This is my test code

DATA: par_file5 LIKE ifibl_aux_fields-allgunix. "Filename

DATA: V1(5) TYPE C VALUE 'HELLO',

V2(5) TYPE C.

IF par_file5 EQ space. "Kein Dateiname wurde angegeben

par_file5 = sy-repid. "--> Namen generieren

par_file5+8 = '.'.

WRITE sy-datlo TO par_file5+9(6) YYMMDD.

par_file5+15 = '.'.

par_file5+16 = sy-timlo.

CONDENSE par_file5 NO-GAPS.

ENDIF.

*OPEN DATASET par_file5 FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.

*TRANSFER V1 TO par_file5.

*CLOSE DATASET par_file5.

OPEN DATASET par_file5 FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.

READ DATASET par_file5 INTO V2.

CLOSE DATASET par_file5.

V1 = '999'.

One program will contain the transfer dataset section, while the others contains the read dataset section.

Read only

0 Likes
1,890

you cant do a READ command if the dataset is not open. You need to check sy-subrc after open, and do read and close only if sy-subrc is 0 after OPen

Read only

0 Likes
1,890

Hi,

You code will only work in the same program. Reason is that you are generating the file name dynamically using lot of parameters. Now in order to read the file that was created, you need to pass the exact file name. If you pass the sy-repid and sy-timlo to the file name variable, it is certainly not going to find the filename. Because the program name will be different and the time of execution will also differ.

Solution : Store the file name when it is created in a custom table. Read it in second program and pass that name to the dataset name of the open dataset statement.

regards,

Advait

Read only

Former Member
0 Likes
1,890

Hi

Advait Gode is right in telling you that both the writting and reading should be in same program.

Because, you are using the system variable sy-repid and field for system time to build your file name.

Best way to avaoid any kind of dumps is to proceed further with processing (either writing or reading) based on the success of Open dataset statement.

Remember to close the dataset after finishing your work.

Regards

Raj