cancel
Showing results for 
Search instead for 
Did you mean: 

sap script totals.

Former Member
0 Kudos

hi.. i want to carry out the totals for quantity and amount in sales order details.

hw can i do that in my driver program..

i have all ny details data in an iinternal table..i ve looped at it and printing it using script.

tried using sum command but not working..

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi rashmi,

see this example.

loop at itab.
  at end of itab-quantity.
   read itab index sy-tabix.
   sum.
* now total is in the field itab-quantity.
endloop.

reward points if helpful.

Thanks,

Suma.

Former Member
0 Kudos

its printing only the last value.like..

for a SO number :1 there are 4 items and the quantities are;100,15,12,14..

so its printing 14, 4 times.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Rashmi,

plz call the function after <b>Sum</b> statement. There in the script use table-quantity field.

use

<b>at end of SONUMBER

endat.</b>

instead of

<b>at end of kwmeng.

endat.</b>

Former Member
0 Kudos

hi rashmi,

u can do one thing...define a variable of type UNIT and go on passing the quantity data in that variable....

code..

clear var1.

loop at ITAB.

.....

....

var1 = var1 + quantity field.

endloop.

thats all...

display var1 in script...

hope this will work...pls reward pts incase usefull...

Regards,

Prashant

Former Member
0 Kudos

use endat before endloop

Former Member
0 Kudos

this is what i ve done..

loop at it_details into wa_details.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'SO_DETAILS'

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

  • EXCEPTIONS

  • ELEMENT = 1

  • FUNCTION = 2

  • TYPE = 3

  • UNOPENED = 4

  • UNSTARTED = 5

  • WINDOW = 6

  • BAD_PAGEFORMAT_FOR_PRINT = 7

  • SPOOL_ERROR = 8

  • CODEPAGE = 9

  • OTHERS = 10

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*&--sum of the order quantities:

AT end of kwmeng.

read table it_details into wa_details index sy-tabix.

SUM.

write:/ wa_details-kwmeng.

endat.

endloop.

Former Member
0 Kudos

Hi Rashmi,

try this. But if we use at end of means it will print total quantity once only

loop at itab.

at end of quantity.

read table itab index sy-tabix.

sum.

write:/ itab-quantity.

endloop.

Thanks,

Suma.