cancel
Showing results for 
Search instead for 
Did you mean: 

mathematical operations in sap scripts

Former Member
0 Kudos

Hi experts,

How can i do mathematical operations in sap script ?

my code is:

&netval& = &netval& - &fre_chrg&.

but it is not working.

what is the correct way?

thanks.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

You can not do any mathematical calculations in Script directly.

However, this can be done by using subroutine. You can either define a subroutine in the driver program or in any other program. And then you can call this subroutine in your script.

/:PERFORM calculate IN PROGRAM zcalculate
/:USING &fre_chrg&
/:CHANGING &netval&
/:ENDPERFORM

Regards,

Kate

former_member588853
Active Contributor
0 Kudos

Hi,

Write a perform and do the calculations

Eg:

/:PERFORM f_clac IN PROGRAM Zcaluclation_scr

/:USING &your fields&

/:CHANGING &ouput filed&

/:ENDPERFORM

The report :

REPORT Zcaluclation_scr.

FORM f_calc input type itcsy

output type itcsy.

        • your code

ENDFORM.

rewards if useful,

regards,

nazeer

Message was edited by:

nazeer shaik

Former Member
0 Kudos

Hi

You can't do mathematical operations in Script

You have to write a Subroutine program using PERFORM.. statement see the sample code

How to call a subroutine form SAPscripts

The Form :

/:PERFORM CDE_CENT IN PROGRAM ZKRPMM_PERFORM_Z1MEDRUCK

/:USING &EKKO-EBELN&

/:CHANGING &CDECENT&

/:ENDPERFORM

The report :

REPORT zkrpmm_perform_z1medruck .

DATA : BEGIN OF it_input_table OCCURS 10.

INCLUDE STRUCTURE itcsy.

DATA : END OF it_input_table.

  • déclaration de la table output_table contenant les

variables exportées

DATA : BEGIN OF it_output_table OCCURS 0.

INCLUDE STRUCTURE itcsy.

DATA : END OF it_output_table.

DATA : w_ebeln LIKE ekko-ebeln,

  • w_vbeln LIKE vbak-vbeln,

w_zcdffa LIKE vbak-zcdffa.

*----


*

  • FORM CDE_CENT

*

*----


*

FORM cde_cent TABLES input output.

it_input_table[] = input[].

it_output_table[] = output[].

READ TABLE it_input_table INDEX 1.

MOVE it_input_table-value TO w_ebeln.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = w_ebeln

IMPORTING

output = w_ebeln.

SELECT SINGLE zcdffa FROM ekko

INTO w_zcdffa

WHERE ebeln = w_ebeln.

it_output_table-name = 'CDECENT'.

MOVE w_zcdffa TO it_output_table-value.

MODIFY it_output_table INDEX 1.

output[] = it_output_table[].

ENDFORM.

Reward points for useful Answers

Regards

Anji