cancel
Showing results for 
Search instead for 
Did you mean: 

If condition exceeded more than one line in scripts

Former Member
0 Kudos

Hi,

this is Anil.I got a problem in scripts.In my script 'IF' condition is exceeeded more than one line.what ever i kept in the first line of the IF condition ,it is working properly.but from the second line onwards the code is not working properly.can any one help me in this topic plz.I have tried '=','/=','/',continuos text also.

Thank you,

Anil.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member

Hi,

In that if condition better to write another IF condition.

I mean nested if.

Regards and Best wishes.

Former Member
0 Kudos

/: IF &VBDKR-LAND1& = 'FI' OR &VBDKR-LAND1& = 'DE' OR

/: &VBDKR-LAND1& = 'AT' OR &VBDKR-LAND1& = 'CY' OR

/: endif

suppose these are the two lines of the condition,but only the lands in the first line of if conditin are working,but in the second line not working.

Former Member
0 Kudos

Hi kiran,

can u help me in solving this problem.

Former Member
0 Kudos

Hi Anil,

There is one other option is well in SAP script. Pls follow the steps:

1. On the same editor scrren follow the path to put whole condition in one line:

a. Put the cursor on the line which you wud like to extend, then (In main menu) Edit -> Page Left/Right -.

Now here your are in right side of the editor, You can put remaining statement here.

Pls tell me if it is not clear.

Regards,

Lokesh.

Former Member
0 Kudos

HII,

CAN U PLZ HELP ME HOW TO EXTEND THE LINE IN SCRIPT.

THANK YOU,

ANIL

Former Member
0 Kudos

Hi,

I think there are two more options.

1. If whole editor line is full than from next line put the tage format = (Extended Line), ang put the condition in this line.

2. Follow the path: double click on window -> Click on Text Element... Now you will be at editor page. So do not change the editor here. Just put your code on that page. Try this.

Regrads,

Lokesh.

Edited by: Lokesh Tarey on Apr 23, 2010 3:28 PM

Former Member
0 Kudos

Hi anil,

I know your problem and you've to use one of the already mentioned workarounds, but I've another hint. Instead of

/: IF &VBDKR-LAND1& = 'FI' OR &VBDKR-LAND1& = 'DE' OR

/: &VBDKR-LAND1& = 'AT' OR &VBDKR-LAND1& = 'CY'

/: ENDIF

write this

/: DEFINE &L& = &VBDKR-LAND1&

/: IF &L& = 'FI' OR &L& = 'DE' OR &L& = 'AT' OR &L& = 'CY'

/: ENDIF

With the little trick to use a shorter symbol for the original symbol you'll get a shorter IF-Statement!

Former Member
0 Kudos

Hello,

Try Writing a perform subroutine in external program, and perform the validations needed.

Based on the results, take further action.

Hope this helps.

THanks,

Kaleem.

Former Member
0 Kudos

Dear Anil,

I think there is some misunderstanding between you and us..

I think all the suggested solutions (i think there were 4 different: many IFs, CASE, PERFORM, shifting page...) will work correctly, just try any of them and you will see

Regards,

MC

Former Member
0 Kudos

Hi Anil,

Try do what Kiran suggested, you can achieve it via following statements:

/: IF &VBDKR-LAND1& = 'FI' OR &VBDKR-LAND1& = 'DE'

/: do_what_you_want

/: ELSE

/: IF &VBDKR-LAND1& = 'AT' OR &VBDKR-LAND1& = 'CY'

/: do_what_you_want

/: ENDIF

/: ENDIF

If you have only ORs in your conditional statement it is quite easy to implement it (one example solution is written above).

The problem may occur when you will have more complicated condition.In such case it is easier to call subroutine and make all conditions and calculations outside the sapscript, and return necessary data back to the form.

Kind regards,

MC

Former Member
0 Kudos

Hi,

/: IF &VBDKR-LAND1& = 'FI' OR &VBDKR-LAND1& = 'DE' OR

/: &VBDKR-LAND1& = 'AT' OR &VBDKR-LAND1& = 'CY' OR

/: &VBDKR-LAND1& = 'CZ' OR &VBDKR-LAND1& = 'DK' OR

/: &VBDKR-LAND1& = 'EE' OR &VBDKR-LAND1& = 'ES'

FT: SOME TEXT

/: ELSE

FT: SOME TEXT

/: ENDIF.

This is my condition.so for these lands the footer should display in scripts else it should priint another.

sooo for me the lands in ist line of the IF condition is working form 2nd line lands are not working .

sooo kindly help me in this plz.

Thank you,

Anil.

Former Member
0 Kudos

Hi,

I would suggest the following solution:


/: CASE &VBDKR-LAND1&
/: WHEN 'FI'
FT: SOME TEXT
/: WHEN 'DE'
FT: SOME TEXT
/: WHEN 'AT'
FT: SOME TEXT
/: WHEN 'CY'
FT: SOME TEXT
/: WHEN 'CZ'
FT: SOME TEXT
..... the same for each country
/: WHEN OTHERS
FT: SOME OTHER TEXT
/: ENDCASE

Kind regards,

MC

Former Member
0 Kudos

Hi,

The answer u have given is correct if there are diff texts for diff lands,but for me same footer has to be printed for all the lands in that if condition.sooo i cant use the case ,plz try again.

thank you.

former_member205763
Active Contributor
0 Kudos

goto edit and select shift left/right and enter conditions, i guess this way ur two conditions will be accomodated in each line for others if nothing is working then split the conditions like.

IF <condiotion>

Endif.

If <condition>

Endif.

though not a good practice but if nothing else is working use this

Or u can use a perform check the condition in perform and send back a flag.

chekc this flag to print ur texts

Edited by: Kartik Tarla on Apr 23, 2010 4:00 PM

Former Member
0 Kudos

Hi,

I don't know how long is your footer text, but you can/and should add the same footer text for each WHEN branch, except WHEN OTHERS. It is a redundant solution, but it's gonna work correctly,

Kind regards,

MC

Former Member
0 Kudos

hi kartik,

plz try to understand this.

see i have footer text which has to be printed only for the lands which are mentioned in the IF condition soo i cant use the case and nested if ,ok.soo for all the lands in if condition the footer text is same soo nested if and case conditions are useless.

plz try once.

thank you.

Former Member
0 Kudos

Hi,

Pls try the solution given above. It will work.

Lokesh...

former_member205763
Active Contributor
0 Kudos

well u can use case with same footer text in all suitable cases.

If u dont wanna use this solution then better create a subroutine use ur if condition inside this subroutine and send back a flag.

in ur script check that if flag EQ X print ur text else not.

Former Member
0 Kudos

HI lokesh,

the answer you gave is working fine.but can i extend more because it is coming upto some extend only ,how can i increase the length more .plz tell me

thank you,

Anil

Former Member
0 Kudos

hi,

can u plz help me in solving this.

thank you,

Anil.

former_member205763
Active Contributor
0 Kudos

You can not increase any further, better go for calling a subroutine in your script

Former Member
0 Kudos

hiii lokesh,

can u plz tell me how can u increase more.

thank you,

Anil.