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

Add internal table lines

Hi,

I have this situation:

itab1: bukrs hkont kosar gjahr monat actual plan

........ bukrs hkont kosar gjahr 01 actual plan

........ bukrs hkont kosar gjahr 02 actual plan

........ bukrs hkont kosar gjahr 03 actual plan

itab2: bukrs kosar mactual mplan ytdactual ytdplan

Say monat = 3, I need to get mactual, mplan, ytdactual, ytdplan from itab1.

mactual, mplan would be the record where monat = 03.

ytdactual, ytdplan would be the sum of mactual, mplan for monat 01 to 03.

How do i do this? Sample code will be really helpful.

Thanks.

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 Jan 17, 2008 at 08:33 AM

    Hi MJay,

    If I got it right this time, u have a parameter and give the month there...

    hope this is what u need..

    PARAMETER monat(2) type c.

    data: tmp like itab1-plan,

    tmp2 like itab1-actual.

    loop at itab1 INTO wa_itab1.

    tmp = tmp + wa_itab1-actual.

    tmp2 = tmp2 + wa_itab1-plan.

    if wa_itab1-monat = monat.

    wa_itab2-bukrs = wa_itab1-bukrs.

    wa_itab2-mactual = wa_itab1-actual.

    wa_itab2-mplan = wa_itab1-plan.

    wa_itab2-ytdactual = tmp.

    wa_itab2-ytdplan = tmp2.

    COLLECT wa_itab2 into itab2.

    endif.

    CHECK wa_itab1-monat = monat.

    endloop.

    reward if helpful...

    Regards,

    Alin

    Add a comment
    10|10000 characters needed characters exceeded

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

    Hi, if i get u right this is what u want:

    DATA: wa_itab1 like LINE OF itab1,

    wa_itab2 like LINE OF itab2,

    tmp like itab1-plan,

    tmp2 like itab1-actual.

    loop at itab1 INTO wa_itab1.

    wa_itab2-bukrs = wa_itab1-bukrs.

    .

    .

    .

    wa_itab2-mactual = wa_itab1-actual.

    wa_itab2-mplan = wa_itab1-plan.

    tmp = tmp + wa_itab2-mactual.

    wa_itab2-ytdactual = tmp.

    tmp2 = tmp2 + wa_itab2-mplan.

    wa_itab2-ytdplan = tmp2.

    COLLECT wa_itab2 into itab2.

    endloop.

    Reward if helpful.

    Regards,

    Alin.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Alin,

      I think I should have been a little more clearer.

      The monat field can have values from 01 to 12 and hence 12 records in the internal table.

      When my monat selection is say monat = '06', I need to get the mactual mplan for monat = 06

      and then sum up all the mactual mplan from 01 to 06.

      Thanks,

      MJ

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.