Skip to Content
0
Former Member
Aug 08, 2007 at 11:40 AM

Adding Amount in SAPSCRIPTS

15 Views

Hi Frens

I have a requirement , where i am printing the amount in a script called from a standard SAP program.

My requirement is to sum these amounts and print it in the footer. I am using a subroutine in a Z program to do the needful.

The code in script is :

/: PERFORM CALC_TOTAL IN PROGRAM ZAHFR_F150_DUNN01

/: USING &MHND-DMSHB&

/: ENDPERFORM

In the Z program i have defined a variable gv_amount

DATA: gv_amount TYPE mhnd-dmshb.

FORM calc_total TABLES in_tab STRUCTURE itcsy

out_tab STRUCTURE itcsy. "#EC CALLED

DATA: lv_amount TYPE mhnd-dmshb.

*-- Retrieve data for Current Item Amount

READ TABLE in_tab WITH KEY name = 'MHND-DMSHB' .

IF sy-subrc = 0 .

  • lv_amount = in_tab-value.

SHIFT in_tab-value LEFT DELETING LEADING space.

MOVE in_tab-value TO lv_amount.

gv_amount = gv_amount + lv_amount .

ENDIF.

ENDFORM. " CALC_TOT

The above code gives a dump as it is not able to interpret the value in in_tab-value

as a number.

Could you please suggest a way how to pass the amount field to the called subroutine and then sum it there.

Any pointers on the same would be of great help.

Thanks

Pankaj