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

Q: What does this statement do?

Former Member
0 Likes
1,970

Hi Experts,

I have come across the following code (in a SAP standard function module):

F 1 = 2. MESSAGE E008(R3). ENDIF.

Can somebody please explain what this does? As I see it 1 is never equal to 2, so this if-statement is never true, hence I do not see the point of having it...

Thank you in advance,

Mikael

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,889

> Hi Experts,

>

> I have come across the following code (in a SAP standard function module):

>

> IF 1 = 2. MESSAGE E008(R3). ENDIF.

>

> Can somebody please explain what this does? As I see it 1 is never equal to 2, so this if-statement is never true, hence I do not see the point of having it...

>

> Thank you in advance,

> Mikael

Hello Mikael,

This gives a reference as to where the message E008 of Message Class R3 is being used.

SAP uses this cheeky trick to keep track where this message is being used.

BR,

Suhas

11 REPLIES 11
Read only

rainer_hbenthal
Active Contributor
0 Likes
1,889

It will throw an compilation error.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,890

> Hi Experts,

>

> I have come across the following code (in a SAP standard function module):

>

> IF 1 = 2. MESSAGE E008(R3). ENDIF.

>

> Can somebody please explain what this does? As I see it 1 is never equal to 2, so this if-statement is never true, hence I do not see the point of having it...

>

> Thank you in advance,

> Mikael

Hello Mikael,

This gives a reference as to where the message E008 of Message Class R3 is being used.

SAP uses this cheeky trick to keep track where this message is being used.

BR,

Suhas

Read only

Former Member
0 Likes
1,889

Hi,

Thank you for your answers,

@ Rainer: It compiles fine.

@ Suhas: Ok, so why do they not just write a comment then?

Best regards,

Mikael

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,889

Hello Mikael,

It is generally used in BAPIs where the user gets an error in BAPIRET structure & if there is no reference of where the message is being populated & it will take some effort to find it out.

SAP uses this small trick to keep track where this message is being used. So that a "where-used" on the message will take the user to this line of code.

Awaiting other users' response.

BR,

Suhas

Read only

0 Likes
1,889

> Awaiting other users' response.

Not necessary, your answer is 100% correct imho.

Thomas

Read only

0 Likes
1,889

> Hi,

>

> Thank you for your answers,

>

> @ Rainer: It compiles fine.

> Best regards,

> Mikael

No, it will not. For sure. F is not a keyword.

Read only

Former Member
0 Likes
1,889

Hi Rainier,

No, I can see that I didn't copy the I in the IF statement, so the code I wrote in my original post would not work, but it should be an IF-statement.

Best regards,

Mikael

Read only

former_member222860
Active Contributor
0 Likes
1,889

Check if Is validating for variable F1 = 2

Read only

Former Member
0 Likes
1,889

Hi Mikael Kilåker ,

This type of comment is being used when we are developing smart forms, in that case if we need to comment some text box then in condition tab we used to put 1 = 2, which is never possible and that is commented.

So its totally upto the developer if he even uses it in normal coding.

Thanks

Rohit G

Read only

Former Member
0 Likes
1,889

Hi,

If 1 = 2.

msg..........

endif.

If the condition is true then only it will show that message in else part you should give some message.

That condition is useless. No use in the progarm,

Did u check out declaration part? wheather macros are defind?

regards,

pravin

Read only

Former Member