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

Loop .....AT NEW matnr or werks or kunnr.........endloop.

Hi All,

I need some logic to loop at an internal table and be able to separate code when ever there is a change in either material or plant or customer.

something like this.

  LOOP AT i_mseg.
    AT NEW ( matnr or werks or kunnr ).
       Perform do_new_code.
    ENDAT.
       Perform do_old_code.
  ENDLOOP.

Let me know how to deal with this kinda issue.

Thanks in advance,

Jr.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 03, 2006 at 07:38 PM

    Look at the help for the AT NEW command. You'll find the SAP concept of the default key. It means that if you have an internal table like:

    data: begin of itab occurs 0,
            matnr like ...
            werks like ...
            kunnr like ...
          end   of itab.

    All you have to do is say:

    loop at itab.
      at new KUNNR.
        perform do_new_code.
      endat.
    endloop.

    You'll get do_new_code performed for a break of any of the three fields.

    Rob

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 03, 2006 at 07:32 PM

    hi

    you cannot use OR addition with AT NEW instead you can use OR addition in ON CHANGE OF statement.

    eg.

    ON CHANGE OF i_mseg-matnr OR i_mseg-werks OR i_mseg-KUNNR.

    ENDON.

    <b>Keep in mind that ON CHANGE OF is outdated...</b>

    May i know wat do you wanna achieve actually???

    Cheers,

    Abdul Hakim

    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.