cancel
Showing results for 
Search instead for 
Did you mean: 

Total in sap script.

srikant_dada
Explorer
0 Kudos

Hi All,

Please help me out for this requirement.

I have an amount field MSEG-DMBTR. I need to show the sum of this field as TOTAL.

The code used in script is:

 
/: DEFINE TOT_PRICE
/: PERFORM final_total IN PROGRAM ZFIN_TOTAL
/: USING &MSEG-DMBTR&
/: CHANGING &TOT_PRICE&
/: ENDPERFORM 

the form subroutine used is:


FORM final_total tables int_cond structure itcsy
outt_cond structure itcsy.
  data : value type dmbtr.
  statics value1 type dmbtr.

  Read table int_cond WITH KEY NAME = 'MSEG-DMBTR'. 
  SHIFT int_cond-value LEFT DELETING LEADING space.
  REPLACE ',' WITH ' ' INTO int_cond-value.
  IF SY-SUBRC = 0.
    CONDENSE int_cond-value NO-GAPS.
  ENDIF.
  value = int_cond-value.
  value1 = value1 + value.

Read outt_cond table WITH KEY name = 'TOT_PRICE' .
outt_cond-value = value1.
Modify outt_cond index SY-INDEX. 
ENDFORM.                    "final_total

i am printing &value1& in footer window...........

but i am not getting the value in print output...... I hav also tried to print &TOT_PRICE& in footer window still not getting the value....

may i know where is the problem???

what should i print in the footer window?

Edited by: Srikant Dada on May 10, 2011 7:11 AM

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

You are declaring the variable TOT_PRICE in script and you are trying to print the value in variable &VALUE1& which is declared in the perform.

You need to print the value in TOT_PRICE variable in the SAP script inorder to get the total value in print out.

Also check that in which window you have defined the TOT_PRICE variable and calling the perform. Try to declare the TOT_PRICE variable in Footer window and call the perform statement with the relevant set of values available in the footer window to calculate the total and print TOT_PRICE

Regards,

Harish.

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

Well, where should we start...

Why define VALUE1 as STATICS when you use it as a variable for calculation?

Since you declared VALUE1 in your subroutine, this will be a local field that always gets cleared when you call the routine again, so this won't work for aggregation.

Also, the call doesn't match the definition of the subroutine... you have an internal table and two structures in the definition but you're passing two fields. So it's anybody's guess what the result will be.

What populates table int_cond? I'm not really sure what your logic tries to do...

The form has no idea about &VALUE1& so no wonder nothing prints when you try to output that.

Etc... etc...

Finally, just a guess here (it has been a while when I used to do SAPscript), but shouldn't you use

/: DEFINE &TOT_PRICE&

to define your variable?

Former Member
0 Kudos

Check in DEBUG value1 has some value.I think it will be blank.

srikant_dada
Explorer
0 Kudos

i hav checked in debug........everything is fine........value1 has the desired value. but still when declaring in footer window &value1&........ it is not displaying the value.

Former Member
0 Kudos

Check there is enough space for printing , i mean the window size has to increase