Skip to Content
avatar image
Former Member

Regarding SELECT statement overflow gives dump

Its production issue,need help ASAP.

sap 4.5b additon we use.

The code is written as

SELECT ebelp

ebeln

vgabe

SUM( menge ) AS menge

shkzg

FROM ekbe

INTO TABLE t_ekbe

WHERE ebeln EQ t_documents-ebeln

AND ebelp EQ t_documents-ebelp

AND ( vgabe EQ c_1

OR vgabe EQ c_2 )

GROUP by ebelp ebeln vgabe shkzg.

The issue is : one PO number , in table EKEB menge field values are some 65 rows each one have large (means 13 digit values.) quantity.so its not SUM the select statement. it is going to dump.

how to solve overflow the select command.

i need urgent help regarding the same.

Thanks,

Arnald

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Aug 19, 2007 at 07:44 PM

    Hi,

    Declare v_menge(25) type p decimals 2.

    SELECT ebelp

    ebeln

    vgabe

    SUM( menge ) AS v_menge

    shkzg

    FROM ekbe

    INTO TABLE t_ekbe

    WHERE ebeln EQ t_documents-ebeln

    AND ebelp EQ t_documents-ebelp

    AND ( vgabe EQ c_1

    OR vgabe EQ c_2 )

    GROUP by ebelp ebeln vgabe shkzg.

    aRs

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 19, 2007 at 07:55 PM

    Hello Arnald

    I think the previous solution will not work because field MENGE (in itab t_ekbe) is still of type QUAN (13, 3 decimals).

    Perhaps the following approach may be useful.

    TYPES: BEGIN OF ty_s_collect.
    INCLUDE TYPE ekbe   AS header.
    TYPES: menge_x(25)  TYPE p decimals 2.
    TYPES: END OF ty_s_collect.
    TYPES: ty_t_collect  TYPE STANDARD TABLE OF ty_s_collect
                                         WITH DEFAULT KEY.
    
    
    DATA:
    "  ls_ekbe        TYPE ekbe,
      ls_collect      TYPE ty_s_collect,
      lt_collect        TYPE ty_t_collect.
    
    
    SELECT ebelp
    ebeln
    vgabe
    "SUM( menge ) AS menge  " not yet...
    shkzg
    FROM ekbe
    INTO TABLE t_ekbe
    WHERE ebeln EQ t_documents-ebeln
    AND ebelp EQ t_documents-ebelp
    AND ( vgabe EQ c_1
    OR vgabe EQ c_2 )
    GROUP by ebelp ebeln vgabe shkzg.
    
    SORT t_ekbe BY ebelp ebeln vgabe shkzg.
    
    LOOP AT t_ekbe INTO ls_collect-header.
      COLLECT ls_collect INTO lt_collect.  " now do summing up
    ENDLOOP.

    If the COLLECT statement runs into an overflow change it accordingly:

    LOOP AT t_ekbe INTO ls_collect-header.
      ls_collect-menge_x = ls_collect-header-menge.
      CLEAR: ls_collect-header-menge.
    
      COLLECT ls_collect INTO lt_collect.  " now do summing up
    ENDLOOP.

    Regards

    Uwe

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hello Arnald

      The following sample report <b>ZUS_SDN_COLLECT_OVERFLOW</b> shows you how to handle the possible arithmetic overflow. For details please refer to the ABAP keyword documentation for CATCH.

      *&---------------------------------------------------------------------*
      *& Report  ZUS_SDN_COLLECT_OVERFLOW
      *&
      *&---------------------------------------------------------------------*
      *&
      *&
      *&---------------------------------------------------------------------*
      
      REPORT  zus_sdn_collect_overflow.
      
      TYPE-POOLS: abap.
      
      
      TYPES: BEGIN OF ty_s_collect.
      INCLUDE TYPE ekbe   AS header.
      TYPES: menge_x     TYPE rzae_stand.  " QUAN 15, 3 decimals
      TYPES: END OF ty_s_collect.
      TYPES: ty_t_collect  TYPE STANDARD TABLE OF ty_s_collect
                                           WITH DEFAULT KEY.
      
      
      DATA:
        go_overflow    TYPE REF TO cx_sy_arithmetic_overflow,
        gt_ekbe        TYPE STANDARD TABLE OF ekbe,
        gs_ekbe        TYPE ekbe,
        gt_collect     TYPE ty_t_collect,
        gs_collect     TYPE ty_s_collect.
      
      
      START-OF-SELECTION.
      
        SELECT ebelp  ebeln  vgabe
               SUM( menge ) AS menge
               shkzg
        FROM ekbe
        INTO CORRESPONDING FIELDS OF TABLE gt_ekbe UP TO 100 ROWS
        GROUP BY ebelp ebeln vgabe shkzg.
      
        CLEAR: gs_ekbe.
        gs_ekbe-ebeln = '3000000008'.
        gs_ekbe-vgabe = '1'.
        gs_ekbe-menge = '9876543210.12'.
        MODIFY gt_ekbe FROM gs_ekbe
            TRANSPORTING vgabe menge
            WHERE ( ebeln = gs_ekbe-ebeln ).
      
        PERFORM display_list USING gt_ekbe.
      
        REFRESH: gt_collect.
        LOOP AT gt_ekbe INTO gs_collect-header.
          gs_collect-menge_x = gs_collect-menge.
      
          TRY.
              COLLECT gs_collect INTO gt_collect.
      
              " Catch the arithmetic overflow exception
            CATCH cx_sy_arithmetic_overflow INTO go_overflow.
              CLEAR: gs_collect-menge.  " caused the overflow
              COLLECT gs_collect INTO gt_collect.
          ENDTRY.
      
        ENDLOOP.
      
        PERFORM display_list USING gt_collect.
      
      END-OF-SELECTION.
      *&---------------------------------------------------------------------*
      *&      Form  DISPLAY_LIST
      *&---------------------------------------------------------------------*
      *       text
      *----------------------------------------------------------------------*
      *  -->  p1        text
      *  <--  p2        text
      *----------------------------------------------------------------------*
      FORM display_list
                     USING
                        ut_outtab  TYPE table.
      
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
          EXPORTING
            i_structure_name = 'EKBE'
          TABLES
            t_outtab         = ut_outtab
          EXCEPTIONS
            program_error    = 1
            OTHERS           = 2.
        IF sy-subrc <> 0.
      * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      
      ENDFORM.                    " DISPLAY_LIST
      

      Regards

      Uwe