Technical Articles
Funny (?) glitch in ABAP development {riddle}
Today I ran through a problem with macros.
I wanted to use 2 parameters in a macro but the second parameter should also be initial.
DEFINE _where_cond.
APPEND |&2 field&1 = var&1| TO dynamic_where.
END-OF-DEFINITION.
START-OF-SELECTION.
_where_cond 1.
_where_cond 2 AND.
The editor shows up the following error:
Call macro _WHERE_COND without 2. Actual parameters.
Solutions
First I wanted to add an IF statement to add the AND command but I found it not “nice”.
The next idea was to define 2 macros what I also discarded as the macro was some more lines longer and I wanted to have the macro as short as possible,
The third – and final – solution was:
IF dynamic_where IS NOT INITIAL.
APPEND 'AND' TO dynamic_where.
ENDIF.
Riddle
In the meantime I encountered another solution, which was very, very bad.
Can you guess which?
Please no discussion about not using macros anyway. thanks.
won’t this work?
No. ?
Shouldn’t the 2nd macro placeholder &2 be defined as a variable in the string template?
Tbh, i was not aware of this behavior in macros
Cf. Placeholders in macros
Hey Suhas Saha , this is a good solution!!
But not what I thought about...
a macro that calls a macro? worse than a macro...
worse than everything Lars Hvam 🙂
My "solution" is quite evil.
I will show you the "evil solution":
?
What do I miss?
you can’t see the evil, but it's there… ?
http://www.fileformat.info/info/unicode/char/00a0/index.htm
Neither do I nor the browser ?
but the editor does...
Indeed.
ABAP editor does,
but when I copied your code from here it didn't include the "forbidden" character.
The blog seems to eliminate the ALT-255 character (or I made a mistake when copying it).
To "space" or not to "space" is the question ?
This is pure evil, did you attend the "Obfuscation 101" course?
I created it 😀