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

SUM within Loop

0 Likes
1,597

Hi experts,

I need to avoid some Fields in structure while using SUM macro's within loop.

My program terminates due to "SUM_OVERFLOW ", pl suggest me how to avoid this issue.

Thanks and Regards,

Ramachandran S

11 REPLIES 11
Read only

Former Member
0 Likes
1,286

hi,

Declare the field which you are using for SUM with large values.

Read only

Former Member
0 Likes
1,286

Length of SUMMING field should be more

Declare as such and check.

Read only

Former Member
0 Likes
1,286

Increase the length of that quantity field (or) currency field.

Regards

Read only

0 Likes
1,286

Hi chandra madapati,

First thanks for your timely reply,

The table i'm using is not changeable, so i have to use the same length and field type. While calculating SUM i need to avoid those fields with a low length and which i don't take to process.

Thanks and Regards,

Ramachandran

Edited by: Ramachandran Sivaraman on Dec 26, 2008 9:55 AM

Read only

0 Likes
1,286

Hi Ram,

Did you check the value of the sum in debuggin ??? which data element are you using?

you can also use user defined variable in the internal tables if standard table fields are falling short.

for example

data : begin of itab occurs 0.

include structure mara.

data : quan(20) type p decimals 3,

end of itab.

here you can use quan field if standard fields falling short of requirement.

First check the value in Debug mode is it going beyond the allowed length.

Regards

Ramchander Rao.K

Read only

Former Member
0 Likes
1,286

Hi,

Increase the length of the SUM field in ur declaration so that it accoumodate

how many digits ur 'SUM' field has.

Read only

Former Member
0 Likes
1,286

Fields which u want to avoid make them as char type if possible.

Else use bapicurr_d to declare numeric pack variables.

Read only

Former Member
0 Likes
1,286

Dear,

Can u paste your code here, so that you will get more ideas.

Regards,

Read only

0 Likes
1,286

Hi chandra,

The code is pasted below ,


DATA:  it_opbal_temp type table of rfposxext  with header line ,
            it_opbal_sum type table of rfposxext  with header line .


{color:green}Inside where i used sum field the error occurs due to field zbd1t which is Dec with 3 len
{color} 
clear it_opbal_sum[].

  loop at it_opbal.
    it_opbal_temp[] = it_opbal[].
    delete it_opbal_temp where konto ne it_opbal-konto.

    loop at it_opbal_temp.
     sum.
      append it_opbal_temp to it_opbal_sum.
     exit.
    endloop.
          append it_opbal_temp to it_opbal_sum.
    delete it_opbal where konto eq it_opbal-konto.
  endloop.

The rfposxext is Global structure so i cannot modify the len of the fields.

The error occurs due to overflow of zbd1t field so i need some help to avoid this field while processing.

or

If we can move the value of it_opbal_temp to another internal table which has specify fields of structure rfposxext. I tried this using move-corresponding , the values not moving to another internal table.

Regards,

Ramachandran

Read only

0 Likes
1,286

Hi

it_opbal_temp[] = it_opbal[].

--Just comment this part

loop at it_opbal.

delete it_opbal_temp where konto ne it_opbal-konto.

--

loop at it_opbal_temp.

use control break statements starts with AT like AT NEW etc

for more info Take F1 help

then use key word SUM

endloop.

Regards

Ramchander Rao.K

Read only

0 Likes
1,286

Hi,

Thanks for your reply.

I tired AT New too even then the zbd1t field overflow due to it have move values in internal table for particular konto, zbd1t contains only two digit like "15,15,30,26 " but the total length is 3. if we sum this internal table the zbd1t field alone gets overflow.

Regards,

Ramachandran