Application Development and Automation 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: 
Read only

Alv Grid Display

0 Likes
2,298

Hi,Experts.

Good morning.

i want to display an empty row in my alv grid display output to calculate the subtotal , grand total.

How can i display the  format according to that.

Any one can please tell, i attached sample output,please verify it.

Thanks& Regards,

Sagar.K.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,209

hi sagar,

before calling Fm- 'reuse_alv_grid_display'.

add one extra row to your final itab. final means which itab has data to print in outputlist in alv grid,

eg:

before coming to this step add your total debit and credit and keep in seperate variables.

wa_final-debit =     'v_debit'. ---->'debit amount variable'.

wa_final-credit = v_credit'.---->'credit amount variable'.

append wa_final to it_final.

and hear v_gt = v_debit + v_credit.

clear wa_final.

wa_final-fieldname = 'grand total'.  "this is just a text to print as grand total

wa_final-debit = 'v_gt'. -->grandtotal.

append wa_fianl to it_final.


now assign this it_final to function module.

HI chinna,

Thank you for you answer,

Have a good day.

7 REPLIES 7
Read only

former_member196331
Active Contributor
0 Likes
2,209

In your field catalog u can use do_sum automatically the sum will be calculated.

In which column u need sum u just use the below code..

don't use for description column , only use for amount column.

  wa_fieldcat-fieldname  = 'LOCCURAM'.

   wa_fieldcat-seltext_m  = 'Price'.

*Calculate Total for Price

    wa_fieldcat-do_sum     = 'X'.

   APPEND wa_fieldcat TO it_fieldcat.

Read only

0 Likes
2,209

hi

Actually my requirement is exactly as i kept in sample output(like i have to write TOTAL=----------------

CLOSING BALANCING = ------------  )

Read only

0 Likes
2,209

Hi ,

Sort your internal table on party code

Loop your internal table and and add a row with calculation of Debit/credit and add row at end of party code

<work_area>-<Party code> = ''.

<work_area>-<old party code > = ''.

<work_area>-<Party name> = 'Total:'.

<work_area>-<Debit> = Calculation of Debit.

<work_area>-<Creadit>= Calculation of Creadit.

<work_area>-<Party code> = ''.

<work_area>-<old party code > = ''.

<work_area>-<Party name> = 'clsong Balance:'.

<work_area>-<Debit> = Calculation of Debit.

<work_area>-<Creadit>= Calculation of Creadit.

Append thisto Internal Table

OR share your code .

Thanks

Mahipalsinh

Read only

Former Member
0 Likes
2,210

hi sagar,

before calling Fm- 'reuse_alv_grid_display'.

add one extra row to your final itab. final means which itab has data to print in outputlist in alv grid,

eg:

before coming to this step add your total debit and credit and keep in seperate variables.

wa_final-debit =     'v_debit'. ---->'debit amount variable'.

wa_final-credit = v_credit'.---->'credit amount variable'.

append wa_final to it_final.

and hear v_gt = v_debit + v_credit.

clear wa_final.

wa_final-fieldname = 'grand total'.  "this is just a text to print as grand total

wa_final-debit = 'v_gt'. -->grandtotal.

append wa_fianl to it_final.


now assign this it_final to function module.

Read only

0 Likes
2,209

HI chinna,

Thank you for you answer,

Have a good day.

Read only

former_member669309
Discoverer
0 Likes
2,209

hi,

sagar kotyada try this one.

CalculateTotal and Closing balancing in program level and append into final internal table using control break statement.

Read only

rosenberg_eitan
Active Contributor
0 Likes
2,209

Hi,

IMHO there is a flow in the design.

How the output will look if we have multiple party code ?

What will happen if the user sort the ALV ?

Using CL_GUI_ALV_GRID and CL_GUI_ALV_GRID->GET_SUBTOTALS

like here Modify grand total in ALV GRID | SCN

or here OO ALV modifed subtotals changes on layout change | SCN

Is IMHO better.

Regards .