Application Development 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: 

How to use Custom Pragmas in Custom SCI Checks?

ttrapp
Active Contributor
0 Kudos

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

1 ACCEPTED SOLUTION

former_member184455
Active Participant
0 Kudos

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

6 REPLIES 6

former_member184455
Active Participant
0 Kudos

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

0 Kudos

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.

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

0 Kudos

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

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)

rdiger_plantiko2
Active Contributor
0 Kudos

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.