‎2014 Apr 03 11:04 PM
Hello,
Someone could help me please, someones knows how to multiply two fields in sapscript, what's the sintax?
thanks for your help,
‎2014 Apr 04 4:51 AM
Hello Enrique,
You need Call Perform block for calculation purpose by making use of parameters.
example:
If you want multiply qty and price then you pass Qty and Price value and along with storage variable for the output to the program.
syntax:
v_qty for Qty
v_price for price
v_temp for storage the output
ztest is the calling program where you will your logic
PERFORM GET_PRODUCT IN PROGRAM ZTEST using &v_qty& using &price& changing &v_temp&
endperform
in the program ZTEST
ITCSY is the structure which contains the name field and value field.
form GET_PRODUCT TABLES IN_PAR STRUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
declare the variable for qty price and temp variable for storing the product inside the subroutine.
READ TABLE IN_PAR WITH KEY 'V_QTY'.
if sy-subrc eq 0
qty = IN_PAR-VALUE
endif
READ TABLE IN_PAR WITH KEY 'V_PRICE'.
if sy-subrc eq 0
price = IN_PAR-VALUE
endif
temp = price * qty.
READ TABLE OUT_PAR WITH KEY 'V_temp'.
if sy-subrc eq 0
OUT_PAR-VALUE = temp.
modify OUT_PAR index sy-tabix.
endif
endform.
If you have any queries please let me know.
‎2014 Apr 03 11:06 PM
Hi Enrique,
Use Perform ....Endperform statement and try to multiply it in a subroutine program and then pass it to script by changing parameters and use that in your Script.
Thanks,
Siva.A
‎2014 Apr 04 4:51 AM
Hello Enrique,
You need Call Perform block for calculation purpose by making use of parameters.
example:
If you want multiply qty and price then you pass Qty and Price value and along with storage variable for the output to the program.
syntax:
v_qty for Qty
v_price for price
v_temp for storage the output
ztest is the calling program where you will your logic
PERFORM GET_PRODUCT IN PROGRAM ZTEST using &v_qty& using &price& changing &v_temp&
endperform
in the program ZTEST
ITCSY is the structure which contains the name field and value field.
form GET_PRODUCT TABLES IN_PAR STRUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
declare the variable for qty price and temp variable for storing the product inside the subroutine.
READ TABLE IN_PAR WITH KEY 'V_QTY'.
if sy-subrc eq 0
qty = IN_PAR-VALUE
endif
READ TABLE IN_PAR WITH KEY 'V_PRICE'.
if sy-subrc eq 0
price = IN_PAR-VALUE
endif
temp = price * qty.
READ TABLE OUT_PAR WITH KEY 'V_temp'.
if sy-subrc eq 0
OUT_PAR-VALUE = temp.
modify OUT_PAR index sy-tabix.
endif
endform.
If you have any queries please let me know.
‎2014 Apr 04 2:42 PM
‎2014 Apr 04 7:50 AM
‎2014 Apr 04 11:18 AM
Hi,
suppose i found a way to mount and format a disc "in SapScript" - would it still be a sensible idea to try to do so..? Calculations are of course entirely different "animals", but still - why does the driver programm need to go to SapScript to perform a calculation (or even perform it itself), why can't the data preparation logic be independent of SapScript and the driver programm (ideally built in such a way, that it can easily be reused in a Print Workbench Form Class)? That way, should somebody someday wish to replace SapScripts with something else, you have one less concern...
cheers,
Janis