Application Development 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: 

DATASET_TOO_MANY_FILES Exception raised

Former Member
0 Kudos
1,485

Hello dudes,

we are currently facing a problem we cannot solve and you are my last chance.

There is a need to perform the following algorithm:

loop at internal_table.

OPEN dataset FILE for output.

transfer internal_table-field to FILE.

Close dataset.

endloop.

<...>

loop at directory.

open dataset FILE for input.

read FILE <...>.

close dataset.

When the program treats the 105th file, an exception is raised: DATASET_TOO_MANY_FILES which corresponds to an error due to a large amount of files opened and not closed.

I cannot explain this error since all open dataset instructions are followed with a close dataset one.

Please help.

Points will be assigned.

Thanks a lot for your help.

Cheers,

Cyril.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
373

Hi,

The close dataset does not seem to realy close the files that you open on server. This seems to trigger the error reported.

As a workaround, you can try this way:

write a separate program that accepts the file name and the contnets to be uploaded on selection screen and has code to open, tranfer and close actions.

you can call this program repeatedly inside your loop using 'submit'.

7 REPLIES 7

Former Member
0 Kudos
373

put open dataset and close dataset outside of the loops and see what happens

Former Member
0 Kudos
373

data: outrec(200) type c.

OPEN dataset p_file for output encoding default.

loop at internal_table.

outrec+0(5) = itab-field1.

outrec+10(5) = itab-field2.

outrec+20(5) = itab-field3.

transfer outrec to FILE.

clear outrec.

endloop.

Close dataset.

regards,

venkat

0 Kudos
373

Hello,

thanks a lot both for your quick answer.

I omited to precise that we need to generate as many file as there are lines in the file (we regenerate a new name for each line).

here is the exact algorithm of our program:

loop at internal_table.

perform get_new_file_name.

OPEN dataset FILE for output.

transfer internal_table-field to FILE.

Close dataset.

endloop.

<...>

loop at directory.

perform get_new_file_name.

open dataset FILE for input.

read FILE <...>.

close dataset.

Thanks a lot for your time and your help.

Cheers,

Cyril.

Edited by: Cyril Naudes on Apr 2, 2008 11:46 AM

0 Kudos
373

have you tried using


close dataset FILE.

It looks like the files you are opening are never closing

0 Kudos
373

Hi,

yes, the previous post is just an algorithm. Here is the exact code:

FORM ZSCAIF_GEN_BI_DOC.

LOOP AT GT_CSV2 INTO GS_CSV. "GI_csv contains each field of the flat file

CLEAR : GV_DESCRIPTION, GV_TECH_NAME,

* creation of file name and file path (3 cases)

GV_COUNT,

GV_FILENAME,

GV_FULLFILENAME.

WHILE GV_COUNT LE 2.

* w_count goes from 0 to 2, as there are 3 fields to store for each line

* GV_C1 will take following values : removal_reason, ship_to_address, Tech_data

CASE GV_COUNT.

WHEN 0.

* removal reason file

MOVE TEXT-REM TO GV_C1. " TEXT-REM = 'r_r'

WHEN 1.

* ship to address file

MOVE TEXT-STA TO GV_C1. " TEXT-STA = 's_t_a'

WHEN 2.

* technical data on the repair file

MOVE TEXT-TED TO GV_C1. " TEXT-TED = 't_d'

WHEN OTHERS.

. " do nothing.

ENDCASE.

***********add on - JDE - 21022008

* need to avoid creating empty documents

IF ( GV_COUNT EQ 0 AND GS_CSV-/BIC/XREMREAS IS NOT INITIAL ) OR

( GV_COUNT EQ 1 AND GS_CSV-/BIC/XSHIPTOAD IS NOT INITIAL ) OR

( GV_COUNT EQ 2 AND GS_CSV-/BIC/XTECHDATA IS NOT INITIAL ).

***********end of add on

CONCATENATE: P_PREF GV_C1 '_' GS_CSV-/BIC/XREPORDER '.txt'

INTO GV_FILENAME,

P_OUTDIR GV_FILENAME INTO GV_FULLFILENAME.

* creation of the text file

OPEN DATASET GV_FULLFILENAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF SY-SUBRC NE 0.

MESSAGE E127(SY) WITH GV_FFNAME ''.

ENDIF.

* write in and close it

CASE GV_COUNT.

WHEN 0.

MOVE : GS_CSV-/BIC/XREMREAS TO GS_OUTFILE, "content of the file

TEXT-RRT TO GV_DESCRIPTION. "description of the document

CONCATENATE P_PREF GV_C1 GS_CSV-/BIC/XREPORDER INTO GV_TECH_NAME. "name of the document (technical)

WHEN 1.

MOVE : GS_CSV-/BIC/XSHIPTOAD TO GS_OUTFILE,

TEXT-SHT TO GV_DESCRIPTION. "description of the document

CONCATENATE P_PREF GV_C1 GS_CSV-/BIC/XREPORDER INTO GV_TECH_NAME. "name of the document (technical)

WHEN 2.

MOVE : GS_CSV-/BIC/XTECHDATA TO GS_OUTFILE,

TEXT-TDT TO GV_DESCRIPTION. "description of the document

CONCATENATE P_PREF GV_C1 GS_CSV-/BIC/XREPORDER INTO GV_TECH_NAME. "name of the document (technical)

WHEN OTHERS.

. "do nothing.

ENDCASE.

TRANSFER GS_OUTFILE TO GV_FULLFILENAME.

CLOSE DATASET GV_FULLFILENAME.

ENDLOOP.

ENDFORM.

Thanks a lot all for your help.

Cheers,

Cyril.

Former Member
0 Kudos
374

Hi,

The close dataset does not seem to realy close the files that you open on server. This seems to trigger the error reported.

As a workaround, you can try this way:

write a separate program that accepts the file name and the contnets to be uploaded on selection screen and has code to open, tranfer and close actions.

you can call this program repeatedly inside your loop using 'submit'.

0 Kudos
373

You're my saviour!

Thanks a lot your answer solved the problem!

Cheers,

Cyril.