08-03-2006 6:28 PM
I am trying to subtotal an amount in an internal table by KUNAG. I then want to write this out to the output file. (see code below)
When I run this in debug the AT NEW and the AT END OF of are executed for every loop pass even though the KUNAG value appears to be the same .
Any ideas?
J
LOOP AT it_report2.
AT new kunag.
l_netwr = 0.
ENDAT.
l_netwr = l_netwr + it_report2-netwr.
l_line = it_report2.
TRANSFER l_line TO p_ufile.
AT END OF kunag.
it_report4-netwr = l_netwr.
l_line = it_report4.
TRANSFER l_line TO p_ufile.
ENDAT.
ENDLOOP.
08-03-2006 6:31 PM
Makes sure that the table is sorting by the KUNAG. You can clear l_netwr at the end of the KUNAG, no need to do it at NEW.
<b>sort it_report2 ascending by kunag.</b>
LOOP AT it_report2.
l_netwr = l_netwr + it_report2-netwr.
l_line = it_report2.
TRANSFER l_line TO p_ufile.
AT END OF kunag.
it_report4-netwr = l_netwr.
l_line = it_report4.
TRANSFER l_line TO p_ufile.
l_netwr = 0.
ENDAT.
ENDLOOP.
Regards
Rich Heilman
08-03-2006 6:34 PM
08-03-2006 6:36 PM
Sorry, I should have included that information.
I do have the table sorted by KUNAG.
J
08-03-2006 6:38 PM
08-03-2006 6:39 PM
What Exactly is ur table structure. can u tell me this?
And one more thing are u using any where condition in Loop statement?
08-03-2006 6:41 PM
I have solved the problem. I did not realize I needed KUNAG as the left most field.
thanks J