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

AT END OF matnr.

Hello-

In loop - endloop I have AT END OF matnr. But it is not working. For all material it is going inside AT ENDAT. It shoulg go inside only for unique matrial. But it is not working like that.

LOOP AT temp_hu_detl.

v_sum = v_sum + temp_hu_detl-qty.

AT END OF matnr.

temp_hu_detl_2 = temp_hu_detl.

temp_hu_detl_2-qty = v_sum.

append temp_hu_detl_2.

CLEAR : v_sum, temp_hu_detl_2.

ENDAT.

ENDLOOP.

Should I have material as first field in the table.

Thanks.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 26, 2006 at 05:30 PM

    Yes - matnr must be the first field.

    According to the help for AT END OF:

    The control level structure with internal tables is static. It corresponds exactly to the sequence of columns in the internal table (from left to right). In this context, the criteria according to which you sort the internal table are unimportant.

    Rob

    Message was edited by: Rob Burbank

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi AP,

      <b>No, its not FINE without SORT </b>

      For all control commands (AT..ENDAT), you need the <b>internal table must be sorted.</b>

      In your case take another internal table and copy the conetent of orignital internal table before going to perform SORT statement.

      ITAB is your originial internal table

      DATA ITAB1 LIKE ITAB OCCURS 0 WITH HEADER LINE.

      ITAB1[] = ITAB[].

      SORT ITAB1 BY MATNR.

      LOOP AT ITAB1.

      AT END OF MATNR.

      ENDAT.

      ENDLOOP.

      When you want to display content, use Orignital internal table ITAB.

      Thanks,

      Vinay

  • Posted on Oct 26, 2006 at 05:24 PM

    AP, make sure that the internal table is sorted by MATNR.

    sort temp_gu_detl ascending by matnr.

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 26, 2006 at 05:20 PM

    First sort the records based on the Matnr first. Also in the internal table temp_hu_detl, make the matnr as first field.

    One more thing is when u r using the AT END all the fields after matnr will become *******....so first pass the header values to some work area before using the AT END statement.

    LOOP AT temp_hu_detl.

    temp_hu_detl_2 = temp_hu_detl.

    v_sum = v_sum + temp_hu_detl-qty.

    AT END OF matnr.

    temp_hu_detl_2-qty = v_sum.

    append temp_hu_detl_2.

    CLEAR : v_sum, temp_hu_detl_2.

    ENDAT.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.