cancel
Showing results for 
Search instead for 
Did you mean: 

IF condition in SAP Script

Former Member
0 Kudos

Hi All,

I am getting problem with IF statement in SAP Script. I need to display one column DR/CR based on the amount field values.

For this i have written like this.


IF &bseg-dmbtr& LT 0
DEFINE &VAR& = 'CR'
ELSE
DEFINE &VAR& = 'DR'
ENDIF

Here VAR is a variable defined here only .

Here, if statement is not working properly.

Can any one Help me.

Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

kesavadas_thekkillath
Active Contributor
0 Kudos

You cannot compare numeric values in script. In your program code it as

IF bseg-dmbtr LT 0.

flag = 'X'.

else.

flag = ' '.

endif.

In your script code it as

IF &flag& EQ 'X'.

DEFINE &VAR& = 'CR'

else.

DEFINE &VAR& = 'DR'

endif.

Former Member
0 Kudos

any option is there to compare in script. ?

kesavadas_thekkillath
Active Contributor
0 Kudos

In your script you can also use this. SHKZG is the debit/Credit Indicator.

IF &BSEG-SHKZG& EQ 'H'.

DEFINE &VAR& = 'CR'.

ELSE.

DEFINE &VAR& = 'DR'.

ENDIF.

Former Member
0 Kudos

Thanks for your reply.

Can we compare based on the amount value?

like if it is -VE ......&var& = 'CR'....becoz i do not have SHKZG field in my structure. I am using RF130 structure here.

Former Member
0 Kudos

How are you referring to BSEG if your structure is RF130? have you tried something like:

Define &VARP& = 'DR'

Define &VARN& = 'CR'.

/: If &amount field& < 0.

  • &amount field&&VARN&

/: else

  • &amount field&&VARP&

/: endif.

Of course, we usually don't output CR/DR if there is a +/- sign on the number, do we?

Former Member
0 Kudos

Hi,

Thanks for your reply.

I have used RF130 structure only not BSEG.

Still that IF condition is not working Properly.

Is there any thing like numeric values can not compare in If conditions in SAP SCRIPTS?