Skip to Content
0

Extension of if statement in SAP standard text (SO10)

Nov 21, 2016 at 11:20 AM

541

avatar image
Former Member

There is an if condition inside SAP standard text . that exceeding the line limit Shift + f8 .

When i tried to extend the line with tag line such /: /= and space . It is not working as expected.

Is there anyway if statement can be extended even after the extension command shift + f8.

Just an additional info

Here i am sharing one sample code for understanding purpose

IF &var& = '1000' OR &var& = '2000' OR &var& = '2700' OR &var& = '3000' OR 
&var& = '3300' .
logic..... 
Endif.

I need to add few more &var& value inside the if condition.

Any input would be helpful.

Regards,

Prabin





10 |10000 characters needed characters left characters exceeded

You have used wrong Primary Tag. It should have been ABAP which I have done.

0
Former Member
G Lakshmipathi

Thank you. I was not sure about tag .

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Sandra Rossi Nov 22, 2016 at 01:39 PM
0

As explained in the documentation:

  • You must not extend a condition over more than one line. Both the IF or ELSEIF command and the attached condition must be completely contained within a single line.

Workaround:

  • Use an additional flag:
  • DEFINE &bool& = ''
    IF &var& = '1000' OR &var& = '2000'.
    DEFINE &bool& = 'X'.
    ELSEIF &var& = '2700' OR &var& = '3000' OR &var& = '3300'.
    DEFINE &bool& = 'X'.
    ENDIF

    IF &bool& = 'X'.
  • Or use a PERFORM to test the condition, and return a boolean, which you can then test.
Show 8 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Sandra

I am not sure how can i implement your suggestion in this scenario.

I would like to explain the code in detail to confirm that i am in right track.

Sample code

IF &var1& = '1000' OR &var1& = '2000' OR &var1& = '2700' OR &var1& = '3000' OR 
&var1& = '3300' .
 

  IF &var2& EQ 'abcd' .
  TEXT TO BE PRINTED IN SCRIPT OUTPUT...
  ELSE.
  TEXT TO BE PRINTED IN SCRIPT OUTPUT...
  ENDIF.

Endif.

In the above scenario I need to insert few more &var1& value for the first if condition.

example &var1& = '4000' &var1& = '5000'......

But inside standard text editor (SO10) if statement can not be extended to second line.

So what i follow from your answer that i can include ELSEIF for the first if condition then i have to include second if condition for both IF and ELSEIF condition (Highlighted below).

First if condition

IF &var1& = '1000' OR &var1& = '2000' OR &var1& = '2700' OR &var1& = '3000' OR 
&var1& = '3300' .
SECOND IF CONDITION....
ELSEIF &var1& = '4000' &var1&  = '5000' .
SECOND IF CONDITION...
ENDIF.


Second if condition

  IF &var2& EQ 'abcd' .
  TEXT TO BE PRINTED IN SCRIPT OUTPUT...
  ELSE.
  TEXT TO BE PRINTED IN SCRIPT OUTPUT...
  ENDIF.


Here my concern is how can i avoid the duplicating the second if condition code.

Please confirm if my observation is right .

0

Look at my answer again, IF and ELSEIF do span on only one line each, the two of them finally correspond logically to a big IF. I can't explain better.

0
Former Member
Sandra Rossi

I think my code was bit confusing for you.

By mistake the first line extended to second line .

Actually my code should have been looked like (highlighted below)

IF &var& = '1000' OR &var& = '2000' OR &var& = '2700' OR &var& = '3000' OR &var& = '3300' .
SECOND IF CONDITION....
ELSEIF &var& = '4000' &var&  = '5000' .
SECOND IF CONDITION...
ENDIF.

By the way thanks for your response.

previous-code.png (10.0 kB)
0

If you apply my answer, your code should look like :

DEFINE &bool& = ''
IF &var& = '1000' OR &var& = '2000' OR &var& = '2700' OR &var& = '3000'
DEFINE &bool& = 'X'
ELSEIF &var& = '3300' OR &var& = '4000' OR &var& = '5000'
DEFINE &bool& = 'X'
ENDIF

IF &bool& = 'X' AND <2nd Condition>
0
Former Member
Sandra Rossi

Now it's clear to me .

I can definitely implement the above logic .

0
Former Member
Sandra Rossi

Though i defined the Boolean &FLAG& and assigned 'X' ,

Value 'X' is not reflecting for &FLAG&

Syntax :

DEFINE &FLAG& = 'X'

what can be the issue .

0
Former Member
Former Member

I can only change the value inside SO10 .

So first I need to define the flag in program .

0
Show more comments