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

Text Editor check syntax

Former Member
0 Likes
694

Hi, currently I have a text editor. I need to check the abap syntax that users key inside the text editor. how can I do that?

please provide codes.

thanks. will reward points if useful.

1 ACCEPTED SOLUTION
Read only

Sougata
Active Contributor
0 Likes
629

Get all the code in the text editor into an internal table, then use statement


SYNTAX-CHECK FOR itab MESSAGE mess LINE lin WORD wrd 
                 [PROGRAM prog] [DIRECTORY ENTRY dir] 
                 [WITH CURRENT SWITCHSTATES] 
                 [error_handling]. 

See example program below:


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. 

Hope this helps,

Cheers,

Sougata.

4 REPLIES 4
Read only

Sougata
Active Contributor
0 Likes
630

Get all the code in the text editor into an internal table, then use statement


SYNTAX-CHECK FOR itab MESSAGE mess LINE lin WORD wrd 
                 [PROGRAM prog] [DIRECTORY ENTRY dir] 
                 [WITH CURRENT SWITCHSTATES] 
                 [error_handling]. 

See example program below:


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. 

Hope this helps,

Cheers,

Sougata.

Read only

Former Member
0 Likes
629

hi sougata thanks for your reply.

Am i suppose to add a button onto my screen so that after users key in the codes and click on the button, it will check the syntax?

can provide me the codes for the screen layput?

thanks.

Read only

Former Member
0 Likes
629

hi sougata, after tryin out the codes, the system promt me this meaasge with i click on the "save" button:

The program is not Unicode-compatible, according to its program attributes.

In Unicode, DESCRIBE LENGTH can only be used with IN BYTE MODE or IN CHARACTER MODE addition.

can i know what is the problem and how to solve it? thanks.

Read only

0 Likes
629

Also check FM's: EDITOR_SYNTAX_CHECK or RS_SYNTAX_CHECK.

Both FM's belong to fucntion group: S38E related to Editor.

Kind Regards

Eswar