Skip to Content
author's profile photo Former Member
Former Member

error on extend an internal table, but the required space was not available

Hi All,

I am trying to retrieve cost data from COVP tables, as well as the quantity, cost centre, and price unit fields from MSEG / BSEG tables. Thing is, if the AWTYP value in COVP table = 'MKPF', i have to get the data from MSEG, otherwise, I need to get it from BSEG table.

I kept getting this error message:

<i>You attempted to extend an internal table, but the required space was not available.</i>

Anyone have any idea how to make my codes more efficient?

Please help. Thanks!

Regards,

Cecilia

REPORT  ZMISCY004.
TABLES : COVP, BSIS, BSEG, MSEG, MAKT, CSKU.

PARAMETERS :
P_FILE(300) DEFAULT '\sapdcdatasaprptoh.txt' LOWER CASE.

DATA MSG_TEXT(50).

DATA :
XKOKRS LIKE COVP-KOKRS,
XBELNR LIKE COVP-BELNR,
XBUZEI LIKE COVP-BUZEI,
XGJAHR LIKE COVP-GJAHR,
XPERIO LIKE COVP-PERIO,
XWKGBTR LIKE COVP-WKGBTR,
XWTGBTR LIKE COVP-WTGBTR,
XREFBN LIKE COVP-REFBN,
XREFBZ LIKE COVP-REFBZ,
XKSTAR LIKE COVP-KSTAR,
XBEKNZ LIKE COVP-BEKNZ,
XMATNR LIKE COVP-MATNR,
XBUKRS LIKE COVP-BUKRS,
XREFGJ LIKE COVP-REFGJ,
XREFBK LIKE COVP-REFBK,
XLTEXT LIKE CSKU-LTEXT,
XMAKTX LIKE MAKT-MAKTX,
XAWTYP LIKE COVP-AWTYP,
XTWAER LIKE COVP-TWAER,
XSGTXT LIKE COVP-SGTXT,
BSEG_KOSTL LIKE BSEG-KOSTL,
BSEG_MEINS LIKE BSEG-MEINS,
BSEG_MENGE LIKE BSEG-MENGE,
MSEG_KOSTL LIKE MSEG-KOSTL,
MSEG_MENGE LIKE MSEG-MENGE,
MSEG_MEINS LIKE MSEG-MEINS.




DATA : BEGIN OF ITAB_COVP OCCURS 10,
KOKRS LIKE COVP-KOKRS,
BELNR LIKE COVP-BELNR,
BUZEI LIKE COVP-BUZEI,
GJAHR LIKE COVP-GJAHR,
PERIO LIKE COVP-PERIO,
WKGBTR(15) TYPE C,
WTGBTR(15) TYPE C,
REFBN LIKE COVP-REFBN,
REFBZ(3) TYPE C,
KSTAR LIKE COVP-KSTAR,
BEKNZ LIKE COVP-BEKNZ,
MATNR LIKE COVP-MATNR,
BUKRS LIKE COVP-BUKRS,
REFGJ LIKE COVP-REFGJ,
REFBK LIKE COVP-REFBK,
LTEXT LIKE CSKU-LTEXT,
MAKTX LIKE MAKT-MAKTX,
AWTYP LIKE COVP-AWTYP,
TWAER LIKE COVP-TWAER,
SGTXT LIKE COVP-SGTXT,
BSIS_WRBTR(13) TYPE C,
BSEG_KOSTL LIKE BSEG-KOSTL,
BSEG_MEINS LIKE BSEG-MEINS,
BSEG_MENGE LIKE BSEG-MENGE,
MSEG_KOSTL LIKE MSEG-KOSTL,
MSEG_MENGE LIKE MSEG-MENGE,
MSEG_MEINS LIKE MSEG-MEINS.
DATA : END OF ITAB_COVP.

SELECT M1~KOKRS
       M1~BELNR
       M1~BUZEI
       M1~GJAHR
       M1~PERIO
       M1~WKGBTR
       M1~WTGBTR
       M1~REFBN
       M1~REFBZ
       M1~KSTAR
       M1~BEKNZ
       M1~MATNR
       M1~BUKRS
       M1~REFGJ
       M1~REFBK
       M1~AWTYP
       M1~TWAER
       M1~SGTXT
       M4~KOSTL
       M4~MENGE
       M4~MEINS

INTO (XKOKRS,
      XBELNR,
      XBUZEI,
      XGJAHR,
      XPERIO,
      XWKGBTR,
      XWTGBTR,
      XREFBN,
      XREFBZ,
      XKSTAR,
      XBEKNZ,
      XMATNR,
      XBUKRS,
      XREFGJ,
      XREFBK,
      XAWTYP,
      XTWAER,
      XSGTXT,
      MSEG_KOSTL,
      MSEG_MENGE,
      MSEG_MEINS
      )
FROM COVP AS M1
LEFT OUTER JOIN MSEG AS M4
ON M1~REFBN = M4~MBLNR AND M1~REFBZ = M4~ZEILE AND M1~REFGJ = M4~MJAHR
WHERE M1~SCOPE = 'OCOST' AND M1~AWTYP = 'BKPF'
  OR M1~SCOPE = 'OCOST' AND M1~AWTYP = 'MKPF'
  OR M1~KSTAR = '972022'.

IF XAWTYP = 'BKPF'.
SELECT KOSTL MENGE MEINS INTO (BSEG_KOSTL, BSEG_MENGE, BSEG_MEINS) FROM
BSEG WHERE BELNR = XREFBN AND BUZEI = XREFBZ AND GJAHR = XREFGJ AND
BUKRS = XREFBK.
ENDSELECT.
MOVE BSEG-KOSTL TO BSEG_KOSTL.
MOVE BSEG-MEINS TO BSEG_MEINS.
MOVE BSEG-MENGE TO BSEG_MENGE.

ELSE.
MOVE ' ' TO BSEG_KOSTL.
MOVE ' ' TO BSEG_MEINS.
MOVE ' ' TO BSEG_MENGE.
ENDIF.


*GET LTEST
SELECT LTEXT INTO XLTEXT
FROM CSKU
WHERE KTOPL = 'COAA' AND SPRAS = 'EN'.

*GET MAKTX
IF XMATNR <> ' '.
SELECT SINGLE * FROM MAKT WHERE MATNR = XMATNR.
MOVE MAKT-MAKTX TO XMAKTX.
ELSE.
MOVE ' ' TO XMAKTX.
ENDIF.

MOVE : XKOKRS TO ITAB_COVP-KOKRS,
       XBELNR TO ITAB_COVP-BELNR,
       XBUZEI TO ITAB_COVP-BUZEI,
       XGJAHR TO ITAB_COVP-GJAHR,
       XPERIO TO ITAB_COVP-PERIO,
       XWKGBTR TO ITAB_COVP-WKGBTR,
       XWTGBTR TO ITAB_COVP-WTGBTR,
       XREFBN TO ITAB_COVP-REFBN,
       XREFBZ TO ITAB_COVP-REFBZ,
       XKSTAR TO ITAB_COVP-KSTAR,
       XBEKNZ TO ITAB_COVP-BEKNZ,
       XMATNR TO ITAB_COVP-MATNR,
       XBUKRS TO ITAB_COVP-BUKRS,
       XREFGJ TO ITAB_COVP-REFGJ,
       XREFBK TO ITAB_COVP-REFBK,
       XLTEXT TO ITAB_COVP-LTEXT,
       XMAKTX TO ITAB_COVP-MAKTX,
       XAWTYP TO ITAB_COVP-AWTYP,
       XTWAER TO ITAB_COVP-TWAER,
       XSGTXT TO ITAB_COVP-SGTXT,
       BSEG_KOSTL TO ITAB_COVP-BSEG_KOSTL,
       BSEG_MEINS TO ITAB_COVP-BSEG_MEINS,
       BSEG_MENGE TO ITAB_COVP-BSEG_MENGE,
       MSEG_KOSTL TO ITAB_COVP-MSEG_KOSTL,
       MSEG_MENGE TO ITAB_COVP-MSEG_MENGE,
       MSEG_MEINS TO ITAB_COVP-MSEG_MEINS.


APPEND ITAB_COVP.
CLEAR ITAB_COVP.
ENDSELECT.
ENDSELECT.

OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC NE 0.
   WRITE: 'File cannot be opened. Reason:', MSG_TEXT.
   EXIT.
ENDIF.

LOOP AT ITAB_COVP.
TRANSFER ITAB_COVP TO P_FILE.
ENDLOOP.
CLOSE DATASET P_FILE.

Add a comment
10|10000 characters needed characters exceeded

Related questions

6 Answers

  • Posted on Dec 01, 2005 at 05:20 AM

    Basically you are retrieving too many records into your internal table and running out of space. See if you can split them into more smaller but several internal tables. See if you can further restrict the number of records selected, if they are not really required to be selected.

    Srinivas

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 01, 2005 at 02:35 PM

    Cecilia - I think your problemn is a nested select:

    *GET LTEST
      SELECT ltext INTO xltext
      FROM csku
      WHERE ktopl = 'COAA' AND spras = 'EN'.
    
    *GET MAKTX
        IF xmatnr <> ' '.
          SELECT SINGLE * FROM makt WHERE matnr = xmatnr.
          MOVE makt-maktx TO xmaktx.
        ELSE.
          MOVE ' ' TO xmaktx.
        ENDIF.
    
        MOVE : xkokrs TO itab_covp-kokrs,
                     etc.
              mseg_meins TO itab_covp-mseg_meins.
    
    
        APPEND itab_covp.
        CLEAR itab_covp.
      ENDSELECT.
    

    Do you need to do the inner select for every cost element text?

    Rob

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 01, 2005 at 02:50 PM

    I think there is some problem with this part. In the end you are moving BSEG-KOSTL to BSEG-KOSTL...whats the significance ? Is there any functionality of this sort rquired ?

    IF XAWTYP = 'BKPF'.

    SELECT KOSTL MENGE MEINS INTO (BSEG_KOSTL, BSEG_MENGE, BSEG_MEINS) FROM

    BSEG WHERE BELNR = XREFBN AND BUZEI = XREFBZ AND GJAHR = XREFGJ AND

    BUKRS = XREFBK.

    ENDSELECT.

    MOVE BSEG-KOSTL TO BSEG_KOSTL.

    MOVE BSEG-MEINS TO BSEG_MEINS.

    MOVE BSEG-MENGE TO BSEG_MENGE.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 01, 2005 at 03:04 PM

    I think the problem is with the select statement.

    SELECT LTEXT INTO XLTEXT

    FROM CSKU

    WHERE KTOPL = 'COAA' AND SPRAS = 'EN'.

    instead use

    SELECT single LTEXT INTO XLTEXT

    FROM CSKU

    WHERE KTOPL = 'COAA' AND SPRAS = 'EN'.

    as ur passing where condition, there might be only 1 record.

    If useful. pl. reward points.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 01, 2005 at 07:19 PM

    Hi,

    The problem seems to be related to overflow of the internal table allocation size which will be set by BASIS people. Like if the internal table size restricted to say 1024KB and if we are trying to push data more than this it will throw such error.

    So, the alternate for this is use internal tables with Packets concept.

    Let me know if this helps, so that i can give some example for this.

    Regards,

    Suman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 02, 2005 at 01:44 AM

    Hi,

    XLTEXT is declared as a single field and u r trying to select the data to single filed.there may be more than 1 record in the table CSKU with ur where condition.so more than 1 record cannot fit into a single field.

    SELECT LTEXT INTO <b>XLTEXT</b>

    FROM CSKU

    WHERE KTOPL = 'COAA' AND SPRAS = 'EN'.

    u can use select single for that

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.