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

Itab total doubt

Hi,

I ve a internal table with following records,

Item no mat qty

1 abcd 2

1 abcd 7

2 efgh 6

How to make this to

1 abcd 9

2 defg 6

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 07:51 AM

    Hi Rahul,

    Have a look at demo program DEMO_INT_TABLES_COLLECT

    Hope this helps.

    Thanks

    Lakshman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 07:58 AM

    Hi,

    Sort itab by itemno mat.

    Loop at itab.

    AT End of qty.

    SUM.

    itab1-itemno = itab-itemno.

    itab1-mat = itab-mat.

    itab1-qty = itab-qty. (qty will be automatically get summed)

    Append itab1.

    Endat.

    Endloop.

    Display itab1 , u will get the required result.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 08:03 AM

    Hi

    use COLLECT u r problem get solves..

    loop at itab into wa.

    collect wa to itab_new.

    endloop.

    loop at itab_new to wa.

    write: /

    endloop.

    plzz reward if iti si useful...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 08:06 AM

    REPORT ZTEST1231.

    data : begin of itab occurs 0 ,

    item_no(3) type i ,

    material(20) type c,

    Quantity(3) type i,

    end of itab .

    itab-item_no = '1'.

    itab-material = 'abcd'.

    itab-quantity ='2'.

    Append itab.

    itab-item_no = '1'.

    itab-material = 'abcd'.

    itab-quantity = '7'.

    Append itab.

    itab-item_no ='2'.

    itab-material = 'efgh'.

    itab-quantity = '6'.

    Append itab.

    clear itab .

    sort itab by item_no material .

    collect itab .

    loop at itab.

    write : itab-item_no , itab-material, itab-quantity .

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 08:08 AM

    Hi,

    just u use collect statement for 2nd field then the respected values will be added when it 2nd fields having same name.

    f1 f2 f3

    1 abcd 2

    1 abcd 7

    2 efgh 6

    collect itab.

    then u will get following output

    1 abcd 9

    2 defg 6

    if it is use full answer reward me a points

    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.