‎2006 May 03 1:09 AM
Dear All,
How can I do calucations in SAP Script.
Actually I have 2 text elements Total and tax. And I would like to display Sub Total which is Total - Tax.
I wonder how can I do that directely in SAP Script without Editing printprogram
Thank you for your inputs.
Regards
Venkat.
‎2006 May 03 5:40 PM
Hi...
On your SAP script write:
/: PERFORM subrutine IN PROGRAM Zprogram
/: USING &PAR1&
/: CHANGING &PAR2&
/: ENDPERFORM
PS: You can use as many USING AND CHANGING as you need.
And the zprogram goes;
FORM subrutine TABLES t_in STRUCTURE itcsy
t_out STRUCTURE itcsy.
data: par1 type n.
Read the value on PAR1
READ TABLE t_in WITH KEY 'PAR1'.
CHECK sy-subrc = 0.
PAR1 = t_IN-value.
DO WHATEVER YOU NEED TO DO
ADD 1 TO PAR1.
....
SEND THE VALUES BACK
READ TABLE t_OUT WITH KEY 'PAR2'.
t_sal-value = PAR1 .
MODIFY t_OUT INDEX sy-tabix.
ENDFORM.
‎2006 May 03 1:17 AM
You cannot do any calculation in script.
Why you want to do in the form instead of print program.
If the print program is standard and if you decided not to change that program you can call a subroutine from the
form, In that form u can do the necessary calculations.
Hope this helps..
Thanks,
Vamshi
‎2006 May 03 5:06 PM
Hi Vamshi,
Thanks for quick info. All points to you.
I will include a Subroutine.
Regards
Venkat.
‎2006 May 03 5:40 PM
Hi...
On your SAP script write:
/: PERFORM subrutine IN PROGRAM Zprogram
/: USING &PAR1&
/: CHANGING &PAR2&
/: ENDPERFORM
PS: You can use as many USING AND CHANGING as you need.
And the zprogram goes;
FORM subrutine TABLES t_in STRUCTURE itcsy
t_out STRUCTURE itcsy.
data: par1 type n.
Read the value on PAR1
READ TABLE t_in WITH KEY 'PAR1'.
CHECK sy-subrc = 0.
PAR1 = t_IN-value.
DO WHATEVER YOU NEED TO DO
ADD 1 TO PAR1.
....
SEND THE VALUES BACK
READ TABLE t_OUT WITH KEY 'PAR2'.
t_sal-value = PAR1 .
MODIFY t_OUT INDEX sy-tabix.
ENDFORM.
‎2006 May 03 9:02 PM
Dear Gabriel,
Thank you very much for your reply and code included, This is very helpful.
I guess, my problem is solved and I will allot full points to you, while closing this thread.
Regards
Venkat