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

report using internal table events

Hi,

i have an internal table with the fields 1. profitcenter 2. company code 3. gl account 4. amount

for each profit center i need to seggregate accounts based on company code.

the report should look like the one below.

please suggest some code using internal table events at new , at end etc. as im not using alv. your help will be rewarded

regards,

ravi.

-Profitcenter -companycode glaccount -amount---

-


-pfcenter1----


-


glaccount1 -1000 ---

-


glaccount2 -2000 ---

-


4444-total--


3000---

********

-


glaccount1 -4000 ---

-


glaccount2 -1000 ---

-


3333-total--


5000---

-profitcentre1*total


8000---

******************************************************

profitcentre2.........

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 24, 2006 at 01:47 AM

    Hi.

    TYPES: BEGIN OF G_I_DATA,

    PROFIT(4) TYPE C,

    COMPANY(4) TYPE C,

    ACCOUNT(10) TYPE C,

    AMOUNT TYPE P,

    END OF G_I_DATA.

    DATA: G_IT_DATA TYPE TABLE OF G_I_DATA,

    G_WA_DATA TYPE G_I_DATA.

    DATA: G_SUM_COMPANY TYPE P,

    G_SUM_PROFIT TYPE P,

    G_AMOUNT TYPE P.

    G_WA_DATA-PROFIT = '0001'.

    G_WA_DATA-COMPANY = '1111'.

    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.

    G_WA_DATA-AMOUNT = 2000.

    APPEND G_WA_DATA TO G_IT_DATA.

    G_WA_DATA-PROFIT = '0001'.

    G_WA_DATA-COMPANY = '1111'.

    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.

    G_WA_DATA-AMOUNT = 3000.

    APPEND G_WA_DATA TO G_IT_DATA.

    G_WA_DATA-PROFIT = '0001'.

    G_WA_DATA-COMPANY = '2222'.

    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.

    G_WA_DATA-AMOUNT = 4000.

    APPEND G_WA_DATA TO G_IT_DATA.

    G_WA_DATA-PROFIT = '0001'.

    G_WA_DATA-COMPANY = '2222'.

    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.

    G_WA_DATA-AMOUNT = 5000.

    APPEND G_WA_DATA TO G_IT_DATA.

    G_WA_DATA-PROFIT = '0002'.

    G_WA_DATA-COMPANY = '1111'.

    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.

    G_WA_DATA-AMOUNT = 2000.

    APPEND G_WA_DATA TO G_IT_DATA.

    G_WA_DATA-PROFIT = '0002'.

    G_WA_DATA-COMPANY = '1111'.

    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.

    G_WA_DATA-AMOUNT = 3000.

    APPEND G_WA_DATA TO G_IT_DATA.

    G_WA_DATA-PROFIT = '0002'.

    G_WA_DATA-COMPANY = '2222'.

    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.

    G_WA_DATA-AMOUNT = 4000.

    APPEND G_WA_DATA TO G_IT_DATA.

    G_WA_DATA-PROFIT = '0002'.

    G_WA_DATA-COMPANY = '2222'.

    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.

    G_WA_DATA-AMOUNT = 5000.

    APPEND G_WA_DATA TO G_IT_DATA.

    SORT G_IT_DATA BY PROFIT COMPANY ACCOUNT.

    WRITE: /6 'ProfitCenter', 20 'CompanyCode',

    34 'Glaccount', 48 'Amount'.

    WRITE: /6 SY-ULINE(50).

    LOOP AT G_IT_DATA INTO G_WA_DATA.

    AT NEW PROFIT.

    WRITE: /6 G_WA_DATA-PROFIT.

    ENDAT.

    G_AMOUNT = G_WA_DATA-AMOUNT.

    AT NEW ACCOUNT.

    WRITE: /34 G_WA_DATA-ACCOUNT,

    48 G_AMOUNT.

    ENDAT.

    G_SUM_PROFIT = G_SUM_PROFIT + G_WA_DATA-AMOUNT.

    G_SUM_COMPANY = G_SUM_COMPANY + G_WA_DATA-AMOUNT.

    AT END OF COMPANY.

    WRITE: /20 G_WA_DATA-COMPANY,

    34 'Totle',

    48 G_SUM_COMPANY.

    CLEAR G_SUM_COMPANY.

    WRITE: /6 '*******'.

    ENDAT.

    AT END OF PROFIT.

    WRITE: /6 G_WA_DATA-PROFIT,

    20 'Totle',

    48 G_SUM_PROFIT.

    CLEAR G_SUM_PROFIT.

    WRITE: /6 '*************************************'.

    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.