2008 Apr 01 6:31 PM
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.
2008 Apr 04 9:33 AM
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'.
2008 Apr 01 6:33 PM
put open dataset and close dataset outside of the loops and see what happens
2008 Apr 01 6:45 PM
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
2008 Apr 02 7:52 AM
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
2008 Apr 03 5:21 PM
have you tried using
close dataset FILE.
It looks like the files you are opening are never closing
2008 Apr 04 8:02 AM
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.
2008 Apr 04 9:33 AM
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'.
2008 Apr 04 10:53 AM
You're my saviour!
Thanks a lot your answer solved the problem!
Cheers,
Cyril.