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: 

Regarding SELECT statement overflow gives dump

Former Member
0 Kudos

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

4 REPLIES 4

former_member194669
Active Contributor
0 Kudos

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

uwe_schieferstein
Active Contributor
0 Kudos

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

0 Kudos

thanks for giving inputs.

this is the code after we SELECT statment.

LOOP AT t_documents. " FROM 1 TO 5000.

w_tabix = sy-tabix.

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.

IF sy-subrc EQ 0.

REFRESH t_ekbe_temp.

CLEAR t_ekbe_temp.

LOOP AT t_ekbe.

IF t_ekbe-shkzg EQ c_h.

t_ekbe-menge = t_ekbe-menge * ( -1 ).

ENDIF.

MOVE-CORRESPONDING t_ekbe TO t_ekbe_temp.

COLLECT t_ekbe_temp.

ENDLOOP.

LOOP AT t_ekbe_temp.

IF t_ekbe_temp-vgabe EQ c_1 .

MOVE t_ekbe_temp-menge TO t_documents-bamng. "IR qty

ELSE.

MOVE t_ekbe_temp-menge TO t_documents-bpmng. "GR Qty

ENDIF.

ENDLOOP.

ENDIF.

MODIFY t_documents INDEX w_tabix.

w_ctr = w_ctr + 1.

IF w_ctr GE 10000.

COMMIT WORK.

CLEAR w_ctr.

ENDIF.

It is working fine other PO numbers.it goes dump only one plant and one PO number that is menge value is too high..So if i change the code its noproblem to the other PO numbers.

please proide some inputs.

Thanks,

Arnald

0 Kudos

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