cancel
Showing results for 
Search instead for 
Did you mean: 

SAPScript conditions

Former Member
0 Kudos

Hi experts,

I have a sapscript. I want to display some variable on the form. I want to create the following logic:

if var1 eq 1.

display bukrs on the form.

else.

display matnr on the form.

endif.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi



/:  IF &var1& EQ 1
PF &bukrs&
/: ELSE
PF &matnr&
/: ENDIF

Pushpraj

Former Member
0 Kudos

I tried this one, but it displays both of the values, why is it?

/: IF &ITAB-ZKTIP& EQ '1'

DF &itab-mid&

/: ELSE

DF &itab-aufnr&

/: ENDIF

Edited by: mrwhite on Jan 30, 2009 12:28 PM

Edited by: mrwhite on Jan 30, 2009 12:31 PM

Former Member
0 Kudos

Hi

Your code seems to be right: so probably the problem is not here, but in other lines.

Try to check where u sed that variable in your sapscript

Max

Answers (4)

Answers (4)

Former Member
0 Kudos
Former Member
0 Kudos

Hi,

I don't think there is anything wrong in your code. Just try using 'case' statements instead of 'if' ,

/:CASE &var1&.

/:WHEN '1'.

&bukrs&.

/:WHEN OTHERS.

&matnr&.

/:ENDCASE.

Hope this helps.

Regards,

Deepthi.

Former Member
0 Kudos

If var1 is char then use '1'.

if &var1& eq 1.

&bukrs&

else.

&matnr&

endif.

This will help

Regards,

Prashant

Former Member
0 Kudos

Hi,

Try using a IF command in your editor as mentioned above. Also in your driver program loop through the respective tables so that you get the values of bukrs and matnr from the table.

Hope this helps.

Regards,

Deepthi.