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

how to use count inside the loop

lifnr-matnr-menge-idnrk-excess

r11-subfert-100-subscrap-25

r11-subfert-100-scrap-20

r11-neera1-125-scrap2-15

(please dont tell delete adjacent duplicates).In my case that is not needed.Because I need this in final stage.output i have shown is partial one.

i need to clear second row 100.because matnr is same.instead of 100 i need to insert zero.

i am declaring variable in my IT.

for example v_matnr type mseg-matnr.

count type i value 1.

loop at it_final.

if sy-index = 1.

v_matnr = it_final-matnr.

move it_final-menge to it_final-menge.

endif.

i am getting logic.i couldnt able to do.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 09:57 AM

    Hi,

    1.

    data: count type i.

    loop at it_final.

    add 1 to count.

    if sy-index = 1.

    v_matnr = it_final-matnr.

    move it_final-menge to it_final-menge.

    endif.

    if count eq 100.

    .....

    clear count.

    endif.

    endloop.

    or 2. Define an new field in your internal table from type i and worte it if you fill the internal table

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 09:57 AM

    you can move data to another internal table like

    it_final2[] = it_final[]

    and delete dupilicates from it_final. and finally you can use it_final2.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 09:58 AM

    Take two variables for lifnr and matnr. Inside the loop pass the first record Lifnr and matnr to those variables. for the second record in the loop check the itab values with the variable values for both lfinr and matnr, if both are same then make the menge zero.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 10:10 AM

    Hi,

    in your internal table have an extra field called

    mark type c.

    sort itab by lifnr matnr.

    field-symbols : <fS_itab> like itab.

    loop at itab assigning <fs_tab>.

    at new matnr.

    <fs_tab>-mark = 'X'.

    endat.

    endloop.

    Now the the records where mark is 'X' will tell u the unique material number.

    Now

    loop at itab.

    if itab-mark ne 'X'.

    you can make the material number as zeros or what ever you want you cando .

    endif.

    endloop.

    Please come back to us for more queries.

    Regards,

    Venkatesh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 10:17 AM

    Dear Bathrinath,

    do like this

    t_final1[] = t_final[].

    data: count type i,

    count1 type i.

    count = 1.

    loop at t_final into w_final.

    count1 = count + sy-tabix.

    read table t_final1 into w_final1 index count1.

    if w_final-lifnr = w_final1-lifnr and

    w_final-matnr = w_final1-matnr and

    w_final-menge = w_final1-menge.

    w_final-menge = 0.

    endif.

    modify t_final from w_final.

    clear: count1,w_final,w_final1.

    endloop.

    hope your problem will be solved.

    regards

    vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 26, 2009 at 10:21 AM

    Hi,

    Try below logic.

    DATA : it_final TYPE TABLE OF ty_final,
                    wa_final TYPE ty_final,
                    wa_final1 TYPE ty_final,
                    w_indx TYPE i,
                    w_tybix TYPE i.
    
        w_indx = 1.
        LOOP AT it_final INTO wa_final.
        w_indx = w_indx + 1.
        w_tabix = sy-tabix.
        IF wa_final-matnr = wa_final1-matnr.
        wa_final-menge = '0'.
        MODIFY it_final INDEX w_tabix FROM wa_final TRANSPORTING menge.
        ENDIF.
        CLEAR wa_final1.
        READ TABLE it_final INDEX w_indx INTO wa_final1.        " Reads next record of the table.
        ENDLOOP.

    Regards

    Bala Krishna

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 12:13 PM

    Thread closed

    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.