Skip to Content
author's profile photo Former Member
Former Member

AT NEW f, AT END OF f in an inernal table Loop ?

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.

Add comment
10|10000 characters needed characters exceeded

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 05:34 PM

    hi,

    did u sort the table???if yes...

    did u sort it with kunag??

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 03, 2006 at 05: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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 05: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?

    Add comment
    10|10000 characters needed characters exceeded