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

Code correction

Former Member
0 Likes
685

Dear All

The following code has Execute but qty,values didnot come

i cheched internal tabel month_total values are stored

why didnot come qty and values

how to come qty and values

my code

loop at month_total.

AT NEW monthcode.

month_total-tmpqty = month_total-tmpqty + month_total-qty.

month_total-tmpval = month_total-tmpval + month_total-val.

write : / month_total-monthcode, month_total-tmpqty, month_total-val.

endat.

endloop.

Thanks and Regards

Suresh

6 REPLIES 6
Read only

naimesh_patel
Active Contributor
0 Likes
660

When you use the AT NEW for perticular field the right fields from that fields becomes * asentrik inside the AT NEW.

So, Do like this:

loop at month_total.
AT NEW monthcode.
  flag = 'X'.
endat.
if flag = 'X'.
  clear flag.
month_total-tmpqty = month_total-tmpqty + month_total-qty.
month_total-tmpval = month_total-tmpval + month_total-val.

write : / month_total-monthcode, month_total-tmpqty, month_total-val.
endif.
endloop.

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
660

Suresh,

AT NEW is a control break structure.

You MUST have the internal table sorted by the "control break field" - in your case - monthcode.

Read only

Former Member
0 Likes
660

Because when ever you enter in side AT NEW stmt.. you'll be out of LOOP...means all table values will be nullified...

you can check this in debugging...

Thanks

Read only

Former Member
0 Likes
660

if you have one record per monthcode you don need the AT NEW STATMENT

if you not try somthing like that

AT NEW monthcode

sum.

month_total-tmpqty = month_total-tmpqty + month_total-qty.

month_total-tmpval = month_total-tmpval + month_total-val.

write : / month_total-monthcode, month_total-tmpqty, month_total-val.

endat.

To get the total of all monthcode records

Message was edited by:

GEORGE TRENTSIOS

Read only

Former Member
0 Likes
660

HI,

<b>SORT month_total BY monthcode.</b>

loop at month_total.

AT NEW monthcode.

month_total-tmpqty = month_total-tmpqty + month_total-qty.

month_total-tmpval = month_total-tmpval + month_total-val.

write : / month_total-monthcode, month_total-tmpqty, month_total-val.

endat.

endloop.

rgs

Read only

Former Member
0 Likes
660

Hi Suresh,

Modify Internal Table after doing Calculations.

Reward if it helps,

Satish