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

TSV_TNEW_PAGE_ALLOC_FAILED: how to split internal table?

former_member211576
Contributor
0 Likes
2,079

Hi experts,

   I am a basis and I saw "TSV_TNEW_PAGE_ALLOC_FAILED" from time to time. I believe I give heap and extended memory very generous(8GB of 32GB, see below). Could you see the program segment below and tell me how to divide and conquer memory consumption issue?

    Roll area...................... 2718272

    Extended memory (EM)........... 2002720576

    Assigned memory (HEAP)......... 8000041584

    Short area..................... " "

    Paging area.................... 40960

    Maximum address space.......... " "

---

  SELECT mkpf~mblnr mkpf~mjahr mkpf~bktxt mkpf~budat mkpf~cputm mkpf~usnam

         mkpf~usnam mseg~mblnr mseg~matnr mseg~werks mseg~lgort

         mseg~zeile mseg~bwart mseg~menge mseg~umwrk mseg~umlgo mseg~lifnr

         mseg~aufnr mseg~ebeln mseg~shkzg mseg~kostl mseg~sgtxt mseg~charg

    INTO CORRESPONDING FIELDS OF TABLE imseg

    FROM ( mkpf JOIN mseg ON mkpf~mblnr =  mseg~mblnr AND

          mkpf~mjahr =  mseg~mjahr )

   WHERE  mseg~mblnr IN s_doc

      AND mseg~matnr IN s_mat

      AND mseg~werks IN s_plt

      AND mseg~lgort IN s_stl

      AND mseg~bwart IN s_mty

      AND mseg~sobkz IN s_spe

      AND mseg~kostl IN s_kostl

      AND mseg~/bev2/ed_aedat IN s_cdt

      AND mkpf~usnam IN s_pnm .

----

    PERFORM get_from_mseg_matnr.

  ENDIF.

  SORT itab BY mblnr matnr.

  LOOP AT itab.

    WRITE: / itab-mblnr,

       13(12) itab-matnr,                    "46 ITAB-WERKS,

       26 itab-lgort,

       33 itab-refno,

       46 itab-budat,

       59 itab-lifnr,

       70 itab-bwart,

       76(14) itab-menge DECIMALS 0,

       93 itab-kostl,

       99(35) itab-bktxt,                 "ITAB-BUDAT,

       160 itab-cputm.

1 ACCEPTED SOLUTION
Read only

Sougata
Active Contributor
0 Likes
1,080

Hi Dennis,

The developer should use the PACKAGE SIZE addition to the SELECT statement in order to avoid the internal table from growing too big i.e. growing more than the space allowed by the system parameter.

This is clearly an example of poor programming. The approach should be similar to the code below:

DATA:

   tbl_outrec      TYPE STANDARD TABLE OF ty_tbl_outrec,

   tbl_bsegout   TYPE STANDARD TABLE OF ty_tbl_bsegout,

   tbl_bkpf        TYPE HASHED TABLE OF bkpf

                           WITH UNIQUE KEY mandt bukrs belnr gjahr,

   tbl_bseg       TYPE HASHED TABLE OF bseg

                           WITH UNIQUE KEY mandt bukrs belnr gjahr buzei.

     SELECT bukrs belnr gjahr FROM bkpf PACKAGE SIZE 10000

         INTO CORRESPONDING FIELDS OF TABLE lt_bkpf

         WHERE   bukrs IN s_bukrs

         AND         budat IN s_budat.

         TRY.

             SELECT * FROM bseg PACKAGE SIZE 50000

               INTO CORRESPONDING FIELDS OF TABLE tbl_bseg

               FOR ALL ENTRIES IN lt_bkpf

               WHERE bukrs = lt_bkpf-bukrs

               AND       belnr = lt_bkpf-belnr

               AND       gjahr = lt_bkpf-gjahr.

               LOOP AT tbl_bseg ASSIGNING <ls_bseg>.

                 APPEND INITIAL LINE TO tbl_bsegout ASSIGNING <ls_rec>.

                 MOVE-CORRESPONDING <ls_bseg> TO <ls_rec>.

               ENDLOOP.

               PERFORM write_file USING tbl_bsegout.

              FREE:

                 tbl_bseg,

                 tbl_bsegout.

             ENDSELECT.                                          "SELECT FROM BSEG

           CATCH cx_sy_open_sql_db INTO lx_open_sql.

             lv_text = lx_open_sql->if_message~get_text( ).

             MESSAGE e000 WITH lv_text.

         ENDTRY.

        FREE lt_bkpf.

    ENDSELECT.                                                   "SELECT FROM BKPF   

Hope this helps.

Cheers,

Sougata.

6 REPLIES 6
Read only

gouravkumar64
Active Contributor
0 Likes
1,080

Hi,

May be it's an issue of MEMORY,You can check & extend the memory size / Parameter from RZ10 / RZ11.

Before some days one of my friend solve the issue using this thread.

http://scn.sap.com/thread/3383244

Also check SAP NOTES like

1322182,649327 ,20527 ETC.

Hope it helps.

Thanks

Gourav.

Read only

Former Member
0 Likes
1,080

Hi Dennis,

Please talk to your ABAP team and check what exactly this program is doing. You can ask them to refine the selection/search criteria as well, when they are executing the program.

Thanks

Abhishek.

Read only

Former Member
0 Likes
1,080

Hi Dennis,

The ABAPers can use the PACKAGE size statement in the SELECT statment.

DATA: l_psize TYPE i VALUE 10000.

Select .... from Table ....into inttable PACKAGE SIZE  l_psize WHERE condition.

Maybe this will help 🙂

Read only

Sougata
Active Contributor
0 Likes
1,081

Hi Dennis,

The developer should use the PACKAGE SIZE addition to the SELECT statement in order to avoid the internal table from growing too big i.e. growing more than the space allowed by the system parameter.

This is clearly an example of poor programming. The approach should be similar to the code below:

DATA:

   tbl_outrec      TYPE STANDARD TABLE OF ty_tbl_outrec,

   tbl_bsegout   TYPE STANDARD TABLE OF ty_tbl_bsegout,

   tbl_bkpf        TYPE HASHED TABLE OF bkpf

                           WITH UNIQUE KEY mandt bukrs belnr gjahr,

   tbl_bseg       TYPE HASHED TABLE OF bseg

                           WITH UNIQUE KEY mandt bukrs belnr gjahr buzei.

     SELECT bukrs belnr gjahr FROM bkpf PACKAGE SIZE 10000

         INTO CORRESPONDING FIELDS OF TABLE lt_bkpf

         WHERE   bukrs IN s_bukrs

         AND         budat IN s_budat.

         TRY.

             SELECT * FROM bseg PACKAGE SIZE 50000

               INTO CORRESPONDING FIELDS OF TABLE tbl_bseg

               FOR ALL ENTRIES IN lt_bkpf

               WHERE bukrs = lt_bkpf-bukrs

               AND       belnr = lt_bkpf-belnr

               AND       gjahr = lt_bkpf-gjahr.

               LOOP AT tbl_bseg ASSIGNING <ls_bseg>.

                 APPEND INITIAL LINE TO tbl_bsegout ASSIGNING <ls_rec>.

                 MOVE-CORRESPONDING <ls_bseg> TO <ls_rec>.

               ENDLOOP.

               PERFORM write_file USING tbl_bsegout.

              FREE:

                 tbl_bseg,

                 tbl_bsegout.

             ENDSELECT.                                          "SELECT FROM BSEG

           CATCH cx_sy_open_sql_db INTO lx_open_sql.

             lv_text = lx_open_sql->if_message~get_text( ).

             MESSAGE e000 WITH lv_text.

         ENDTRY.

        FREE lt_bkpf.

    ENDSELECT.                                                   "SELECT FROM BKPF   

Hope this helps.

Cheers,

Sougata.

Read only

0 Likes
1,080

Hi Sougate and Jacob,

    I believe this is what I am looking for. Thanks a lot. I will tell our developers to re-write SELECT with PACKAGE SIZE.

Read only

Former Member
0 Likes
1,080

Hi Dennis,

I am sure it will solve the issue and You wont see the Red and Blue Screen ( Error 🙂 )