05-12-2015 4:32 PM
Hi, pragmas are an alternative to pseudo-comments. Using pseudo comments in SCI checks is well understood. Can you give me example how to use custom defined pragmas in custom SCI checks?
Best Regards,
Tobias
05-20-2015 9:23 AM
Hi Tobias,
Up to now, pragmas only work for the ABAP syntax check and for the extended program check where they replace the old pseudo-comments. Code Inspector checks still only use pseudo-comments.
I doubt that there is something like a 'custom defined' pragma.
Best Regards, Randolf
05-20-2015 9:23 AM
Hi Tobias,
Up to now, pragmas only work for the ABAP syntax check and for the extended program check where they replace the old pseudo-comments. Code Inspector checks still only use pseudo-comments.
I doubt that there is something like a 'custom defined' pragma.
Best Regards, Randolf
05-20-2015 10:00 AM
Well using NW 7.40 SP 03 there are options using enhancements.
SAP has prepared something:
check CL_CI_SCAN CONSTRUCTOR
The statement:
SCAN ABAP-SOURCE p_include->lines
TOKENS INTO tokens
STATEMENTS INTO statements
LEVELS INTO levels
STRUCTURES INTO structures
FRAME PROGRAM FROM p_include->trdir-name
INCLUDE PROGRAM FROM p_include->trdir-name
MESSAGE INTO message
INCLUDE INTO include
LINE INTO line
WORD INTO word
WITH ANALYSIS
WITH INCLUDES
WITH COMMENTS.
can be enhanced to:
...
SCAN ABAP-SOURCE p_include->lines
TOKENS INTO tokens
STATEMENTS INTO statements
LEVELS INTO levels
STRUCTURES INTO structures
FRAME PROGRAM FROM p_include->trdir-name
INCLUDE PROGRAM FROM p_include->trdir-name
MESSAGE INTO message
INCLUDE INTO include
LINE INTO line
WORD INTO word
WITH ANALYSIS
WITH INCLUDES
WITH COMMENTS
WITH PRAGMAS '*'.
We are using this to validate if developers wrote explaining text behind pragmas.
05-20-2015 10:55 AM
This is interesting. So using this (internal!) command you can get the pragmas in the source code.
If I understand you right you scan the source again - in your SCI class?- and get the pragmas to check them. Since a custom pragma is stored in transparent table TRPRAGMA this should also work.
Do you have experience with this technique in own SCI checks?
Cheers und "Gruß in meine alte Heimat",
Tobias
05-20-2015 11:42 AM
Yes we have experience with own test.
No we did en enhancement to the SAP Classes to work with SAP Checks and with our new ones.
At the moment it's only one that uses this pragma feature.
Hope I will find time to blog about this.
Greetings from Hamburg.
Timo
03-11-2016 8:13 AM
To keep this thread up-to-date: at least with 7.40 SP 11 one can create custom pragmas (they are own ABAP data dictionary entities)
01-24-2022 10:40 AM
Great news that "custom pragmas" are available!
Just a little drawback: when using a pragma with own name, syntax checks warns the "unknown pragma" (understandable, from his viewpoint 🙂 ). If the custom pragmas could be defined in some place of the system, to make them known to the syntax check, it would be perfect, but I can live with the current state.