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

control breaks(logic required)

Hi all again,

Iam using th e following code.

LOOP AT i_liste_3 INTO wa_liste_3.
    IF sy-tabix = '1'.
      h_ausch = wa_liste_3-menge * ( wa_liste_3-aufak / 100 ).
      wa_liste_3-ausch = ( h_ausch + wa_liste_3-menge ).

    ELSE.
      h_ausch = h_ausch1 * ( wa_liste_3-aufak / 100 ).
      wa_liste_3-ausch = ( h_ausch + h_ausch1 ).

    ENDIF.
    MODIFY i_liste_3 FROM wa_liste_3.
    h_ausch1 = wa_liste_3-ausch.
    CLEAR h_ausch.
    ON CHANGE OF wa_liste_3-matnr.
    move '1' to sy-tabix.
    ENDON.
  ENDLOOP.

.

this code is working fine for one material.

my requirement is on change of matnr i want to set sy-tabix to 1(but its not working).I tried with using variables no luck.

i have the internal table .

vornr matnr

1800 18

1300 18

1200 18

1800 19

1100 19

900 19.

so for the record 1800 18 i have to use

h_ausch = wa_liste_3-menge * ( wa_liste_3-aufak / 100 ).

wa_liste_3-ausch = ( h_ausch + wa_liste_3-menge ).

so for remainning records for matnr = 18.

1300 18

1200 18 i have to use

h_ausch = h_ausch1 * ( wa_liste_3-aufak / 100 ).

wa_liste_3-ausch = ( h_ausch + h_ausch1 ).

again on change of material 19 for the only first record

1800 19 i have to use

h_ausch = wa_liste_3-menge * ( wa_liste_3-aufak / 100 ).

wa_liste_3-ausch = ( h_ausch + wa_liste_3-menge ).

I hope it is clear.

regards

Chandu.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 07, 2005 at 04:26 PM

    Try it:

    data: v_x type i.

    LOOP AT i_liste_3 INTO wa_liste_3.

    clear v_x .

    ON CHANGE OF wa_liste_3-matnr.

    h_ausch = wa_liste_3-menge * ( wa_liste_3-aufak / 100 ).

    wa_liste_3-ausch = ( h_ausch + wa_liste_3-menge ).

    v_x = 1.

    ENDAT .

    if v_x is initial .

    h_ausch = h_ausch1 * ( wa_liste_3-aufak / 100 ).

    wa_liste_3-ausch = ( h_ausch + h_ausch1 ).

    ENDIF.

    MODIFY i_liste_3 FROM wa_liste_3.

    h_ausch1 = wa_liste_3-ausch.

    CLEAR h_ausch.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 07, 2005 at 04:27 PM

    Use the below code....

    sort i_liste_3 by matnr.

    LOOP AT i_liste_3 INTO wa_liste_3.

    at new wa_liste_3-matnr.

    move '1' to sy-tabix.

    endat.

    IF sy-tabix = '1'.

    h_ausch = wa_liste_3-menge * ( wa_liste_3-aufak / 100 ).

    wa_liste_3-ausch = ( h_ausch + wa_liste_3-menge ).

    ELSE.

    h_ausch = h_ausch1 * ( wa_liste_3-aufak / 100 ).

    wa_liste_3-ausch = ( h_ausch + h_ausch1 ).

    ENDIF.

    MODIFY i_liste_3 FROM wa_liste_3.

    h_ausch1 = wa_liste_3-ausch.

    CLEAR h_ausch.

    ENDLOOP.

    This will trigger for evry new material.

    Hope this will work for u.

    Pl. award appropriate points.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 07, 2005 at 04:28 PM

    You can use the control statement AT NEW. for what you looking for.

    the code between at new <field>...endat. will be executed only if the value of field is a new one from the previous loop pass...(This can be used to do something whenever a new value for the specified field occurs).

    Thanks & Regards,

    Renjith

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 07, 2005 at 04:33 PM

    Try this.

    LOOP AT i_liste_3 INTO wa_liste_3.
      IF sy-tabix = '1'.
    *-- For the first record only
        h_ausch = wa_liste_3-menge * ( wa_liste_3-aufak / 100 ).
        wa_liste_3-ausch = ( h_ausch + wa_liste_3-menge ).
        MODIFY i_liste_3 FROM wa_liste_3.
        h_ausch1 = wa_liste_3-ausch.
        CLEAR h_ausch.
        CONTINUE.
      ENDIF.
      h_ausch = h_ausch1 * ( wa_liste_3-aufak / 100 ).
      wa_liste_3-ausch = ( h_ausch + h_ausch1 ).
      MODIFY i_liste_3 FROM wa_liste_3.
      h_ausch1 = wa_liste_3-ausch.
      CLEAR h_ausch.
      ON CHANGE OF wa_liste_3-matnr.
        h_ausch = wa_liste_3-menge * ( wa_liste_3-aufak / 100 ).
        wa_liste_3-ausch = ( h_ausch + wa_liste_3-menge ).
        MODIFY i_liste_3 FROM wa_liste_3.
        h_ausch1 = wa_liste_3-ausch.
        CLEAR h_ausch.
        CONTINUE.
      ENDON.
    ENDLOOP.
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 07, 2005 at 04:35 PM

    Hi Sai,

    You can use a variable to solve this..

    DATA: lv_matnr LIKE mara-matnr.

    LOOP AT i_liste_3 INTO wa_liste_3.

    <b>* IF sy-tabix = '1'.

    IF lv_matnr NE wa_liste_3-matnr.

    lv_matnr = wa_liste_3-matnr.</b>

    h_ausch = wa_liste_3-menge * ( wa_liste_3-aufak

    -aufak / 100 ).

    wa_liste_3-ausch = ( h_ausch + wa_liste_3-menge

    -menge ).

    ELSE.

    h_ausch = h_ausch1 * ( wa_liste_3-aufak / 100

    / 100 ).

    wa_liste_3-ausch = ( h_ausch + h_ausch1 ).

    ENDIF.

    MODIFY i_liste_3 FROM wa_liste_3.

    h_ausch1 = wa_liste_3-ausch.

    CLEAR h_ausch.

    <b>* ON CHANGE OF wa_liste_3-matnr.

    • move '1' to sy-tabix.

    • ENDON.</b>

    ENDLOOP.

    Hope this helps..

    Sri

    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.