‎2008 Jan 21 2:49 AM
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.
‎2008 Jan 21 3:00 AM
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.
‎2008 Jan 21 3:00 AM
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.
‎2008 Jan 21 7:12 AM
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.
‎2008 Jan 21 7:36 AM
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.
‎2008 Jan 21 7:46 AM
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