Summation in SAP Script

To sum values in sap script, I did the following:

1-      Go to se38

2-      Create a program with type subroutine pool

3-      Add the following function to your program :

form calc_sum TABLES in_tab  STRUCTURE itcsy

out_tab STRUCTURE itcsy.

data: Sum_kwert LIKE komvd-kwert.

Read Data into internal table (in_tab)


CHECK sy-subrc = 0.

(your variable name) = in_tab-value. “Take the value from the internal table into a variable

 “Do your Calculation here , for example summation .

 “Pass the calculated value to the script


CHECK sy-subrc = 0.

out_tab-value = (Your Calculated Value).

MODIFY out_tab INDEX sy-tabix .

endform.                    “calc_sum

Then open your SAP Script , right click on the main window then choose edit text
Then open your SAP Script, right click on the main window then choose edit text and add the following code :

/E                         Sum_Line

/:                            DEFINE &KOMVD_KWERT& = &KOMVD-KWERT&

/:                            DEFINE &SUM_KWERT&

/:                            PERFORM CALC_SUM IN PROGRAM Z_LVSKOMMIL1_PROG

/:                            USING &KOMVD_KWERT&

/:                            CHANGING &SUM_KWERT&

/:                            ENDPERFORM


4 thoughts on “Summation in SAP Script

  1. Waldo On June 4, 2017 / 11:04 AM

    Great post. I was checking constantly this blog and I am impressed! Extremely useful information specifically the last part 🙂 I care for such info much. I was looking for this particular info for a very long time. Thank you and good luck.


    • menoshet June 6, 2017 / 9:16 AM

      Thank you so much 🙂


  2. joel September 23, 2017 / 11:55 AM

    Prachtvolle Fragen, Sie haben gerade ein Emblem gewonnen.


  3. king kong September 29, 2017 / 8:24 PM

    I’m truly enjoying the design and layout of your site. It’s a very easy on the eyes
    which makes it much more pleasant for me to come here and visit more
    often. Did you hire out a developer to create your theme?

    Outstanding work!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s