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

How to Check the syntax errors programatically?

Former Member
0 Likes
1,246

Dear friends,

I am in the process of finding how to check the syntax errors in a programatic way .

The scenario is :

I would get the Development objects like Class , Report, Function module in a table which will exist in the system.

I would like to run syntax check on each of these objects seperately and collect all the issues if exists and display.

Please suggest.

Thanks

MGR

Moderator Message: Please search before posting your question. This concept has been discussed in forums before. There is a class available to do this( Search &  get it )

Message was edited by: Kesavadas Thekkillath

4 REPLIES 4
Read only

Sougata
Active Contributor
0 Likes
1,002

Use syntax:

SYNTAX-CHECK FOR itab MESSAGE mess LINE lin WORD wrd DIRECTORY ENTRY dir.

Example below from ABAPHelp.

DATA: itab TYPE STANDARD TABLE OF string,
      mess TYPE string,
      lin  TYPE i,
      wrd  TYPE string,
      dir  TYPE trdir.

APPEND 'PROGRAM test.'                  TO itab.
APPEND 'DATA dat TYPE d.'               TO itab.
APPEND 'DATA len TYPE i.'               TO itab.
APPEND 'DESCRIBE FIELD dat LENGTH len.' TO itab.

SELECT SINGLE *
       FROM trdir
       INTO dir
       WHERE name = sy-repid.

dir-uccheck = ' '.

SYNTAX-CHECK FOR itab MESSAGE mess LINE lin WORD wrd
             DIRECTORY ENTRY dir.

IF sy-subrc = 4.
  MESSAGE mess TYPE 'I'.
ENDIF.

dir-uccheck = 'X'.

SYNTAX-CHECK FOR itab MESSAGE mess LINE lin WORD wrd
             DIRECTORY ENTRY dir.

IF sy-subrc = 4.
  MESSAGE mess TYPE 'I'.
ENDIF.

Moderator Message: Please refer to the SAP documentation ( URL ) instead of pasting the code here.

Message was edited by: Kesavadas Thekkillath

Read only

Former Member
0 Likes
1,002

Hi ,

can you please send the source code for the CL_RECA_RS_SERVICES this would be helpful.

this is not available.

Thanks

MGR

Read only

0 Likes
1,002

Its available in Wiki Section , authored by Vinod Kumar. Just search using this name and class name .

I'm glad you did a search

Please note that this class has a limitation that the syntax check can be only done for "programs". The keyword "SYNTAX CHECK" must not be used by developers( its sap internal command ). There are some functions like RS_SYNTAX_CHECK,EDITOR_SYNTAX_CHECK etc. You can do a work around.

Kesav

Read only

Sougata
Active Contributor
0 Likes
1,002

Kesavadas Thekkillath wrote:

The keyword "SYNTAX CHECK" must not be used by developers( its sap internal command ).

That is not entirely correct. SYNTAX-CHECK FOR itab is NOT a SAP internal language element.