2007 Sep 27 2:39 PM
Hello All,
I have 2 variables ®UP-WRBTR& and ®UP-SKNTO& passed to sap script from print program. I want to calculate thier difference in the script and display the value. I am using.
/: DEFINE &NET_AMOUNT& = ®UP-WRBTR& - ®UP-SKNTO&
This is not working. Could anyone please suggest how to solve this?
Regards
Indrajit
Hi indrajit.
You cannot perform any arithmetic operations in Layout set text elements.
But we can acheive this using the PERFORM command.
Eg:
In the window :
/: DEFINE &NET_AMOUNT& = '0'
/: PERFORM F_CALC_DIFF IN PROGRAM ZREP01
/: USING ®UP-WRBTR&
/: USING ®UP-SKNTO&
/: CHANGING &NET_AMOUNT&
/: ENDPERFORM
Net amount = &NET_AMOUNT&
In the program ZREP01 define the Subroutine:
FORM F_CALC_DIFF TABLES INTAB STRUCTURE ITCSY
OUTTAB STRUCTURE ITCSY.
DATA : V1 TYPE REGUP-WRBTR,
V2 TYPE REGUP-WRBTR,
V3 TYPE REGUP-WRBTR.
READ TABLE INTAB INDEX 1.
V1 = INTAB-VALUE.
READ TABLE INTAB INDEX 2.
V2 = INTAB-VALUE.
V3 = V1 - V2.
WRITE V3 TO OUTTAB-VALUE LEFT-JUSTIFIED.
MODIFY OUTTAB INDEX 1.
ENDFORM.
This will give you the solution.
<b>Reward if Helpful.</b>
2007 Sep 27 2:43 PM
Hi Indrajit,
try it
/: DEFINE &NET_AMOUNT&
&NET_AMOUNT& = ®UP-WRBTR& - ®UP-SKNTO&
Regards,
Allan Cristian
2007 Sep 27 2:45 PM
You only have limited commands in SAPscript, and they do not include arithmatic.
You either have to perform the subtraction in your print program, or call a subroutine from your SAPscript.
Regards,
Nick
2007 Sep 27 2:56 PM
Hi indrajit.
You cannot perform any arithmetic operations in Layout set text elements.
But we can acheive this using the PERFORM command.
Eg:
In the window :
/: DEFINE &NET_AMOUNT& = '0'
/: PERFORM F_CALC_DIFF IN PROGRAM ZREP01
/: USING ®UP-WRBTR&
/: USING ®UP-SKNTO&
/: CHANGING &NET_AMOUNT&
/: ENDPERFORM
Net amount = &NET_AMOUNT&
In the program ZREP01 define the Subroutine:
FORM F_CALC_DIFF TABLES INTAB STRUCTURE ITCSY
OUTTAB STRUCTURE ITCSY.
DATA : V1 TYPE REGUP-WRBTR,
V2 TYPE REGUP-WRBTR,
V3 TYPE REGUP-WRBTR.
READ TABLE INTAB INDEX 1.
V1 = INTAB-VALUE.
READ TABLE INTAB INDEX 2.
V2 = INTAB-VALUE.
V3 = V1 - V2.
WRITE V3 TO OUTTAB-VALUE LEFT-JUSTIFIED.
MODIFY OUTTAB INDEX 1.
ENDFORM.
This will give you the solution.
<b>Reward if Helpful.</b>
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |