Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

alv report

Former Member
0 Kudos

Hi all,

LOOP AT itab.

append itab to i_alv.

ENDLOOP.

I am displaying alv report with subtotals based on the currency.

My question is based on the new account (saknr) how to do the subtotals.

Ex:1001 USD 10 10

1001 USD 10 20

-


20 30

1002 USD 10 30

-


USD 30 60

I need out put like this.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi ,

You can try like this...considering your final table be it_final.


  LOOP AT it_final INTO wa_final.
    count = count + 1.
    value1 = value1 + wa_final-value.
    ntgew1 = ntgew1 + wa_final-ntgew.
    diff =  diff + wa_final-diff.
    IF count = 1.
      wa_final-bztxt = wa_final-bztxt.
    ELSE.
      wa_final-bztxt = ' '.
    ENDIF.
    
    wa_final1-value = wa_final-value.
    wa_final1-ntgew = wa_final-ntgew.
    wa_final1-diff  = wa_final-diff.
   
    APPEND wa_final1 TO it_final1.
    AT END OF bztxt.
      CLEAR count.
      wa_final1-bztxt = wa_final-bztxt.
       wa_final1-value = value.
      wa_final1-ntgew = ntgew.
      wa_final1-diff = diff.

   *here the fields that you don't want to show you can use the field name = " ". *
   
      APPEND wa_final1 TO it_final1.
      CLEAR : value , ntgew ,  diff .
      
    ENDAT.
  ENDLOOP.

5 REPLIES 5

Former Member
0 Kudos

Are you using Object Oriented ALV approach.

Former Member
0 Kudos

no i am using normal alv

former_member188685
Active Contributor
0 Kudos

populate the sort table based on SAKNR.

sort-fieldname = 'SAKNR'.

sort-up = 'X'.

sort-subtot = 'X'.

append sort to it_sort.

pass this it_sort to it_sort of the ALV function/method

0 Kudos

Hi vijay,

thanks for the answer.As per your answer this will give subtotal on every saknr,

I don't want like that .I want when ever more than 1 saknr will come on that time i want subtotal.

Former Member
0 Kudos

Hi ,

You can try like this...considering your final table be it_final.


  LOOP AT it_final INTO wa_final.
    count = count + 1.
    value1 = value1 + wa_final-value.
    ntgew1 = ntgew1 + wa_final-ntgew.
    diff =  diff + wa_final-diff.
    IF count = 1.
      wa_final-bztxt = wa_final-bztxt.
    ELSE.
      wa_final-bztxt = ' '.
    ENDIF.
    
    wa_final1-value = wa_final-value.
    wa_final1-ntgew = wa_final-ntgew.
    wa_final1-diff  = wa_final-diff.
   
    APPEND wa_final1 TO it_final1.
    AT END OF bztxt.
      CLEAR count.
      wa_final1-bztxt = wa_final-bztxt.
       wa_final1-value = value.
      wa_final1-ntgew = ntgew.
      wa_final1-diff = diff.

   *here the fields that you don't want to show you can use the field name = " ". *
   
      APPEND wa_final1 TO it_final1.
      CLEAR : value , ntgew ,  diff .
      
    ENDAT.
  ENDLOOP.