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

summation

hi experts,

i got the values in internal table.

key activ hsl csale

01 koae 786.88 800.00

01 rmwl 567.77 987.55

01 koae 100.55 800.00

01 sd00 432.55 234.66

02 koae 650.00 400.00

02 rmwl 156.44 412.88

02 koae 700.00 500.00

02 sd00 100.77 500.88

i want summation of hsl and csale where same key and same activ and i need to put in another jtab internal table.

that means jtab values nust be like this.

key activ hsl csale

01 koae 886.88 1600.00

02 koae 1350.00 900.00

for this how can i write the code can anybody help me.

answer will be rewarded.

venkat.

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 Sep 22, 2006 at 12:14 PM

    Hi,

    If key is a character field, collect itab will work.

    Just put collect itab instead of append itab and check the output.

    regards,

    senthil

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi

      Check this code,

      data : begin of itab occurs 0,

      key(2),

      activ(4),

      hsl type p decimals 2,

      csale type p decimals 2,

      end of itab.

      itab-key = '01'.

      itab-activ = 'koae'.

      itab-hsl = '786.88'.

      itab-csale = '800.00'.

      collect itab.

      itab-key = '01'.

      itab-activ = 'rmw1'.

      itab-hsl = '567.77'.

      itab-csale = '987.55'.

      collect itab.

      itab-key = '01'.

      itab-activ = 'koae'.

      itab-hsl = '100.55'.

      itab-csale = '800.00'.

      collect itab.

      • add all your values like this and check

      • itab-key = '01'.

      • itab-activ = 'koae'.

      • itab-hsl = '786.88'.

      • itab-csale = '800.00'.

      • collect itab.

      loop at itab.

      write :/ itab-key, itab-activ, itab-hsl, itab-csale.

      endloop.

      Regards,

      Senthil

  • Posted on Sep 22, 2006 at 12:14 PM

    You can use COLLECT.

    ~Suresh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2006 at 12:15 PM

    sort itab.

    loop at itab

    at end of activ.

    sum.

    move-correspoding itab to itab1.

    append itab1.

    endat.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2006 at 12:18 PM

    Hi,

    First sort the internal table depending upon the fields and then using AT NEW u can find the sum.

    sort itab by key activ.

    loop at itab.

    w_hsl = w_hsl + hsl.

    w_cscale = w_cscale + cscale

    at new activ.

    • here append the data into another table

    endat.

    endloop.

    Regards,

    Vibha

    • Reward points if it helps

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2006 at 12:35 PM

    hi,

    try this,

    sort ftab by key activ.

    loop at ftab.

    clear: m, n.

    at new active.

    m = ftab-activ.

    loop at ftab where active = m.

    n = n + 1.

    endloop.

    if n > 1.

    move ftab-... to btab-.....

    move ftab-... to btab-.....

    move ftab-... to btab-.....

    collect btab.

    endif.

    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.