cancel
Showing results for 
Search instead for 
Did you mean: 

Difference of 2 columns as 3 column in SAP Script

Former Member
0 Kudos

Hi,

I have 2 columns &BSID-DMBTR and &BSID-SKNTO& in a script and need to have a 3 column which is the difference of both these columns.

So in the script I have coded like this.

/: DEFINE &W_BALANCE&

/: &W_BALANCE& = &BSID-DMBTR& - &BSID-SKNTO&

And then write.

  • &W_BALANCE&

But I am not getting the value w_balance as the above statement in bold is not being executed by the system.

Any ideas how we can achieve the same?

Thanks!!!

Accepted Solutions (1)

Accepted Solutions (1)

valter_oliveira
Active Contributor
0 Kudos

Hello.

Use perform statement and create a report to make the change like this:

/: PERFORM f_difference IN PROGRAM zprogram

/: USING &BSID-DMBTR&

/: USING &BSID-SKNTO&

/: CHANGING &W_BALANCE&

/: ENDPERFORM

Check link about perform in script:

http://help.sap.com/saphelp_nw70/helpdata/EN/d1/80318f454211d189710000e8322d00/frameset.htm

Regards.

Valter Oliveira.

Answers (2)

Answers (2)

former_member196280
Active Contributor
0 Kudos

Arthematic operations are not possible inside form, you have to do the calculation explicitly and call it inside the form.

Go through this example

Ex. In FORM

/: PERFORM <Subroutine name> IN PROGRAM <subroutine prog name>

/:USING &<field name>&

/:CHANGING &<field name1&

/:ENDPERFORM

Program:::

Then create subroutine pool program and you have to write the code.

FORM ><subroutine name> tables int_cond structure itcsy

outt_cond structure itcsy.

data : value(20), value1(20). "do your own declarations

Read int_cond table index 1.

value = int_cond-value.

value1 = value1 + value.

Read outt_cond table index 1.

outt_cond-value = value1.

Modify outt_cond index 1.

ENDFORM.

Just rough idea given above.

Close the thread once your question is answered.

Regards,

SaiRam

Former Member
0 Kudos

Hi,

In Scripts you cannot do Arithmatic Calculations so in order to do so use

/:PERFORM

/:ENDPERFORM

In this Command we pass two values

1 USING

2 CHANGING

In Using pass the &BSID-DMBTR&

and &BSID-SKNTO&

In changing pass &W_BALANCE&

You also need to have a ZPROGRAM of Include or Executable type in which you'll have to write the logic.

Please Close the task if your issue is Solved.

Regards