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: 

how to use SUMMING in scripts?

Former Member
0 Kudos

hi folks,

i need to add 2 fields in the sap script..how do i do it? there is a command "summing", but does anyone know its syntax ?

Thanks,

aditi

6 REPLIES 6

former_member188685
Active Contributor
0 Kudos

hi,

SUMMING: Adding program symbols

Program symbols can be added with the SUMMING command. The command only needs to be defined once. Each time that the specified symbol is edited, its current value is added to the sum field. Several program symbols can also be added in a sum field.

Syntax:

/:SUMMING program symbol INTO sum symbol

As SAP script cannot define sum fields dynamically, the sum symbol must be in a structure of the calling program, which was declared with TABLES.

regards

vijay

vinod_gunaware2
Active Contributor
0 Kudos

The SUMMING command is used for accumulating a total value for a program symbol. The command should be specified just once. Then, each time the specified program symbol is formatted, its current value is added into the total symbol. Several program symbols may all be added into a single total symbol.

Syntax:

<b>/: SUMMING program_symbol INTO total_symbol</b>

SAPscript cannot create the field for the total dynamically. The symbol used must be defined in a TABLES structure in the calling program.

regards

vinod

Former Member

Hi aditi,

You can use SUMMING command to perform summing operation of fields in SAPScript.The syntax has already been given by Vijay...

You can use PERFORM statement to perform summing operation.

syntax:

/: PERFORM function_name in program_name

/: using &income&

/: changing &sum&

/: endperform.

In the program "program_name", call the function

form function_name TABLES in_var type ITCSY outvar type ITCSY.

endform.

**in_var contains fields NAME & VALUE.in_var contains variable sent in the using addition of the earlier PERFORM Statement(in this case, it will be income)

out_var contains the summed values and this value will be sent back to SAPScript(in this case it will be sum).

I will give an example..

form add_income tables in_tab structure itcsy out_tab structure itcsy.

global = global + in_tab-value.

loop at out_tab.

out_tab-value = global.

modify out_tab index sy-tabix.

endloop.

endform.

Hope you got the needed stuff from this.

Regards,

Sylendra.

0 Kudos

Hi Prasad,

What is the type of this Global field.

Krishna

0 Kudos

global is the variable and you declare as integer .

0 Kudos

Dear Prasad,

Thank you very much. i also getting solution by your post. but sorry i have no chance to give point for you

any how thanks again.