Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Last executable line in IF stament is getting executed forcefully!!!

0 Likes
959

Dear Experts,

I was stunned when I saw, the last executable line in IF stament is getting executed forcefully. You can just copy paste the below code in a report and run.

Data:  a type char4,

          b type char4.

a = 0020

b = 0050.

if a eq b.

write / 'Majic'.

endif.

If you guys are having some ideas about it, please let me know. I am fully confused.

Thanks in Advance.

Dear Experts,

I was stunned when I saw, the last executable line in IF stament is getting executed forcefully. You can just copy paste the below code in a report and run.

Data:  a type char4,

          b type char4.

a = 0020

b = 0050.

if a eq b.

write / 'Majic'.

endif.

If you guys are having some ideas about it, please let me know. I am fully confused.

Thanks in Advance.

5 REPLIES 5
Read only

GirieshM
Active Contributor
0 Likes
911

Hi Kabitirtha,

The compiler is trying to find the end of the if statement. It is not getting executed, if you place an else statement then you can get clear idea.

The arrow mark in debugging denotes that it is getting out of the statement. if you place an else statement, then the arrow in debugging states that it is executed.

With Regards,

Giriesh M

Read only

former_member185613
Contributor
0 Likes
911

Hi,

I see that the program is not displaying any output. Can you place the screen capture of the working code lines?

Regards,

~Athreya

Read only

oliver_wurm
Active Participant
0 Likes
911

Hi,

feels like there is a hidden camera filming some ABAP experts copying the code into SE38 ...

Of course the Code is not executed (and you forgot a dot after "a = 0020").

Regards

Oliver

Read only

former_member184158
Active Contributor
0 Likes
911

Hi,

it is not a majic, just he has tried to look for a else, he did find, it and there is no another statement, so he has goten ambiguous,

so if you write else, it will be clear

DATAa TYPE char4,
          b
TYPE char4.

a
= 0020.
b
= 0050.

IF a EQ b.
 
WRITE / 'Majic'.
ELSE.
 
WRITE ' it is not majic, it is just searching the else statement'.
ENDIF.



Regards

Ibrahim

Read only

0 Likes
911

Hi

so if you write also, like this, it works, as I said, just he could not complete , he has nothing to read, so he has gotten ambiguity ,

so hier without else but there is another statement,

DATAa TYPE char4,
          b
TYPE char4.

a
= 0020.
b
= 0050.

IF a EQ b.
 
WRITE / 'Majic'.
ENDIF.

write : 'Welcome Again' .



Regards

Ibrahim