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: 

run time error in DATASET_TOO_MANY_FILES

Former Member
0 Kudos

Dear Experts,

I am getting a run time error DATASET_TOO_MANY_FILES while running a report. Exception CX_SY_TOO_MANY_FILES.

in the line OPEN DATASET WA_ITA-F1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT . Please help.

Below is the content.

TYPES  : BEGIN OF  T_TABLE  ,

             F1(101) TYPE C ,

         END OF T_TABLE.

  DATA : ITAB TYPE TABLE OF T_TABLE,

         SPACES TYPE I ,

         WA_ITA TYPE T_TABLE.

  DATA: LV_SPACE TYPE STRING.

  LV_SPACE = CL_ABAP_CONV_IN_CE=>UCCP( '00a0' ).

  LOOP AT IT_TABLE INTO WA_TABLE .

    CONCATENATE  WA_TABLE-CRDR WA_TABLE-ACC_NO WA_TABLE-AMOUNT WA_TABLE-NARA1  INTO WA_ITA-F1.

    CONDENSE WA_ITA-F1.

    OPEN DATASET WA_ITA-F1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT .

    SPACES = 101 - STRLEN( WA_ITA-F1 ).

    DO SPACES TIMES.

    CONCATENATE WA_ITA-F1 LV_SPACE INTO WA_ITA-F1.

    ENDDO.

    CLOSE DATASET WA_ITA-F1 .

    APPEND WA_ITA TO ITAB.

    CLEAR WA_ITA.

  ENDLOOP.

  DATA : LW_FILE TYPE STRING.

  LW_FILE = P_FILE.

  CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD

    EXPORTING

*     filename = p_file

      FILENAME = LW_FILE

      FILETYPE = 'DAT'

    CHANGING

*     data_tab = it_table.

      DATA_TAB = ITAB.

ENDFORM.       

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

There's a limit of a number of files those can be open concurrently, if I remember it should be 50, so you should check how many files you're opening

LOOP AT IT_TABLE INTO WA_TABLE .

Here you open file WA_ITA-F1

    CONCATENATE  WA_TABLE-CRDR WA_TABLE-ACC_NO WA_TABLE-AMOUNT WA_TABLE-NARA1                     INTO WA_ITA-F1.

    CONDENSE WA_ITA-F1.

    OPEN DATASET WA_ITA-F1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT .

but then I don't know if you close it because you change the value of WA_ITA-F1

    SPACES = 101 - STRLEN( WA_ITA-F1 ).

    DO SPACES TIMES.

        CONCATENATE WA_ITA-F1 LV_SPACE INTO WA_ITA-F1.

    ENDDO.

and so probably the closing fails

    CLOSE DATASET WA_ITA-F1 .

so after opening the 50th file the dump occurs

It's not clear what you need to do, because you open the file without to read it

Max

4 REPLIES 4

Former Member
0 Kudos

Hi

There's a limit of a number of files those can be open concurrently, if I remember it should be 50, so you should check how many files you're opening

LOOP AT IT_TABLE INTO WA_TABLE .

Here you open file WA_ITA-F1

    CONCATENATE  WA_TABLE-CRDR WA_TABLE-ACC_NO WA_TABLE-AMOUNT WA_TABLE-NARA1                     INTO WA_ITA-F1.

    CONDENSE WA_ITA-F1.

    OPEN DATASET WA_ITA-F1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT .

but then I don't know if you close it because you change the value of WA_ITA-F1

    SPACES = 101 - STRLEN( WA_ITA-F1 ).

    DO SPACES TIMES.

        CONCATENATE WA_ITA-F1 LV_SPACE INTO WA_ITA-F1.

    ENDDO.

and so probably the closing fails

    CLOSE DATASET WA_ITA-F1 .

so after opening the 50th file the dump occurs

It's not clear what you need to do, because you open the file without to read it

Max

0 Kudos

Hi Max,

Thanks for the reply ,

I have written the below code to add spaces and remove # that gets appended to WA_ITA-F1.

  SPACES = 101 - STRLEN( WA_ITA-F1 ).

    DO SPACES TIMES.

        CONCATENATE WA_ITA-F1 LV_SPACE INTO WA_ITA-F1.

    ENDDO.


I have declared above.


DATA: LV_SPACE TYPE STRING.

  LV_SPACE = CL_ABAP_CONV_IN_CE=>UCCP( '00a0' ).

Please correct my code where ever you think is required.

Appreciate your help.


0 Kudos

Hi

if you open a file you don't have to change the name if you want to close it:

- Here you define te name of the file has to be open:


  LOOP AT IT_TABLE INTO WA_TABLE .

    CONCATENATE  WA_TABLE-CRDR WA_TABLE-ACC_NO WA_TABLE-AMOUNT WA_TABLE-NARA1  INTO WA_ITA-F1.

    CONDENSE WA_ITA-F1.

    OPEN DATASET WA_ITA-F1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT .

So if OPEN DATASET is ok you shouldn't change the file name so WA_ITA-F1, if you need to do it you should use a new variable where you can store the old value:


  OPEN DATASET WA_ITA-F1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT .

   IF SY-SUBRC = 0.

      WA_FILENAME = WA_ITA-F1.

   ELSE.

      CLEAR WA_FILENAME.

   ENDIF.

Now you can change the value of WA_ITA-F1 amd use WA_FILENAME to close te file


    SPACES = 101 - STRLEN( WA_ITA-F1 ).

    DO SPACES TIMES.

        CONCATENATE WA_ITA-F1 LV_SPACE INTO WA_ITA-F1.

     ENDDO.

    CLOSE DATASET WA_ITA-F1 .

    IF WA_FILENAME IS NOT INITIAL. " It means the file is open

        CLOSE DATASET WA_FILENAME .

    ENDIF.

     APPEND WA_ITA TO ITAB.

    CLEAR WA_ITA.

  ENDLOOP.

Now you shouldn't have the dump because you'll ave only one file open

Max

0 Kudos

     Thanks max for explaining in details.