Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAPSCRIPT Math?

Former Member
0 Likes
964

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
805

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

4 REPLIES 4
Read only

Former Member
0 Likes
806

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

Read only

Former Member
0 Likes
805

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

Read only

Former Member
0 Likes
805

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

Read only

Pawan_Kesari
Active Contributor
0 Likes
805

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&