‎2007 Jul 23 4:14 PM
Is it possible to do math functions to field values in the SAPSCRIPT text editor?
In this case I am looking to divide and multiply. Else, does the math need to be done in ABAP and passed to the SAPSCRIPT editor?
Thank-You.
‎2007 Jul 23 4:17 PM
Hi,
Yes you need to do this in the ABAP and pass back to the SCRIPT ..
Here is the regular example which you get in the WEB
http://help.sap.com/saphelp_40b/helpdata/en/d1/803279454211d189710000e8322d00/content.htm
You need to write the same perform and in the program do the MATH operations and pass back the OUTTABLE with the values, then this values will be available in the SCRIPT
Regards
Sudheer
‎2007 Jul 23 4:17 PM
Hi,
Yes you need to do this in the ABAP and pass back to the SCRIPT ..
Here is the regular example which you get in the WEB
http://help.sap.com/saphelp_40b/helpdata/en/d1/803279454211d189710000e8322d00/content.htm
You need to write the same perform and in the program do the MATH operations and pass back the OUTTABLE with the values, then this values will be available in the SCRIPT
Regards
Sudheer
‎2007 Jul 23 4:18 PM
Hello,
Yes, the Math functions are to be performed in the Subroutine Pool and get back to the script using the ITCSY structure.
Regards,
Deepu.K
‎2007 Jul 23 4:21 PM
Hi,
You can use the PERFORM command to call an ABAP subroutine (form) from any program, subject to the normal ABAP runtime authorization checking. You can use such calls to subroutines for carrying out calculations, for obtaining data from the database that is needed at display or print time, for formatting data, and so on.
PERFORM commands, like all control commands, are executed when a document is formatted for display or printing. Communication between a subroutine that you call and the document is by way of symbols whose values are set in the subroutine.
Syntax in a form window:
/: PERFORM TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
...
ENDFORM.
The values of the SAPscript symbols passed with /: USING... are now stored in the internal table IN_TAB . Note that the system passes the values as character string to the subroutine, since the field Feld VALUE in structure ITCSY has the domain TDSYMVALUE (CHAR 80). See the example below on how to access the variables.
The internal table OUT_TAB contains names and values of the CHANGING parameters in the PERFORM statement. These parameters are local text symbols, that is, character fields. See the example below on how to return the variables within the subroutine.
From within a SAPscript form, a subroutine GET_BARCODE in the ABAP program QCJPERFO is called. Then the simple barcode contained there (First page, Next page, Last page) is printed as local variable symbol.
Definition in the SAPscript form:
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/
/ &BARCODE&
Coding of the calling ABAP program:
REPORT QCJPERFO.
FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
DATA: PAGNUM LIKE SY-TABIX, "page number
NEXTPAGE LIKE SY-TABIX. "number of next page
READ TABLE IN_PAR WITH KEY PAGE.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY NEXTPAGE.
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY BARCODE.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = |. "First page
ELSE.
OUT_PAR-VALUE = ||. "Next page
ENDIF.
IF NEXTPAGE = 0.
OUT_PAR-VALUE+2 = L. "Flag: last page
ENDIF.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.Pls reward all helpful points.
Regards,
Ameet
‎2007 Jul 23 4:24 PM
Math functions can be done in SAPSCRIPT itself
try this for example
/: DEFINE &A& := 10
/: DEFINE &B& := 20
/: ADD &B& TO &A&
* A = &A&
* B = &B&