cancel
Showing results for 
Search instead for 
Did you mean: 

sap script totals and subtotals

Former Member
0 Kudos

im doin a script for sales order.

my question is that is i enter a range for SO..

i need the subtotals for every SO on that page and also at the last page i want the total of all the subtotals..

i ve got through for the subtotals..but getting total and subtotal simultaneously on the last page is a problem.

n till nw its page1 format..

do i ve to include page2 format or any other soution??

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

If u wantto display the grand total in the last page, u can handle that in the driver program.

AT LAST .

sum the field into var1.

Endat .

In the scripttext editor of first page of footer window,

  • &var1&

It will no way effect ur Subtotal at the end of ur page.

Revert back if any issues,

Reward with points if helpful.

Regards,

Naveen.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi rashmi,

If the above code doesn't work means, use upto subtotal part. That means after at last u can remove and do in the above loop itself.see the below one.

loop at itab.

v_qty =v_qty+ itab-qty.

call function 'WRITE_form' for element 'TABLE_ROW'.

at end of vbeln.

read table itab index sy-tabix.

sum.

call function 'WRITE_form' for element 'TABLE_SUBTOTAL'.

endloop.

in the variable v_qty u will have total value.

reward if helpful

Thanks,

Suma.

Former Member
0 Kudos

Hi Rashmi,

I missed one statement. plz use the below code.

loop at itab.
             call function 'write_form'
             exporting
                element = 'TABLE_ROW'
                function = 'SET'
                type = 'BODY'
                window = 'MAIN'
 <b>at end of vbeln</b>
 read itab index sy-tabix.
 sum.
              call function 'write_form'
                  exporting
                  element = 'TABLE_SUBTOTAL'
                   f unction = 'SET'
                  type = 'BODY'
                  window = 'MAIN'
  endat.

<b> at last.</b>
 read table itab index sy-tabix.
 sum.
        call function 'write_form'
           exporting
            element = 'TABLE_TOTAL'
            function = 'SET'
             type = 'BODY'
             window = 'MAIN'
 endat.
endloop.

Former Member
0 Kudos

Hi rashmi,

If u are able to do subtotals in script means u can find total in driver program and save it in variable . use that variable in sapscript last page. plz check suppose this code is useful.

loop at itab.

call function 'write_form'

exporting

element = <b>'TABLE_ROW'</b>

function = 'SET'

type = 'BODY'

window = 'MAIN'

read itab index sy-tabix.

sum.

call function 'write_form'

exporting

element = <b>'TABLE_SUBTOTAL'</b>

function = 'SET'

type = 'BODY'

window = 'MAIN'

endat.

<b>at last</b>.

read table itab index sy-tabix.

sum.

call function 'write_form'

exporting

element = <b>'TABLE_TOTAL'</b>

function = 'SET'

type = 'BODY'

window = 'MAIN'

endat.

endloop.

IIn sap script under 'TABLE_ROW' element write all coloumns.

under 'TABLE_SUBTOTAL' itab-qty

under 'TABLE_TOTAL' itab-qty

I am not sure. but it may work plz once test it.

reward if helpful.

Thanks,

Suma.

Former Member
0 Kudos