Skip to Content
avatar image
Former Member

Runtime error :COMPUTE_BCD_OVERFLOW

Hi,

I am getting the run time error as "Overflow for arithmetical operation (type P) in program".

Here is the part of my code.

Types:  begin of ty_nriv,

         OBJECT    type NROBJ,

         SUBOBJECT type NRSOBJ,

         NRRANGENR   type NRNR,

         TOYEAR     type NRYEAR,

         minnumber   type NRFROM,

         maxnumber   type NRto,

         CurrentNumber type NRLEVEL,

         No_range type NRTO,

         useage   type P decimals 6, 

         M_dooms  type P decimals 4,

       end of ty_nriv.


data:g_object type nriv-object,
       tab_nriv type standard table of TY_nriv ,
       WA_NRIV TYPE TY_NRIV,
      GV_YEAR(4) TYPE N,.

*selection screen

select-options:  s_object for g_object .

*start-of-slection.

select  OBJECT

           SUBOBJECT

           NRRANGENR

           TOYEAR

           FROMNUMBER

           tonumber

           NRLEVEL

           from nriv

           into table tab_nriv

          where object in s_object

             and TOYEAR < GV_YEAR.
 

  loop at tab_nriv into wa_nriv.
 

    WA_NRIV-No_range = WA_NRIV-maxnumber - WA_NRIV-minnumber + 1 .
 

    wa_nriv-useage = ( ( wa_nriv-currentnumber - wa_nriv-minnumber + 1 ) / WA_NRIV-No_range ) * 100 .

 
    wa_nriv-M_dooms = 50 / ( ( ( wa_nriv-currentnumber - wa_nriv-minnumber + 1 ) / ( wa_nriv-No_range + 1 ) )

      / ( 1 - ( wa_nriv-currentnumber - WA_NRIV-minnumber + 1 ) / ( WA_NRIV-No_range + 1 ) ) ).

 
      modify tab_nriv from wa_nriv transporting  No_range useage M_dooms.

 
  endloop.

Please help me out in this issue.

Thanks,

*P.S- I have tried with increase the length of packed type of decimals 10 and with data element KTMNG.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Oct 08, 2008 at 06:05 AM

    Hi Swetha,

    I guess the following calculation causes division by zero ( which is infinity ) somewhere, so you are getting this dump

    wa_nriv-M_dooms = 50 / ( ( ( wa_nriv-currentnumber - wa_nriv-minnumber + 1 ) / ( wa_nriv-No_range + 1 ) )
     
          / ( 1 - ( wa_nriv-currentnumber - WA_NRIV-minnumber + 1 ) / ( WA_NRIV-No_range + 1 ) ) ).
    
    

    You can give that calculation inside try catch to avoid the dump and capture the error.. like

    TRY.
    wa_nriv-M_dooms = 50 / ( ( ( wa_nriv-currentnumber - wa_nriv-minnumber + 1 ) / ( wa_nriv-No_range + 1 ) )
     
          / ( 1 - ( wa_nriv-currentnumber - WA_NRIV-minnumber + 1 ) / ( WA_NRIV-No_range + 1 ) ) ).
    CATCH CX_ROOT.
      Message 'Error'.
    ENDTRY.
    

    Cheers,

    Kothand

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Swetha,

      Use Below Code

      Types: begin of ty_nriv,

      OBJECT type NROBJ,

      SUBOBJECT type NRSOBJ,

      NRRANGENR type NRNR,

      TOYEAR type NRYEAR,

      minnumber type NRFROM,

      maxnumber type NRto,

      CurrentNumber type NRLEVEL,

      No_range type NRTO,

      useage type P decimals 6,

      M_dooms type P decimals 4,

      end of ty_nriv.

      data:g_object type nriv-object,

      tab_nriv type standard table of TY_nriv ,

      WA_NRIV TYPE TY_NRIV,

      GV_YEAR(4) TYPE N .

      data:c type P decimals 6,

      d type P decimals 6.

      *selection screen

      select-options: s_object for g_object .

      *start-of-slection.

      select OBJECT

      SUBOBJECT

      NRRANGENR

      TOYEAR

      FROMNUMBER

      tonumber

      NRLEVEL

      from nriv

      into table tab_nriv

      where object in s_object

      and TOYEAR < sy-datum+(4).

      loop at tab_nriv into wa_nriv.

      WA_NRIV-No_range = WA_NRIV-maxnumber - WA_NRIV-minnumber + 1 .

      if wa_nriv-no_range is not initial.

      wa_nriv-useage = ( ( wa_nriv-currentnumber - wa_nriv-minnumber + 1 ) /

      WA_NRIV-No_range ) * 100 .

      endif.

      if wa_nriv-No_range <> -1.

      c = ( ( wa_nriv-currentnumber - wa_nriv-minnumber + 1 ) / (

      wa_nriv-No_range + 1 ) ).

      endif.

      if c <> 1.

      d = ( c / ( 1 - c ) ).

      endif.

      if d is not initial.

      wa_nriv-M_dooms = 50 / d.

      endif.

      modify tab_nriv from wa_nriv transporting No_range useage M_dooms.

      endloop.

      Regards

      jana